m3u playlist creator

Following script will look for all .mp3 files in the current directory and create .m3u playlist from them

Script:

#!/bin/sh
 
DIR="./"
SUFFIX="mp3"
FILE_NAME="$1.m3u"
 
echo "#EXTM3U" >> $FILE_NAME
 
for i in "$DIR"/*.$SUFFIX
do
    echo ${i%%} |sed 's#^.*/##' >> $FILE_NAME
done

Command:

sh script.sh FILENAME

Adding SSH Keys

Generate key:

ssh-keygen -t rsa -b 4096
Generating public/private rsa key pair.
Enter file in which to save the key (/home/uzza/.ssh/id_rsa): your_key_name
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in your_key_name.
Your public key has been saved in your_key_name.pub.
The key fingerprint is:
30:c4:21:b3:2d:33:f7:00:f2:7b:24:1b:18:29:2c:31 uzza@Uzza-mint
The key's randomart image is:
+--[ RSA 4096]----+
|E.o.+.o.         |
|oo.= B.          |
|... O B          |
|     @ =         |
|    o . S        |
|     .           |
|                 |
|                 |
|                 |
+-----------------+

Set permissions to the .ssh folder on the server

chmod 700 ~/.ssh
chmod 600 ~/.ssh/*

Copy key on the server:

ssh-copy-id login.domain.com

New row will be added to the ~/.ssh/authorized_keys

Login to the server without specifying password:

ssh login.domain.com

Guake console shortcut fix

There is a problem with binding CTRL as a shortcut in Guake console. Following code solves this problem:

Getting current shortcut:

gconftool-2 -g /apps/guake/keybindings/global/show_hide

Setting new one:

gconftool-2 -t string -s /apps/guake/keybindings/global/show_hide "<Control>less"

Getting size and position of the scaled element

var el = document.getElementById("main_menu");
var details = el.getBoundingClientRect();

Futher reading:
http://ejohn.org/blog/getboundingclientrect-is-awesome/

Making merging easier

Open your .profile file (on linux is .bashrc):

mate ~/.profile

Add following line:

export trunk="https://svn.server.com/repo_name/trunk"

And use $trunk with merge command:

svn merge -c 3435 $trunk

ACK – search for pattern in files

http://betterthangrep.com/documentation/

Example:

ack -i main_menu data/js/game/

How to disable mignifying glass on ipad

body {
  -webkit-touch-callout: none;
}

Javascript Books

Blog Post:
https://plus.google.com/115133653231679625609/posts/H3onog42Msj?utm_source=javascriptweekly&utm_medium=email

===========

http://shop.oreilly.com/product/9780596805531.do

http://www.amazon.de/Effective-JavaScript-Specific-Software-Development/dp/0321812182/ref=sr_1_2?ie=UTF8&qid=1356887062&sr=8-2

https://leanpub.com/oopinjavascript

http://www.amazon.com/Past-Present-Future-JavaScript-ebook/dp/B008MYLN3Y

http://shop.oreilly.com/product/0636920018421.do

http://www.amazon.com/gp/product/1593272820?ie=UTF8&tag=marijhaver-20&linkCode=as2&camp=1789&creative=9325&creativeASIN=1593272820

Mixin ECMAScript 5 compatible

There is a small difference between ECMAScript 3 and 5 described here:
http://www.nczonline.net/blog/2012/12/11/are-your-mixins-ecmascript-5-compatible/?utm_source=javascriptweekly&utm_medium=email

Solution:

function mixin(receiver, supplier) {
    if (Object.keys) {
        Object.keys(supplier).forEach(function(property) {
            Object.defineProperty(
               receiver,
               property,
               Object.getOwnPropertyDescriptor(supplier, property)
            );
        });
    } else {
        for (var property in supplier) {
            if (supplier.hasOwnProperty(property)) {
                receiver[property] = supplier[property];
            }
        }
    }
}

Do you really want to leave this page ? – Confirmation popup window

window.onbeforeunload = function(){
    return 'Do you want to leave without saving changes';
}