[HowTo] Save all flash video files being played in Chrome/Chromium to Home directory

After watching a video on youtube in chrome, I felt like saving it. I couldn’t find the flv in ~/.cache or in /tmp. So I dug around and found this link: http://superuser.com/questions/235535/in-google-chrome-on-linux-where-is-the-flv-if-not-in-tmp.

The solution by omab worked for me. So I wrote this one line command which would save all the currently playing files in Chrome and Chromium in home directory.

A=`ps auwx | grep "flash" | grep "chrom" | awk '{print $2}'`; ls -la /proc/$A/fd | grep Flash | awk '{print $8}' | xargs -I _ mplayer /proc/$A/fd/_  -dumpstream -dumpfile ~/_.flv

Leave your thoughts in the comments!


[HowTo] Install Firefox 4 on Ubuntu using PPA

Firefox 4 which was released yesterday has been downloaded over 6 million times in just 24 hours. It features faster application startup, faster javascript engine, full HTML5 and CSS3 compliance etc.


What’s New in Firefox 4:

Fastest Firefox Ever

  • Performance: Firefox is up to six times faster than the previous release. With improved start-up and page load times, speedy Web app performance and hardware accelerated graphics, Firefox is optimized for rich, interactive websites.

Streamlined Interface

  • App Tabs: give a permanent home to frequently visited sites like Web mail, Twitter, Pandora, Flickr.
  • Switch to Tab: easily find and switch to any open tab from your Awesome Bar without opening duplicate tabs.
  • Panorama: drag and drop tabs into manageable groups to save time while navigating many open tabs.

Private and Secure Synchronization

  • Firefox Sync: access your Awesome Bar history, bookmarks, open tabs, passwords and form data across multiple computers and mobile devices.

Most Customizable

Private and Secure

  • Do Not Track: Firefox is leading the Web towards a universal standard Do Not Track feature that allows users to opt-out of tracking used for behavioral advertising.
  • Firefox puts privacy first, fixing flaws in some Web standards to prevent others from accessing your browser history.
  • HTTP Strict Transport Security (HSTS): automatically establishes secure connections to stop “man in the middle” attacks and keep sensitive data safe from interception during the log-in process.
  • Content Security Policy (CSP): prevent cross-scripting attacks by allowing sites to explicitly tell the browser which content is legitimate.

Cutting Edge Tools for Web Developers:

  • The JavaScript engine incorporates the new JägerMonkey JIT compiler, along with enhancements to the existing TraceMonkey JIT and SpiderMonkey’s interpreter for faster page-load speed and better performance of Web apps and games.
  • HTML5 support in Firefox includes hardware accelerated, high-definition video (WebM), 3D graphics, offline data storage, professional typography, touchscreen interfaces and the Mozilla Audio API to help create visual experiences for sound and more.
  • Firefox 4 also improves existing tools like CSS, Canvas and SVG to enable developers to make exciting Web pages.
  • Firefox provides uninterrupted browsing when there is a crash in the Adobe Flash, Apple QuickTime or Microsoft Silverlight plugins. If one of these plugins crashes or freezes, it won’t affect the rest of Firefox. Simply reload the page to restart the plugin.


Read the full blog entry from mozilla.

Install it on Ubuntu using PPA:

sudo add-apt-repository ppa:mozillateam/firefox-stable
sudo apt-get update
sudo apt-get install firefox


[SOLVED] ‘Unknown’ filesystem in gparted

I had a primary NTFS partition with windows 7 installed on it. Somehow, its bootloader went corrupt so I used install-mbr in ubuntu to fix that but it only made the problem worse. Now my system didn’t recognise the partition as NTFS partition and I couldn’t access the partition.

