Archive for April, 2010

HTML5 Presentation

Saturday, April 17th, 2010

This presentation will blow you mind how powerful HTML5 is/will be.
Some of the new things are:
New form inputs
Canvas
Audio
Video
Drag ‘n’ Drop
Client side storage
Geolocation and much more!

Check unread Gmails from Terminal

Wednesday, April 14th, 2010

I made this python script for my conky config to view the number of unread emails from my Gmail account.
It uses cURL. If you don’t have it and are running a Debian based distro, just do:

sudo apt-get install curl

The program:

import subprocess
import re

username = 'username'
password = 'password'

def getInfo(username, password):
    cmd = ['curl', 'https://' + username + ':' + password + '@mail.google.com/mail/feed/atom']
    return subprocess.Popen(cmd, stdout=subprocess.PIPE).stdout.read()

def parseInfo(data):
    m = re.search('<fullcount>(\d*)<\/fullcount>', data)
    if m:
        return m.group(1) + ' new'

print parseInfo(getInfo(username, password))

Vim Config Tips

Monday, April 5th, 2010

Vim logo
One thing I love about vim is that it is extreme configurable. I have put together this config with comments for explenation. Be sure to know what thing does before using them.
Just leave a comment of you think I have forgotten something.

"Enable syntax highlighting and select color scheme:
syntax on | colorscheme wombat256

"Enable 256 colors:
set t_Co=256

"If you have the problem that most of the text gets bold, this works. But nothing gets bold after this:
set t_md=

"Enable auto-Indent:
set autoindent smartindent

"Enable line numbering:
set nu

"Enable mouse:
set mouse=a

"Enable unicode:
set encoding=utf8

"Enable incremental search:
set incsearch

"Replace tab with 4 spaces:
set tabstop=4 softtabstop=4 shiftwidth=4 expandtab

"So you get all error messages at once and just have to click enter one time:
set nomore

"Match parens and braces:
set showmatch

"Makes search case insensitive:
set smartcase ignorecase

"Highlight the line you are at:
"set cursorline

"Remove toolbar (waste of space):
set go-=T

"Enable statusline (also waste of space, but it might be handy):
set ls=2

"Show changes commands make:
set report=1

"Highlights what you search for:
set hlsearch

"Shows whitespaces and tabs:
set list listchars=tab:\|\ ,trail:· "

"You don't lose selection when you indent selected code:
noremap < <gv | vnoremap > >gv

"Check php files for syntax errors:
noremap <C-B> :!php -l %<CR>

"Bind ALT+1 and ALT+2 for moving through tabs:
nmap <A-1> :tabprevious<CR>
map <ESC>1 :tabprevious<CR>
map <A-2> :tabnext<CR>

nmap <ESC>2 :tabnext<CR>
nmap ,t :tabnew<CR>
map ,T :tabclose<CR>

"Screen redraw also clears highlights:
nnoremap <silent> <C-L> :nohls<CR><C-L>

Aptitude Easter Egg

Sunday, April 4th, 2010

Probably old news, but if you didn’t knew here’s a little cool thing in Aptitude :)

echofish@ubuntu:~$ aptitude moo
There are no Easter Eggs in this program.
echofish@ubuntu:~$ aptitude -v moo
There really are no Easter Eggs in this program.
echofish@ubuntu:~$ aptitude -vv moo
Didn't I already tell you that there are no Easter Eggs in this program?
echofish@ubuntu:~$ aptitude -vvv moo
Stop it!
echofish@ubuntu:~$ aptitude -vvvv moo
Okay, okay, if I give you an Easter Egg, will you go away?
echofish@ubuntu:~$ aptitude -vvvvv moo
All right, you win.

                               /----\
                       -------/      \
                      /               \
                     /                |
   -----------------/                  --------\
   ----------------------------------------------
echofish@ubuntu:~$ aptitude -vvvvvv moo
What is it?  It's an elephant being eaten by a snake, of course.