Sunday, December 21, 2014

Getting ready for the cloud: Preparation for autoscaling

Advent of cloud services has disrupted the way online services are managed. What used to be a gargantuan task of renting, deploying and managing remote servers has been replaced by single click creation and deployment. The process of creating a virtual machine is much easier and programmable than renting servers or working on shared hosting spaces. Cloud service providers create an illusion of infinite space over their own finite resources with managed services like S3 or Dropbox. This takes away any worries about resource limits. The user pays for what he uses and does not have to worry about changing servers in the future when requirement is bound to increase.

Consistency problem with auto-scaling

Considering how easy it is to create and terminate servers on cloud, the application developer tries to minimize its resource consumption. That is where comes auto-scaling. Auto-scaling is a set-up of operating at a minimum resource consumption with provision for automatically increasing resources as soon as the demand comes. Suddenly, there are 10000 users using on an application, the server has created 20 different mirror of the original server to cater to all of them.

The consistency problem

This brings us to the problem of data integrity and consistency. If user A adds a new content, this content should be available to user B accessing the website from different mirror of your server. Your dynamic cloud servers(instances) can not host any dynamic data. Any dynamic data must be consistent across the servers while keeping the resource usage minimum. You need a shared place to manage all your dynamic data.


Solutions for the consistency

Database consistency

Database being the most dynamic is fortunately a different software. You can host it on a different server and make the application servers query this single database server. Database scaling is somewhat limited with most engines not allowing a seamless scaling. e.g. MySQL for example need to stop "write" while changing servers. (You can create multiple read-replicas but there can be a single master server.) A solution is to use managed db services like dynamodb which are virtually scalable. However, the choice of database engine is dictated more by the application requirements than just scalability.

File uploads

The files which are uploaded to the application (e.g. a new user profile picture) needs to be accessible to all logged in user. You can not save this in the application uploads directory. It needs a place which is accessible from different instances behind a load balancer. One easy way out is to create another file hosting server and mount this server in other instance. Every mirror will mount this space on the uploads directory(NFS / Network File System) during boot. This way every time a file is saved in the uploads directory, it will actually be saved on the file hosting server. Alternatively, you can use a managed hosting space such as s3 and place all dynamic files there.

NFS vs managed space : When setting up NFS, you need to check the fraction of write requests that you need to process. Does the NFS server has to bear the burden of load. If every request has to use a file present on the shared space, every request is transferred to the NFS server which defies the primary objective. A managed hosting space like S3 is much better since it is completely scalable. Unless you need to host executables or program code on the shared space, a managed storage works generally. If you are using a reliable service provider, they should have scalable mechanisms for handling usage spikes with low latency. The choice of NFS vs managed space depends on what the application want to do with the content of this shared space.

Application flexibility: The application needs to modify itself to make auto-scaling work. You need to edit database paths, the place to read and write files or even the place to put temporary files. (How temporary are these files?) All these changes are going to be as complicated as the application itself. If the application is based on some preset framework, you might need to wait for a version upgrade or a mod to make your system cloud-compatible.

Monday, November 24, 2014

ffmpeg: error while loading shared libraries: libass.so.4 after upgrading system

Case

Ubuntu 14.04 running compiled ffmpeg using the directions specified on their website. Upgraded the system to 14.10. This brought a number of updates and also upgraded older libraries to newer versions. After the upgrade, running `ffmpeg` on the terminal gave the following error.

Investigation:




The solution:

Found on #ffmpeg @ freenode IRC :
abi changed. recompile

Sunday, June 29, 2014

How to stop visitors from downloading online videos?

I don't want users to download my online videos to their computer?

Videos on internet can be effortlessly downloaded to your local drive using readily available tools. Several people however want to upload a protected video, something that they would like to sell to internet. Instances of such queries can be found on the first page of Google such as this and this and this . As several video hosting companies point out, videos hosted anywhere on internet can be downloaded. A suggested rule of thumb is that if you plan to protect a video of monetary value, the best you can do is keep it away from internet. But what good is a monetary value if the commodity itself is taken away from its market. Businesses and film makers urgently need a channel that protects their content from the time of uploading to the time when the video is streamed on viewer's device.

Stop video download to prevent piracy

The web is brimming with websites offering free download of any movie or TV series. The most video creators can do is take recourse to legal action, which is in itself ineffective when there are so many website mushrooming. You can not go on tracking and suing each one of them. Movie "Pirate bay Away from keyboard" laments this affairs of copyrights versus content-sharing. It points to the need for a technology of content broadcast which is secure in itself and does not need to fall back on any legal backing.

Some solutions for stopping video download

1. RTMP 

