Absolutely Tech

[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!

Cheers!

[HowTo] Extend phpmyadmin session expiration time

Recently, I got frustrated being logged out every few minutes (24 minutes, to be precise) from phpmyadmin on my localhost. I make some db changes, write some code and when I get back to phpmyadmin, I would see my session had expired. To fix this, I changed the configuration so that my session would expire only after 24 hours of inactivity.

Steps to follow:

  • Copy the following code at the end of /etc/phpmyadmin/config.inc.php:
    $cfg['LoginCookieValidity'] = 60*60*24;
    ini_set('session.gc_maxlifetime', $cfg['LoginCookieValidity']);

This will let your session expire only after 60*60*24 seconds, that is one day.

Cheers!

[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

Cheers!

[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:

if(function_exists('show_admin_bar')){
	show_admin_bar(false);
}

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:
http://userscripts.org/scripts/show/89552

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.

Cheers!

[Solved] Mp3 not playing on Amarok

After upgrading to Maverick, somehow Amarok stopped playing Mp3. Same thing happened when I upgraded to Lucid from Karmic.

To fix it, install libxine1-all-plugins:

sudo apt-get install libxine1-all-plugins

That fixed it for me!

Cheers!

[HowTo] Suspend Ubuntu from terminal or keyboard shortcuts

When learning to make bash scripts, at one point or other you’d like to know how to suspend your computer from terminal. Well, there are quite some methods available for Ubuntu. You can choose whatever suits your needs. I prefer method 3 (look below).

Method 1:

sudo sh /etc/acpi/sleep.sh force

Method 2:

sudo pm-suspend

This command might not be available in older versions of Ubuntu. It works perfectly fine on Lucid and Maverick.

Method 3:

This command does not require sudo so it might come in handy. For example, you can map it to a keyboard shortcut for easy access.

dbus-send --print-reply --system --dest=org.freedesktop.UPower /org/freedesktop/UPower org.freedesktop.UPower.Suspend

One thing to notice here is none of the commands I mentioned here will ask your password on resuming. For that you’ll have to lock your computer before suspending. You’ll have to use gnome-screensaver-command --lock before suspending to lock the computer

Create a suspend script:

Open a new file in gedit:

sudo gedit /usr/bin/suspend-comp

Copy and paste the following code and save it:

#!/bin/sh 
sleep $1;
dbus-send --print-reply --system --dest=org.freedesktop.UPower /org/freedesktop/UPower org.freedesktop.UPower.Suspend

If you want the script to ask for a password on resuming, copy-paste this code instead:

#!/bin/sh 
sleep $1;
gnome-screensaver-command --lock
dbus-send --print-reply --system --dest=org.freedesktop.UPower /org/freedesktop/UPower org.freedesktop.UPower.Suspend

Add the executable bit:

sudo chmod +x /usr/bin/suspend-comp

Now suspend-comp time-in-seconds can be used in terminal. For example, if I want to have my computer suspended after 20 seconds I can simply type:

suspend-comp 20

Mapping it to keyboard shortcut for easy access:

Go to System->Preferences->Keyboard Shortcuts. Click Add. Type Suspend for Name and suspend-comp 0 in Command field. Click Apply.

Now scroll to the bottom of the list to find Suspend. Click on ‘Disabled’ on the right to ‘Suspend’. Now press any key combination to map the command to it. I used Ctrl+Alt+Shift+s.

Now simply pressing Ctrl+Alt+Shift+s will suspend your computer.

Cheers!

[HowTo] Find number of files inside a folder in Linux

I wanted to find out the number of files inside a folder. I didn’t want the folders to be included in the result.
A blog post on zimbio.com shows us how to do it with ls command which is not only downright inaccurate, it is also slower than what I am going to show you.
I am going to show you how to do it using find command which is extremely powerful once you know how to use it.
Executing the command below will print the number of files (excluding folders) in current directory (including all subdirectories):

find ./ -type f | wc -l

This can be used to find number of directories too:

find ./ -type d | wc -l

You can do more complex counting for example finding out the number of files which are of filesize 1Mb and more.

find ./ -type f -size +1M | wc -l

Finding number of symlinks:

find ./ -type l | wc -l

You can also see number of files accessed within last 1 hour from current directory:

find ./ -type f -amin -60 | wc -l

Here -60 means less than 60 minutes ago.

Only imagination is the limit with what you can achieve using find command.

[HowTo] Open thumbs.db and extract thumbnails from it

Thumbs.db is a file used to store thumbnail data of a folder in Windows. It makes loading of thumbnails significantly faster, however it has some privacy issues. Like if you delete an image, its thumbnail might still be there in thumbs.db file which would allow you to view it.

There’s an open source python script called Vinetto available to extract all the thumbnails in open.db to a folder. It works on Linux, Windows and Mac OS. You can download the script from here.

On Ubuntu, you can use apt-get to install vinetto:

sudo apt-get install vinetto

To extract thumbnails:

vinetto -o ./thumbnails ./thumbs.db

This will extract all the thumbnails inside thumbs.db to thumbnails folder.

Cheers!