Jojo (my cat)

Dec 05
2008

my cat

Filtering Lists

Dec 01
2008

Ruby

arr = (1..10).to_a
arr.select{ |e| e % 2 != 0 }

Python

arr = range(1,11)
[e for e in arr if e % 2]

Perl

@arr = (1..10);
grep($_ % 2, @arr);

Simple Email Hex Encoding

Nov 18
2008
#!/usr/bin/python
 
import re
 
hex_encode = lambda x: ("&#%i;" * len(x)) % (tuple(map(ord, re.findall('.', x))))
 
# hex_encode("root@example.com") =>;
# root@vidul.com

Store Init Failed – Engine Init() Failed

Nov 15
2008

This nice post describes the fix for Opera email error.
On UNIX/Linux OS you can achieve the same effect with the following command:
pkill -9 opera
Then start Opera and everything should be fine.

Mozart N40

Nov 14
2008

I’m screaming revenge again
Wrong
I’ve been wrong for far too long
Been constantly so frustrated
I’ve moved mountains with less
When I channel my hate to productive
I don’t find it hard to impress

Bones in traction
Hands break to hone raw energy
Bold and disastrous
My ears can’t hear what you say to me

Hold your mouth for the war
Use it for what isn’t for
Speak the truth about me
Determined

Possessed
I feel a conquering will down inside me
Strength
The strength of many to crush
Who might stop me
My strength is in number
And my soul lies in every one
The releasing of anger can better any medicine under the sun

There comes a time within everyone to close your eyes to
what’s real
No comprehension to fail
I vacuum the wind for my sail
Can’t be the rest
Let others waste my time
Owning success is the bottom line.
Like a knife into flesh
After life is to death
Pulling and punching the rest of duration
NO ONE can piss on this determination

The Best Package Manager

Nov 04
2008

Zypper is fast and reliable package manager, and not slow and buggy like APT.

Ultra Tiny Address Book

Oct 29
2008
#!/usr/bin/perl
 
$s = shift;
$"  = "\n";
$/  = $\;
$_  = <data>;
@_ = /(.*?$s.*)/gi;
 
print "@_\n";
 
__DATA__
 
me "some address" my_phone_here
etc...
etc...</data>

Getting Negative Number

Oct 28
2008
positive = 10.01
 
# the negative equivalent: -10.01
 
negative = positive - (positive * 2)
negative = positive * -1 # or
negative = positive / -1
negative = -positive # or 
negative = ---positive

“Beautiful is better than ugly.”

Oct 21
2008

python -c ‘import this’ | head -n3 | tail -n1

Sequence Types and Slice

Oct 21
2008

Ruby slice:

a = [1, 2, 3, 4, 5, 6]
a[0..-1] # [1, 2, 3, 4, 5, 6]
a[(0..-1)] # tha same

Python slice:

a = [1, 2, 3, 4, 5, 6]
a[:-1] # [1, 2, 3, 4, 5]
a[:] # [1, 2, 3, 4, 5, 6]
a[0:len(a):2] # [2, 4, 6]  Nice, isn't it?

Calendar

February 2012
M T W T F S S
« Sep    
 12345
6789101112
13141516171819
20212223242526
272829  

Tags