This is one solution that some video creators go for. Basic difference is RTMP protocol which is a different method of data transfer than conventional HTTP/HTTPS methods on regular web. Acronym for Real-time media playback, this requires a real-time streaming of media data. With a little obfuscation, you can even hide RTMP server and path so as to further prevent video leeches.
Pros: One-up security over regular HTTP methods
Cons 1: Real-time playback does not provide any buffer and slightly slower internet can give broken playback resulting in poor user experience.
Cons 2 : "RTMP Explorer", a simple, small software which you can simply download, run and play RTMP video, this software will download the video straightaway.
Cons 3: Incompatible with mobiles. This protocol can not be played on mobile browsers because of lack of flash player. Best you can do is create an app for mobile platforms or fallback to HTML5 which makes your video quite vulnerable.


2. HTTP Live/Dynamic Streaming(HLS/HDS)

Apple and Adobe have both their own versions of this protocol. Set up requires a dedicated media server and also some technical know how so that you can configure adaptive bit rates. It gives some option to include elements of encryption keys to protect media headers. 
However, even this is not so difficult to download. Somebody who can see what is happening can grab the video easily. Download-helper somehow failed to download as it is just an add-on with no file system access. There is also a PHP script to download and combine fragments of a HLS/HDS into a complete offline video file. Apart from this, there are some device compatibility issues with video playback. It is not able to run without a flash player or a dedicated app.


How VdoCipher tries to provide an easy to use DRM on videos?

Considering such need of premium video creators, we have built VdoCipher as a solution to streaming protected content on internet. An online video hosting service where premium videos can be streamed while keeping video immune to downloaders. The system ensures that every single video playback requires an authentication from back-end. There are libraries to be used with different languages such as PHP or ASP or you can always use API directly. For providing mobile compatibility, there is an easy to use interface where one can create custom apps with minimal knowledge of HTML. App can be compiled and exported for both Android and iOS stores.

Website is in early beta stage and there are some features such as App-Maker which are still not online. If anybody wants to try out, I suggest check out website www.vdocipher.com and contact via contact page. If you have any queries, please ask them in comments below.

I shall cover more on features of VdoCipher and its usage in a subsequent blog post.

Monday, February 10, 2014

Original Flappy bird apk download

Flappy Bird is a 2013 mobile game developed in Hanoi by Vietnam-based developer Nguyễn Hà Đông and published by .GEARS Studios, a small, independent game developer also based in Vietnam. The game, which was released on May 24, 2013, was removed from both Apple's App Store and Google Play on February 9, 2014 by the game's author.

"insanely irritating, difficult and frustrating game which combines a super-steep difficulty curve with bad, boring graphics and jerky movement" : Huffington Post
 
Download the apk here.

Warning: It's too hard to play.

Sunday, November 3, 2013

Apache errors after upgrade from 2.2 to 2.4, or upgrading ubuntu 13.04 to ubuntu 13.10

Today I upgraded my laptop ubuntu from raring ringtail to saucy salamander. After setting the desktop to the salamander wallpaper, I moved to my http://localhost, but alas! the apache configuration was not working. I was getting the default "It works" page from /var/www/index.html . During the upload process, I was asked whether I want to update the configurations in /etc/apache2/envvars and /etc/php5/apache2/php.ini. I had selected to upgrade both of them while noting down the previous customizations that will be lost. So, I set out to correct this new after upgrade error :

1. Bring back the customization removed during the upgrade process. I usually run the apache2 process by the normal user instead of www-data. Edited the /etc/apache2/envvars file to bring back old users.
Then changed the error reporting on php.ini files. Apache restart with sudo service apache2 restart. Check http://localhost/ , still getting  the default "It works" page. Moving on..