I modified the partition ID using fdisk but that didn’t work. Fdisk recognised it as NTFS but gparted didn’t, nor did Ubuntu. To fix it, I followed the following steps:


      • Download


      •  and extract the files to a folder. The files are compiled executable files so there is no need for any installation. I extracted it in a folder named testdisk on my home directory. Ubuntu users can install it using

    sudo apt-get install testdisk

    cd ~/testdisk/linux
      • Execute the testdisk:
    sudo ./testdisk_static
      Select [Create] and press enter. On the resulting screen, select your harddrive using cursor keys and press enter. On the next screen select the partition table type. It’d generally be Intel if you are using a PC and Mac if you are on Mac. Select the correct one and press enter.
      Now you’ll be presented with lots of options. Use cursor keys to select Advanced and press enter. Select the partition which shows unknown type. Use left and right arrow keys to select [Type] and press enter. You’ll see the list of partition types. In the list the HPFS/NTFS has partition id 07. Press enter, type 7 for NTFS or another partition ID corresponding to your partition type. Press enter.
      Now use the right arrow key to select the [Boot] and press enter. Use right arrow key to select [Rebuild BS] and press enter. Select [Write] and press enter. Now type y. The partition should be fixed by now. You can now quit the testdisk
      • Refresh partition list
    sudo partprobe


The disk should be accessible again now


[HowTo] Add expires headers to cache static files using htaccess

Caching is one of the most important things to keep in mind when you are developing a website which is expected to get large amount of visitors. Most web developers neglect caching, some even don’t know correct ways to implement it.

In this tutorial, I’ll show you how to enable browser cache of static files simply using htaccess file. Basically server adds the Expires header to file-type you specify. Expires header will make sure the browser stores the file locally and use the same file until the time mentioned in expires header has passed.

Before we move ahead, please make sure apache’s mod_expires is loaded. You can check it using phpinfo() under ‘Loaded Modules’ section. If you don’t find it there, you can see this tutorial to enable mod_expires.

Copy the following code and paste it into .htaccess file in your website’s root directory.

# Turn on the Expires engine
ExpiresActive On
# Expires after a month client accesses the file
ExpiresByType image/jpeg A2592000
ExpiresByType image/gif A2592000
ExpiresByType image/png A2592000
ExpiresByType image/x-icon A2592000
ExpiresByType text/plain A2592000
# Good for one week
ExpiresByType application/x-javascript M604800
ExpiresByType text/css M604800
ExpiresByType text/html M604800


ExpiresActive On turns on the expires engine. ExpiresByType image/jpeg tells server to check if MIME-type of file is image/jpeg. If yes, set the expires header.

‘A’ in A2592000 stands for ‘Access’ and it means set the expires header for 2592000 seconds (1 month) after the user has accessed the file. ‘M’ stands for ‘Modified’. M2592000 would mean ‘set expire date to one month after the file has been modified’.

Images are not likely to change even in years. Hence, you can set several months of expiry time in that. Whereas, css and javascript are likely to be modified. Therefore, we put a week’s expire header in css, javascript and html files.

Check out the official documentation to read more about the mod_expires module.

Some people would argue that explicitly setting ‘expires’ header is not a good idea as it would override the default caching mechanism of the browser. But the fact is that browsers use ‘ETag’ header to cache the data. They would still request the server to see if the content has changed by matching the ETag of the local cached copy of the data and server’s copy. If the Etags are different, it would know the data has been changed and would download the new data. But this mechanism still requires the browser to send request for each object to check if a newer one is available adding fractions of second of lag for each request. Server has to still serve the response. This makes this method comparitively inefficient.

On the other hand, explicitly setting expire would make the browser not to send request until expire date has passed which means very few requests are made. Hence, very fast page loading.

Thus, using this file is advisable as it would make your website load faster on the viewers computer and would ease the burden on your server too.

Comments and suggestions are more than welcome.


[SOLVED] Error ‘dpkg: error processing (–unpack) trying to overwrite…

Recently I got this error after installing VLC on Ubuntu 10.10 Maverick Meerkat. Not really remembering what caused the error to be triggered in the first place, it became very difficult to find a solution for it.
When I executed sudo apt-get upgrade to upgrade my packages, it told me there was some issues and I needed to execute sudo apt-get -f install to fix them. I did as advised but it produced the following error:

