Just use this command:
# ssh -f -L local_port:remote_host:remote_port user@remote_host -N
Czerwiec 28th, 2010 — Linux
Just use this command:
# ssh -f -L local_port:remote_host:remote_port user@remote_host -N
Listopad 17th, 2009 — JavaScript
Two days ago I had a problem with Ajax.Autocompleter (from script.aculo.us library). I needed to use dynamically parameters sending in request to the server. Basically they are created only statically when class is set up. To change this behaviour use this solution:
new Ajax.Autocompleter(
'search',
'autocomplete_choices',
'index.php?controller=search&action=autocomplete, {
paramName: 'name',
callback: function(element, entry) {
return entry+"&"+Form.Element.serialize('type');
}
}
);
Listopad 6th, 2009 — PHP
Sometimes I have to capitalize words in my pages. The problem is these words are encoded in UTF-8. Simple solution to resolve it:
$word = 'kędzierzyn-koźle'; $word = mb_convert_case($word, MB_CASE_TITLE, 'UTF-8');
Listopad 3rd, 2009 — Mac OS X, OS
I had a problem with moving forward and backward by word (like CTRL+left, CTRL+right in others terminals) using Mac OS X system terminal. The solution to resolve it is very simple
Open Preferences » Settings » Keybord and add key mappping:
Option + cursor left = \033b
Option + cursor right = \033f
Październik 22nd, 2009 — Firefox
Using ram as cachedisk in firefox increases productivity of flash (ex. watching youtube).
First you have to do is create ramdisk using this command:
# diskutil erasevolume HFS+ "ramdisk" `hdiutil attach -nomount ram://1165430`
Next step is specify path to ramdisk in Firefox. Open new tab (or window) and type about:config.
Now you have to add new variable called browser.cache.disk.parent_directory with path to your created disk.
Set size of files which will be saved in your diskspace (browser.cache.disk.capacity) – for example 1165430 (550Mb).
To enable memory caching click double on browser.cache.memory.enable.
Październik 15th, 2009 — Linux, Mac OS X, OS
Use this command:
$ screen -dmS screen_name command
Październik 7th, 2009 — Python
$ python -m timeit -r 1000 -s "bla=[1,2,3]" "for item in bla:" " item" 1000000 loops, best of 1000: 0.306 usec per loop
$ python -m timeit -r 1000 -s "bla=[1,2,3]" "lista=bla.__iter__()" "while True:" " try:" " lista.next()" " except:" " break" 100000 loops, best of 1000: 3.13 usec per loop
__iter__ + try..except + while is round 11x slower than “for in” loop.
Październik 6th, 2009 — Linux, Mac OS X, Perl
perl -pi -w -e 's/source_text/destination_text/g;' *.php
Październik 6th, 2009 — Mac OS X
$ dscacheutil -flushcache
Październik 2nd, 2009 — Linux
Just use small snippet:
$ ls -l | grep "^d"