sqldump

(coffee) => code

List All Folders in Descending Order of Size

Fancy du trick to list all folders in the current folder in descending order of size of content with human readable folder-sizes.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
du -k -d 1 | sort -nr | awk ''
     BEGIN {
        split("KB,MB,GB,TB", Units, ",");
     }
     {
        u = 1;
        while ($1 >= 1024) {
           $1 = $1 / 1024;
           u += 1
        }
        $1 = sprintf("%.1f %s", $1, Units[u]);
        print $0;
     }
    ''

The Decline of MySQL

daleV, of Geek Gumbo, presents an interesting take on the impending decline of MySQL.

Look for Oracle not to drop it’s Open Source version after 2015. It will keep a stripped down version available to entice new users to their revenue stream when they need to upgrade, and to claim they still support the Open Source community. The prices for MySQL will steadily climb. This will kill MySQL as the database of choice for web development. Look for MySQL to decline in use.

Ever climbing license costs, “paid-only” versions of MySQL Workbench and other tools along with the lack of “Basic” and “Silver” level support pretty much sums up the basis for the prediction. He ends with the following nugget:

This reminds me of the old quote, first uttered in 1422 at the coronation of French King Charles VII, after the death of his father, Charles VI, “The King is dead. Long live the King.” Just maybe we’re a bit premature, but we see it coming.

Simple logRotate Script for MongoDB

logRotate.js

1
db.getMongo().getDB("admin").runCommand("logRotate")

logRotate.sh

1
2
3
4
5
#!/bin/sh
# Clear old logs
rm /data/logs/mongod.log.*
# Rotate logs
mongo logRotate.js

Making OS X’s Preview and Quicktime Less Annoying

Product discussion at Apple:

“Guys, we need 250 new features for the next release. What do you have for me?”

“Here’s something: let’s open up ALL the files from the user’s previous session when the user decides to launch apps like Preview or Quicktime”

“Why Bob, that’s a brilliant idea!”

“Improving on what Bob said, let’s NOT give them the option to turn this behaviour off!”

“Alright, let’s make it happen. 1 down, 249 to go.”

Run the following in your Terminal to prevent Preview (and/or Quicktime) from opening up all the windows from your previous session:

1
2
3
4
defaults write com.apple.Preview \
NSQuitAlwaysKeepsWindows -bool false
defaults write com.apple.QuickTimePlayerX \
NSQuitAlwaysKeepsWindows -bool false

Getting Rid of Chrome’s “Flash Plug-in Out of Date” Message on Ubuntu 12.04

Type about:plugins in the address bar and click Details on the top right corner.

Under Flash, look at all the libflashplayer.so files in use.

Disable all except the actual chrome plugin listed under /opt/google/chrome/plugins.

Check the version number of the Chrome flashplayer and update as necessary by downloading the latest package from adobe.com.

Delete All Keys in Redis

The fun way:

1
redis-cli KEYS ‘*’ | awk ‘{print $1}’ | xargs redis-cli DEL

The recommended way:

1
redis-cli FLUSHALL

Ubuntu 11.04 - Stuttering Stinkbug

I’ve been living with an annoying bug in Ubuntu on my ThinkPad for quite a while now. If I recall correctly, it started off in Ubuntu 9.10 and has continued through to 11.04 as well. The main effect of this bug causes the mouse to stutter, even when the system is idle. This bug reported on launchpad describes the stuttering as a result of kslowd spawning multiple instances and pegging CPU time. This bug was prevalent throughout 2.6.35-* versions of the Ubuntu kernels.

In the 2.6.36-* variation, kslowd was renamed to kworker and contrary to what others have reported, in my experience, the problem worsened. No fix was in sight yet.

Even in today’s latest 2.6.38-* series, many users have reported kworker processes pegging enormous amounts of CPU time, rendering the system useless for a few seconds ever so often.

A fix that worked for me involves disabling the poll parameter of the drm_kms_helper kernel module. You can try out the fix by executing (as root, of course)

1
echo N > /sys/module/drm_kms_helper/parameters/poll

If it works out well, you can make the fix permanent by adding the following line to your /etc/modprobe.d/local.conf

1
options drm_kms_helper poll=N

Good luck!

Mod_python on Amazon Linux

It takes a few commands to get mod_python with Apache up and running on the free tier Amazon Linux AMI of EC2.

Step 1
Install Apache and mod_python using

1
yum install httpd mod_python

Step 2
Add python handlers by adding the following lines to /etc/httpd/conf.d/python.conf

1
2
3
4
5
6
7
8
9
10
11
LoadModule python_module modules/mod_python.so

<Directory "/var/www/html">
  Options Indexes FollowSymlinks MultiViews
  AllowOverride None
  Order allow,deny
  allow from all
  AddHandler mod_python .py
  PythonHandler mod_python.publisher
  PythonDebug On
</Directory>

Step 3
Add a script to serve by creating a file /var/www/html/my.py and add the following code to it:

1
2
def index(req):
    return "Hello World!"

Access the file using http://my-ec2-address/my.py (make sure port 80 is open on the EC2-firewall)