Reading package lists… Done
Building dependency tree
Reading state information… Done
Correcting dependencies… Done
The following extra packages will be installed:
vlc vlc-nox
Suggested packages:
mozilla-plugin-vlc videolan-doc
The following packages will be upgraded:
vlc vlc-nox
2 upgraded, 0 newly installed, 0 to remove and 198 not upgraded.
66 not fully installed or removed.
Need to get 0B/5,258kB of archives.
After this operation, 229kB of additional disk space will be used.
Do you want to continue [Y/n]? y
WARNING: The following packages cannot be authenticated!
vlc vlc-nox
Install these packages without verification [y/N]? y
(Reading database … 206759 files and directories currently installed.)
Preparing to replace vlc 1.1.0-1~ppa1~maverick (using …/vlc_1.1.0-1ubuntu1_i386.deb) …
Unpacking replacement vlc …
dpkg: error processing /var/cache/apt/archives/vlc_1.1.0-1ubuntu1_i386.deb (–unpack):
trying to overwrite ‘/usr/lib/vlc/plugins/access/libxcb_screen_plugin.so’, which is also in package vlc-nox 1.1.0-1~ppa1~maverick
dpkg-deb: subprocess paste killed by signal (Broken pipe)
Preparing to replace vlc-nox 1.1.0-1~ppa1~maverick (using …/vlc-nox_1.1.0-1ubuntu1_i386.deb) …
Unpacking replacement vlc-nox …
dpkg: error processing /var/cache/apt/archives/vlc-nox_1.1.0-1ubuntu1_i386.deb (–unpack):
trying to overwrite ‘/usr/lib/vlc/lua/playlist/anevia_streams.luac’, which is also in package vlc 1.1.0-1~ppa1~maverick
dpkg-deb: subprocess paste killed by signal (Broken pipe)
Errors were encountered while processing:
E: Sub-process /usr/bin/dpkg returned an error code (1)

After some time of googling and head-scratching, I finally found a solution and it wasn’t that difficult either.
To fix it just note down the path of files which are causing the trouble. From the above mentioned error, we can clearly see that there are these two files causing the error:


You just forcefully overwrite them using the following command:

sudo dpkg -i --force-overwrite <filename>
sudo apt-get -f install

For the above two files you’d execute:

sudo dpkg -i --force-overwrite /var/cache/apt/archives/vlc_1.1.0-1ubuntu1_i386.deb
sudo dpkg -i --force-overwrite /var/cache/apt/archives/vlc-nox_1.1.0-1ubuntu1_i386.deb
sudo apt-get -f install

This fixed the error for me and I hope this fixes it for you too.


[HOW-TO] Converting case in MySQL

I had been wondering this for few days. I wanted a solution which could comvert first letter of text in some fields to uppercase and the rest to lower. I got time today and experimented a bit and found a very simple solution.