2. The vhosts not working :
The first obvious error was that none of the virtual hosts were working. After looking through the apache.conf file in /etc/apache2 I found the line :
Include sites-enabled/*.conf
This made it mandatory for virtual hosts files to have *.conf ending to be read as legit files. To correct this error, it is better to delete all links in sites-enabled/ folder. Then append .conf to the vhosts file inside sites-available/. Then enable each site one by one. Apache reload with sudo service apache2 reload Check http://localhost/ . New error : 403 permission denied. But I corrected the run user to the file owner, let's check the logs

3. The authz issue :
Going through the logs, error coming up was
[Sun Nov 03 18:02:27.790498 2013] [authz_core:error] [pid 5530] [client 127.0.0.1:50046] AH01630: client denied by server configuration: /home/vibhav/public_html/
So apparently, the line "allow from all" in vhosts was not working as it was working before. I went to the upgrading document of apache and found that some things have changed her. Instead of
order allow, deny
allow from all
The new configuration needed
Require all granted
 Do a sudo service apache2 reload again and head to http://localhost/ . It's all working.

This worked for me. If this is not all, please check out http://httpd.apache.org/docs/2.4/upgrading.html for the official upgrade documentation. If you are still having problems, please mention it in comments below.

Friday, June 21, 2013

Consciousness after resurrection

What if a dead person actually comes alive? What if some day a scientist is able to reboot the human body after it is dead. Will the resurrected person be like the normal person he was? What shall be the consequences on his physical and mental condition? Let's delve into the mind of a resurrected person.
Resurrection is an existing concept in movies and TV serials. In the practical world, however, it is simply impossible just because it has not been done ever. There might be a scientific theory behind that. For now, I decide not to believe in this statement. Let's consider a scenario where the technology is advanced enough to be able to resurrect a dead man. The concept is no longer far-fetched given that complex brain surgery is already done on animals. Stem cells and genetic research are taking us into a domain which was earlier attributed to the meta-physical. I have a belief it is not long when doctors shall be able to resurrect a dead man after creating the damaged or missing organs.

The human body is called alive when the brain (nervous system) and the heart (circulatory system) is in sync relying on each other for their functioning. A healthy person shall be one in which this relationship of heart and brain is able to drive the respiratory, digestive and excretory systems. The nervous system makes sure that the involuntary actions of lungs, heart and kidneys go on while it is these systems that keep the nervous system alive. When a person dies, this dependence breaks due to damage on one these parts, rest of the systems break down and the human is declared dead. In our situation, doctors shall have to repair the damages body parts that resulted in death (Almost every organ but brain can now be transplanted). They shall be able to then restart the symbiotic process of circulatory and nervous systems. The person now comes alive!
The brain that solves mysteries of the universe fails to understand itself.
Note that the person was dead a moment ago. Will he retain the memories? No, a brain is a set of neurons which are saving memories in electrical impulses. It needs continuous energy to sustain the memories even for the most basic system tasks. Much like a computer RAM, all it's data are gone the moment power goes off. The electrical impulses die away and the brain is mostly static. The brain memories are not like the magnetic dipoles on a magnetic disk. It won't retain any memory of the previous 'life session'. Here we make an assumption, we hereafter belief that upon resurrection, the brain shall still be able to sustain the involuntary life actions of respiration, blood circulation and digestion. Or we can assume that these actions are still being controlled by an artificial life support system. Now that the blood circulation restarted, the brain started functioning. But, there are no memories. I do not mean the memory loss as in the fictions and movies but a simple brain format (like the formatting of a computer disk). We just assume that the BIOS (involuntary life tasks) of this computer (brain) is separately installed.
PSM V26 D764 Longitudinal section through the center of the brainAt t=0, reboot finished, blood circulation in brain is normal and reached a steady state.
The brain is static, no neuron activities, and extremely low level of feelings. Consciousness does not exist now. By consciousness, I mean a state of 'brain' when one part of it is able to assess its existence, or it is able to generate impulses in response to another set of impulses. This way it think what kind of thought is going on. This state of consciousness, or a general term called feeling, is completely absent in the subject. All over the bodies, neuron sensors have just come alive and have started responding to the external environment. These shall send electrical signals to the brain and enliven the static neurons of the brain. The brain shall now start 'working'. What will it be thinking?

The model of the brain we shall be using in this discussion: Let us consider the brain as a neural network, the one from computer science, a vast array of independent neurons sending each other signals based on the signals they receive. The only difference is that this one is sending analog signals instead of binary and the back-propagation mechanism is much more multi-directional giving a much faster computing power (It is worth noting that a neural network in comp. science does not compute, it receives values as signals and tries to adapt itself to the signal thus recognizing patterns and then it starts predicting the next value).
Neuron in tissue cultureWhenever this neural network receives a signal, it processes it and stores it. The next signal might be of a similar nature. Then the pattern has been recognized and is running in the cache (the currently active thought). Now, when the third signal arrives, the brain predicts the signal. If the received pattern is similar to what the predicted pattern, it releases some chemical to feel good and another part of the brain might start a small impulse to record this feeling, As an example, on touching four parts on the wall, a brain can recognize the fact that it is a plain two-dimensional rigid obstruction, it predicts the sense of touch when the fingers touch new part of the wall and this further strengthens the belief or the recording impulse that it is indeed a wall. This is how the predicting and object creating operates in our model of the human brain. The feeling of curiosity is propelled by the fact that brain loves repeated signals. The feel-good chemical released during the formation of a new memory has already taught the brain to learn new things. Over time, this feeling is often suppressed by thoughts more relevant to the new memory in question or just that this feeling becomes far less than many other feelings.
Back to the subject: So our neural network has just started receiving the starting signals. They shall start storing it in the neuron impulses. A few of these signals shall remain on the brain as a memory of these patterns. The person will start to decipher the signals. Based on the signals, he shall start to construct a model of the world around him. He may take time to open his eyes. He shall perhaps keep his eyes closed with no reason to open his eyes.

The person's back can sense the feel of the soft thing he is lying on, he can feel the heat of the atmosphere, the eyes has not yet opened but the light beyond has already struck chords on the cones of neurons on the retina. The fingers of his hand seem to come I contact with something. The sensitive fingertips are never late to send the sense of touch. After creating a mind model of the material in hand, the curious brain wants to get hold of this texture which is soft. If only he could just grab a little more of the material, he could discover this new pattern, this new thing, a new entity in his brain. And then something weird happens, a sense goes through his arm and the hand moves, the fingers curl on the object. Fingers move by his will, yes he can move, he has a hand which moves at his will. The feeling part of the brain gets excited, it releases the feel-good chemical into the nearby blood-vessels which makes the whole brain get excited, it makes the whole brain take an extra effort in their work. The fingers have sent a new signal, he is now holding a piece of his own bed-sheet in his hand. It feels good!! I have an arm with wrist and fingers at my command, it feels good. The excitement chemical is high in the blood around the brain, This is specially high in the area around the part which controls the hand and the finger tips. It no longer wants to restrain itself. The response from the brain is high this time. The consciousness has still not fully understood the idea of a limb. It has no control over it. The brain at his free will commands the hand to move in a random direction. The person flings his arm. This is useful as it helps him understand himself.
You might be thinking the subject is much like a baby who has just came out of womb, swinging arms and legs around, looking around curiously amazed, innocence and curiosity are visible on the face. The situation must be actually quite similar. The difference however, is more interesting. Our subject is a grown up man. His needs might be limited to food and warmth like an infant but his limbs and body are better formed. His unpredictable curious activities can be destructive like a child with a larger scale. The subject might need to be kept in constraint, may be hand-cuffed. I am quite sure when a grown up behaves like a child literally, the scene is hardly as cute as in the case of babies.
There is one more difference, our subject is a grown up man/woman. This person shall have fully developed sexual organs and thus have the capability to sense sexual feelings. His/her organs will be capable of the sense of arousal. The subject will not take time in discovering a body part with such an intense sense. The curious brain will like to discover the organs. The person will touch his/her organs and try to understand the mystery of intense sense of touch. It is safe to assume the person had not seen or observed the existence of two types of human body. He might just be too busy with his existence and understanding the new and varied stimuli he is suddenly exposed to. He shall understand more when he gains mental age and observe human society.
The person shall slowly learn to stay calm, feel hungry and understand his surroundings. The mental age of this person is equal to a new born. Unable to speak and communicate, the person shall just lie down and get active on feelings of thirst, hunger, pain etc. To further develop his mental age, he can be forced to situation where he need to be learn to communicate, he shall start to learn to speak like a little child in perhaps the same time period. In a way, it can be really embarrassing for a person to be a grown up with a mental age of a child. Being exposed to conditions where a lot shall be expected of him being a grown up might give him embarrassment or compel him to increase his mental age depending on the view of the world he would had upto that moment.
For the person, the life would be like being born in a grown body without a childhood. The language and analytical skills shall develop with time. It's hard to say the time required for a person to bring his mental age to his chronological age.
What if this is actually possible?
I think that in such an event the person must not be exposed to the plethora of senses around him. To control his senses, he should be kept under a sedative and he should be exposed to a slow and mild surroundings. The person might be kept with his eye covered. Sedatives can be used to keep a large part of his body unconscious. The exposure to senses must be slow like a baby developing in the womb. Like a fetus, he shall slowly embrace the senses and develop a stable life sustaining nervous system before actually feeling his limbs and looking with his eyes.
The exposure to the visible world must be even slower, this grown up man is more powerful than a child and his senses might be a little more developed. The person can be allowed to see the world while a greater part of his body should lay unconscious

Da Vinci Vitruve Luc Viatour colouradjusted crop240Ethics, Morals, religion and stuff!! : If possible, the process shall be the subject of a fierce controversy. The person who is resurrected is no longer the person who died. He is just a new life, a new person. This stuff is way more than sufficient to blow any medical-ethical person out his minds. Personally, I don't think it should be done even for one single time. For first reason, the person is not the same. He is a new born with the body of the dead. Second, the person shall be resurrected for no reason but for scientific experiments. Consciousness, I think is nothing but a collection of neuron impulses, is still the most sacred thing in the universe. It's the thing that drives a lot of species on earth. It gives us the feelings that we live for. It is the sole purpose of a species life. It should not be for experiments. Thirdly, the person shall come alive being the object of an experiment. I cannot even think of the thoughts in the dead person's relatives but the idea of a new person in the body of the dead is itself creepy. The new person without any relationships cannot have a happy life. Perhaps I believe in the epicurean philosophy, the thought itself is very repelling to me.

Friday, May 10, 2013

Displaying PHP file as it is executed, creating data streams in PHP

PHP allows you to display data as it is generated on the server, so while your PHP file is still being executed, the display begins and this feature can be put to some real dynamic uses. I shall cover a few of these applications and let you make more ingenious things.

Here is the code for generating PHP data stream using the flush buffer command.




1. Creating continuous data streams

2. Making synced chat

Tuesday, February 26, 2013

Preventing upstart service from starting on every boot - Things I learned today

Being a curious linux user I have installed a lot of things, server on my system. Apache, tor, ssh, mysql, postgresql are all installed. Due to this reason there were so many ports open on my system that many of them I could't understand. This situation has serious security concerns. Take for example ssh, given the laptop password, anybody on the web can login and access my data without any notification to me. (I am looking for a software which notifies me of any incoming ssh connection. Leave that for some other time.) Today, I found a way to prevent so many daemon to start with the boot up.
PS: I hate installing even a small software for doing the same job as a simple terminal command.

To stop upstart jobs from initialization during boot, one need to override the starting configuration file store in /etc/init/ . In this folder , the specific run level at which these jobs are to be started is specified in their respective ****.conf files. To override any of these jobs , simply create a file with content "manual"  and give it an extension .override.

Example : To prevent mysql server to start :

$ cd /etc/init       #go to the folder containing start scripts
$ ls - l             # take time to look into the folder
$ sudo echo "manual" > mysql.override  #create a file mysql.override with content "manual"

Done !!

Restart the system and do a quick nmap/nc/telnet to find if the mysql port (3306) is running.
Now, to start the stopped service manually use the service command :

$ sudo service mysql start       #the service command to start mysql manually

Rollback : If you have disabled your upstart job, but now want to roll back simply delete the file .override (e.g. apache2.override) from the folder /etc/init/ .

System information : The above instructions are tested upon Ubuntu 12.10 but shall be valid for most of the linux distros. If this does not work on your system, mention your system info in the comments as it shall help others.

Tuesday, January 15, 2013

Why upgrade to Gimp 2.8

After a rather long wait, Gimp has finally rolled out the new version 2.8 . This version comes with most of the features I was missing in the previous version. The new Gimp 2.8 has

Single window mode : I am out of words how much I was waiting for this.

Multi-column dialogs : It's just so useful when you are doing some complex designs. and have to use two dialogs at the same time without letting yourself bogged down with multiple windows.

Group Layers: Anybody who worked on Photoshop was missing this here. Thanks to the developers for this nice update.

Detailed release notes : http://www.gimp.org/release-notes/gimp-2.8.html

Monday, January 14, 2013

.htaccess in apache2.2/2.4 on Ubuntu LAMP setup

.htaccess not working after installing Apache

htaccess files don't work on Apache server server by default and anybody who moved from using wamp/xampp to apache encounter this problem.

htaccess is a file which can be placed in the folders of document root and is meant to override apache configurations for that particular folder. It is loaded by apache while serving request i.e. during runtime. htaccess being located inside the document root can be accessed by anybody editing the application and thus pose a security risk by it's ability to override server configuration. Hence, an Apache installation installed with default virtual hosts in /etc/apache2/sites_available/ have htaccess disallowed.

But wait! I have used wamp without any such configuration. Why this mess? If you have any experience with XAMPP or WAMP, you might have noted they allow the htaccess files by default. The reason is that while these two are for development purposes only, Apache on Linux is built for production environments. Hence, it has most of the security arrangements in place by default.

So what should you do?

It is therefore recommended to add the htaccess commands inside a directive tag in the apache configurations. Edit the virtual host file under
/etc/apache2/sites-available/
and replace
Allowoverride None with Allowoverride all . Save the file and reload apache server with

sudo service apache2 reload

Now the .htacces files located in the document folder should start working.

Why not to use .htaccess? What could be problems with .htaccess?

On a production environment, if you have access to the apache configuration files, it's always better to edit apache.conf or virtual-hosts file instead of allowing .htaccess. Why?
It decreases server load, decreases page load time resulting in better user experience. If htaccess is set to allowed and you are serving a request for /scripts/js/jslib/myjavascript.js, the server searches for a .htaccess at each folder i.e. it first searches for /.htaccess, then /scripts/.htaccess ,then /scripts/js/.htaccess ,then /scripts/js/js-lib/.htaccess . This has a direct effect on server load.

How to edit apache configuration instead of allowing .htaccess?

Case: You need to put a .htaccess file in the folder /var/www/master/ to redirect users from example.com to www.example.com. Thus, the contents of your .htaccess should be roughly the following
RewriteEngine on
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule . index.php

Alternative: Edit the apache virtual host file corresponding to your site and add the following directive instead inside the virtual host tags

<VirtualHost *:80>
 ......
 <Directory /var/www/master/>
  RewriteEngine on
  # if a directory or a file exists, use it directly
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  # otherwise forward it to index.php
  RewriteRule . index.php
 </Directory>
 .....
</VirtualHost>

Reference :
1. http://httpd.apache.org/docs/2.2/howto/htaccess.html#when

Tuesday, May 29, 2012

Bandwidth Optimization



don't let your website crash at that crucial point


Imagine an online contest taking website, or railway ticketing website, as soon as the clock strikes, there are hundreds or thousands of visitors thronging their bandwidths. Such website often get crashed or hanged. They need to make the most of the bandwidth alloted. Bandwidth optimization has grown into an essential topic for Web developers around the world. It's of vital importance to commercial websites especially those which have timed events. There are several examples where this aspect requires a good deal of thought.

Let's look at a closer picture. Imagine data coming out of the server, when a number of users come to the site at one time. The hundreds of HTTP-request made to the server are queued. While the server is a single computer(if we ignore a cloud platform where the request is redirected to another server in place of being queued) . It can handle a limited number of requests at a time. Several requests get timed out either from client or server side resulting in a small percentage of successful requests. The number of requests that a server handles at a time is the bandwidth. This is different from the one which is expressed as the amount of total data which the server provides in a given time often expressed as GB per month, but is generally unlimited if you are ready to spend a little. Such crowded scenario can be avoided by using certain bandwidth optimization techniques. I know a few of them so sharing with you. Don't let your website crash at crucial moments.
  1. Using image sprites Image sprites is a technique where a number of images are clubbed into one single image or a image and it's on-hover image are clubbed together. Such techniques are generally in use for toolbar icons or even those which are to be loaded again and again.
  1. Compress images Images can be hugely compressed to reduce it's size and scrap all unwanted hidden data from the image. For example, in Photoshop you can “save for web” instead of normal save. Similarly, large images can be substituted for SVG vector graphics. A cleverly made vector graphics can be made very small in size, though this is not always feasible. Use a compressed JPEG image whenever possible.
    Use polyclip.js for adding alpha channel to JPEG images. It'a a useful javascript library developed by Zoltan "Du Lac" Hawryluk using HTML5.
  1. Cache images Images often tend to be bandwidth extensive resource. It is best if you ask the user to cache it in the browser. This can be achieved by javascript and is recommended when an image is to be loaded in almost every page.
  1. Minification The script files can be minified to a large extent and it's an obvious first step towards decreasing the total size transferred to the client for a complete page loading. Mnification is the process of compressing script. Minificaton finds out the repeating group of words in file and tries to reduce them to numbers. It also removes all unwanted spaces and trailing tabs to make up a small script file.
  1. Clubbing together the imported files Every web page page is accompanied with a host of supporting files, the stylesheets and script files. All these files are requested from the server in separate HTTP-requests. These requests often increases the loading time. If there are more than three or four such files they can be clubbed as single stylesheet and single script file. The backend can also be programmed to bundle all these files together before sending to the client.
  1. Avoiding Flash I am discouraging Flash but Flash is actually a very high bandwidth consumer. Using Flash content increases the loading time on the client side as well. With the advent of HTML5, SVG etc. (I am not very sure how WebGL ranks in this respect) , it is recommended to avoid flash wherever possible.
  2. Moving to a cloud platform/higher bandwidth At the end, when all the above means fail to make your website stand against a wave of traffic, it is always advisable to shift to a better host providing a wider bandwidth. You are lucky enough to get such huge traffic go ahead and spend that extra dollar to get a next generation cloud platform.
“When traffic comes grab it with both hands”

The trick is to reduce the number of HTTP-requests made to the server and compressing a complete page into the smallest possible size. There are many other methods that I don't know and would love to hear from you. Please mention those methods in the comments.

Saturday, April 21, 2012

Touchegg!! WoW!!

No, that's not Mac.. that's Ubuntu *grins*. No, you don't need to write out everything you want on a Ubuntu. You actually don't need to open a terminal unless you love to do so...


That's my usual reply to a window user amazed at the beauty of my beloved 'Ubuntu'. Powered on a gnome 3.2 shell and Ubuntu 11.10, studded with diamond like extensions and completed with touchegg customization my OS is at it's best. So, I thought it is the right time to share with you my Ubuntu desktop.

Monday, April 9, 2012

An Obituary


शोक-समाचार - 'संयुक्त प्रवेश परीक्षा ने ली अंतिम सांस
संयुक्त प्रवेश परीक्षा (जेईई)
(9 अप्रैल 1960 – 8 अप्रैल 2012)

लंबे समय से कपिल चप्पल की मार झेल रही 'संयुक्त प्रवेश परीक्षा' ने अंततः 8 अप्रेल, सांयकाल 5 बजे दम तोड़ दिया| आप 52 वर्ष के थे|

आप प्रारम्भ से ही बड़े सख्त मिजाज थे| बच्चों के देखकर ही आपका पारा चढ जाता और आप उन्हें डराने धमकाने लगते| फलस्वरूप छोटे बालकों में आपका आतंक व्याप्त हो गया| लेकिन बढ़ती उम्र के साथ आपके मिजाज़ में कुछ नरमी आई|

'मानव संसाधन विकास मंत्रालय' के साथ लगभग तीस वर्षों तक आपके मधुर वैवाहिक सम्बन्ध रहे| जिसके फलस्वरूप अपनी युवावस्था में आपके सात पुत्र हुए| सभी ने बड़े होकर अलग-अलग शहरों में अपने पिता का नाम रोशन किया| लेकिन इतने से उनकी सांसारिक इच्छाएँ खत्म नहीं हुई| अपनी ढलती उम्र में भी आपने 'फाईट मार कर' आठ कमजोर-कुपोषित बच्चों को जन्म दिया| ऐसा प्रतीत हुआ मानो वे 'क्वालिटी' की बजाए 'क्वांटिटी' पर ज्यादा ध्यान दे रहें है|

बाद में आपका रुझान कोटा नामक 'कोठे वाली' की तरफ बढ़ने लगा| उनकी पत्नी (मानव संसाधन विकास मंत्रालय) ने कोटा से उनका पीछा छुड़ाने के लिए 2006 में उनका पूरा हुलिया ही परिवर्तित कर दिया| लेकिन कोटा ने उन्हें फिर भी पहचान लिया और तब से उनके सम्बन्ध और भी प्रगाढ़ हो गए| अंततः कोई चारा ना देख उनकी पत्नी ने अपने 'सीरिअल किलर - खूंखार दरिंदे – राजनेता भाई' कपिल चप्पल के साथ मिल कर अपने पतिदेव 'जेईई' के क़त्ल की साजिश रची| अपनी राजनीतिक शक्तियों का प्रयोग करते हुए 'श्री चप्पल' ने 2010 में 'जेईई' पर घातक हमला किया तब से वे जिंदगी और मौत के बीच झूल रहे थे|

लेकिन जेईई के आई.सी.यु. में भर्ती रहने के दौरान ही उनकी पत्नी 'मंत्रालय' ने ISEET नामक अज्ञात शख्स के साथ अपने संबंधों का खुलासा कर दिया| उन्होंने ये भी घोषणा कर दी की 2013 में वे परिणय सूत्र में बंध जाएंगे| मृतक जेईई के १५ बच्चों के साथ अब सौतेला व्यवहार होने की आशंका है|

लेकिन लगता है 'मंत्रालय' की खुशी अधिक दिनों तक नहीं टिकने वाली क्योंकी 'कोटा' नामक उसी 'कोठे-वाली' ने अभी से उसके मंगेतर ISEET पर डोरे डालने शुरू कर दिए है|

शोकाकुल आई.आई.टी बोम्बे, आई.आई.टी दिल्ली, आई.आई.टी कानपुर एवं समस्त आई.आई.टी परिवार|

(इस आलेख का उद्देश्य किसी को ठेस पहुंचाना नहीं है, और अगर आपको ठेस पहुचती है तो इसे मात्र एक संयोग कहा जाएगा ... सायोनारा)
Share it till 'Kapil Chappal' read this :P
with - Rajneesh meena & jotoo !
Shared by Rishabh Jain on Facebook.

Saturday, March 24, 2012

Using purge on linux, never again!

Don't ever use the purge command with a * on a linux machine unless your hate your system. Yeah, that's the crux of the story I am going to tell you. The warnings are meant for you - read it.
In the quest for making the most 'out' of my laptop, (I guess that best explains my actions) I was jovial for running the best of both gnome and unity on my Ubuntu.The joy was not going to last longer than a few hours. Gnome had been running butter smooth with all awesome extensions installed. Now, the desktop cube feature on unity was also successfully. To add to my success, the IITD caldav server was synced to my alarm-clock signalling the time for windows uninstall.


But, the MAC was always a plus one with it's multi-touch touchpad. The only thing I wanted was that somehow, touchegg, utouch and synaptiks could be made to run such that the three fingers drag can show MAC that ubuntu can do it with three fingers what MAC does with four.


Step one : Re-install all three required software.
Result : No change, no new applications created in applications folder.

Step two : Remove touchegg and utouch.
Observation : touch egg removed easily, utouch has got a lot of files and installations, so       perhaps utouch* will do the job
Action : sudo apt-get remove utouch*
Observation : blah.. blah.. unable to get lock.. blah.. blah
Action : sudo apt-get purge utouch*
Result : ****Doom***

In what number system will 14 X 2 be 92?


So, my friend just said referring to an old calculator that it gives 14 * 2 as 92. It was meant to be just an example, but the equation raised a question in my mind whether in any number system will the equation hold good. So, I did some paper-work and found some interesting results while searching for the required number system.
The first point is to note that if the base is greater than 10, the number shall be less than 28 and if greater than 10, it shall greater than 10. While any system lower than 10 won’t allow for the digit 9. So the given equation can’t be correct anywhere.
LHS is 14 * 2, so the system has to be greater than the 4-base, for the digit 4 to occur. Let’s check out 5-base, here 14 * 2 is 33. Yes, now it becomes very clear that the equation is not valid in any system. You see that in the highest value among the possible number systems is 33. So, any possibility for numbers greater than 33 is not possible for 14*2.
Now,
  • In 5-base system :           14*2=33
  • In 6-base system :           14*2=32
  • In 7-base system :           14*2=31
  • In 8-base system :           14*2=30
  • In 9-base system :           14*2=28
  • In decimal system :         14*2=28
  • In 11-base system :         14*2=28
  • In 12-base system :         14*2=28
  • In 13-base system :         14*2=28
  • In 14-base system :         14*2=28

The most interesting fact is that for all systems greater than 8, the equation holds good. So, we have a new question, why only after 8?
Keep thinking!!

Tuesday, December 21, 2010

Here are some ways of viewing pdf files online......

I use internet on mobile (nokia 2760, phone with small heap size of 600kb) and one of my greatest problems used to be the adobe pdf files which most of the mobile browsers can't open. I have been trying to search solution of this and here ishttp://www.blogger.com/img/blank.gif the result.
I have found 12 different ways of opening pdf files. Most of these require you to either enter the url of the file in a given text box and 'go' or upload from local media.
The following has both options:

1)adobe access

http://access.adobe.com/
Here comes some help from the creaters of pdf. Adobe provides online conversion tool to view online or local pdf files as text or html. You just need to fill up a small form. On mobile, you might need to refresh if a 'converting' message comes . It works only for pdf.

2)SAMURAJdata.se
http://view.SAMURAJdata.se
This is one of the most recommended tool. It opens .pdf and .ps as browsable images while opens .doc files as html pages. It works great on both mobile and computer.

3)pdfescape

http://pdfescape.com
Perhaps the best on computer. This online tool gives you option of maintaining an account and retrieving files from anywhere. Doesn't works on mobile(atleast not on mine). Perhaps, uses flash viewer.

4)ZOHO viewer

http://viewer.zoho.com
It can maintain a given address for as long as you wish so that you may return to same address to view the file again or you may give the address to friends or on blogs. It can also show other file formats such as .doc, .xls, .ppt, .ps and even open office files.


Now, let's have a look at some of the online tools which works only upon an online pdf that is a xyz.pdf that has a url(http://......../xyz.pdf)

1)google docs

http://docs.google.com/viewer

This certainly qualifies to be the best in this category. It can show almost all file formats and is the most popular. It converts all pdf into images that gives problem for slow connections when the large image loads very slowly. (in very small ram mobile..... I was not able to use it until I found opera mini 4 beta version.)

2)Google cached

This can be of use only in case of pdf files indexed by google. Google has a snapshot of many webpages and online documents such as .pdf, .xls and .doc files. To open cached version of a document, simply type this inLink the google search box-- "cache:http://.......
./xyz.pdf"
In case of mobile, you need to go to the classic or the desktop version of google. Mobile version doesn't supports the "cache:" operater.

3)NITROpdf

http://www.pdfdownload.org/online-pdf-viewer.aspx
It only works on pdf files and can't do anything about .doc, .ppt, .xls files. However, it has an advantage of refering the user to the google cached version of the file. Even if you type in a .doc file address, it will just refer you to google alongwith an error message. If you are using mobile, then its preferable to use a better front end at http://serola.info/test/pdfconvert.htm

The following two are only for mobile:

4)uc web


to download go to http://wap.uc.cn/en
this chinese browser comes with an online support for converting .pdf, .doc and .xls files. However, the page rendering is not satisfactory in complex .pdf files.

5)google web transcoder

To use, go to http://www.google.com/gwt/x?u=url_of_the_pdf
This is the tool which i mostly use. The pdf need not be indexed but it should be present on the net. Moreover, u can easily do your browsing only on gwt pages(if u have to only read and not enter values in text boxes). It also easily transcodes other common file formats.

Viewing pdf from local media. Here you can upload your pdf and view it.

I will recommend to try the tools mentioned in the first category instead of the following two...

1)viewdocsonline
http://www.viewdocsonline.com

It can show more file format as compared to pdfonline.com

2)pdfonline
http://www.pdfonline.com/sides/comments.htm


Something for mobile users:

3)gmail
Use gmail for viewing those pdf files that is with you on your mobile. Send an email to yourself with the pdf file attached. (The pdf might not be readable on your mobile but it still is a pdf and just need the right software for its decoding). You can use the email feature if available in your messaging menu for sending attached emails. Now, use your local browser for opening gmail on your mobile. You will be able to read the pdf as html.

Wednesday, October 6, 2010

A Humble Start

It has been almost three months since I created this blog. However it still posed a bare look with "NO POST." sign disappointing anyone who opened this site(i hardly think anybody have reached this place other than i myself..and it did disappointed me a lot).

Therefore, now i think i must fill this up with something.....yes just anything and i started this--rather boring stuff.

well..for my short introduction, i am a student at IIT Delhi doing B.Tech in kam'akal(read chemical)engineering.

thanks for giving ur precious time to this.