CREATE TABLE  `temp_users` (
`fname` VARCHAR( 50 ) NOT NULL
`email` VARCHAR( 250 ) NOT NULL

Query above makes a temporary table ‘temp_users’ to store the updated data.

INSERT INTO `temp_users`
SELECT CONCAT( UPPER( SUBSTRING( fname, 1, 1 ) ) , LOWER( SUBSTRING( fname, 2 ) ) ) , email
FROM `users`

This query selects the data from the current table, converts the case and inserts into our temporary table ‘temp_users’.

The converted data has now been been stored into a temporary table. Now you can drop the table ‘users’ and rename ‘temp_users’ to ‘users’.

DROP TABLE `users`;
RENAME TABLE `temp_users` TO `users` ;

And that is all.


[HowTo] Optimize Mozilla Firefox for better performance

Firefox is getting very popular lately, mainly due to its customizability. I use firefox as my main browser and use all sorts of addons which help me in web-development. These addons make my firefox hungry but I can’t do without them. So, instead I tweaked around some settings in firefox which made it much responsive and faster than before.

To tweak those settings, follow the following steps:

1. Type about:config in your address bar and hit enter.

2. In the filter type browser.session
3. Modify browser.sessionhistory.max_entries by double clicking it. This setting sets the number of steps you can go forward or backward on a page. Default is 50 which is just too much. 20 will be more than sufficient for most people.

4. Modify browser.sessionstore.interval by double clicking it. This setting specifies the rate of saving current session. The default is 10000 milliseconds which means that every ten seconds your sessions are stored. So, when your browser crashes you will, at most, lose only tabs since last nine seconds prior to crash. Change it to 30000 or 20000, whatever suits you. 10000 is definitely not required by most of the people.

5. Modify browser.sessionstore.max_tabs_undo. This setting stores the number of tabs you can undo-close by pressing ctrl-shift-t. Default has been set to 10. I set it to 5 which is more than sufficient for me.

6. Modify browser.sessionhistory.max_total_viewers. This setting can vastly improve the performance. It specifies the number of pages to store in memory. When you press back/forward in a browser, pages are instantly displayed. This is because those pages have been stored in the memory and this setting specifies how many pages should be stored. By default, its -1 which means it depends upon the amount of ram. I have 2 GB and I set this setting to 4.

7. Modify network.prefetch-next. This setting specifies if the prefetching should be enabled or not. Prefetching is when a site tells the browser to download a link (which is most likely to be visited) beforehand only. It is useless and only takes up extra bandwidth and memory. Set the value to false.

Lastly, you can try to change some settings yourself and see the results. You can check the mozillazine knowledgebase to know what a particular setting does. For example, for network.prefetch-next you can check out the setting details at http://kb.mozillazine.org/Network.prefetch-next. Similarly, for other settings.

Some more tricks to free up memory usage of firefox:

1. The awesome bar (address/location bar), as you must be knowing is really amazing feature but it may lead to slowdowns if history is too large. Go to Preferences->Privacy, and in ‘Remember my browsing history for atleast’, put minimum history that you ever require. Mine is 30, since I don’t need more than that and putting a less value always speeds up things. In the same dialog box, In ‘When using the location bar, suggest:’ , try an use only one option if you don’t require both. This will further reduce the address bar lag.

2. Remove useless plugins/extensions: Periodically check the list of your extensions and disable those which you haven’t used since a long time. Extensions are the main cause of Firefox’s slowdown.

3. Use a blank pages as your home page. This makes firefox startup a bit faster.

4. Try and use default theme as themes eat up way too much memory. It delays the startup very significantly.

5. Flash is one of the reasons why Firefox eats so much amount of memory. It has been known that memory taken by a flash animation isn’t freed even after closing that tab. They said they improved this memory leak from Firefox v3 onwards but I don’t see much of a difference. The solution is you can replace all your flash animations with a play button using flashblock extensionsand just click the play button to play the required flash animations.
This way you control which flash files are being played, thereby reducing the amount of memory taken.

These settings will definitely make your Firefox blazing fast. Try and implement all of them and see the difference.


[HowTo] Remove admin bar from wordpress 3.1

The new admin bar in wordpress 3.1 is one good feature to have but sometimes its unwanted. For example you might already have some other kind of top bar with which admin bar may interfere. You can remove the admin bar by putting the following code in /wp-content/YOURTHEME/functions.php:


Undo recent facebook style changes

Recently facebook made its font smaller. It worried lots of people with weaker eye sight. The font looks ugly as well. They reduced it all the way to 11px from 13px. And changed its color to #000 from #333. I made a quick greasemonkey script as it works cross-browser to fix the issue until facebook does something about it.

You can install the script from the following link:

Google Chrome: Chrome doesn’t need any extension for this to work. It’ll install the script right away.
Firefox: You need to install greasemonkey extension from https://addons.mozilla.org/en-US/firefox/addon/748/

Opera: It has its own Userjs API. This script might work on Opera. However, it has not yet been tested.

I don’t recommend using any version of IE, hence no instructions for that.

[HowTo] Use locate command and updatedb to search all partitions

Updatedb command by default does not include /media path for updating its database. You can change the settings in /etc/updatedb.conf so that it starts indexing other partitions too.

sudo gedit /etc/updatedb.conf

In the PRUNEPATHS setting, remove /media. Save the file and run

sudo updatedb

This will index all your files from /media folder. Make sure the partitions are mounted.