Skip to content

Instantly share code, notes, and snippets.

var hash = new Object();
var anotherHash = {};
var hash = {"element1": "value2",
"element2": "value2",
"testKey": "testValue"};
hash['element1'] = 'question';
hash.element2 = 'baz';
hash['answer'] = '42';
hash.foo = 'bar';
for( var item in hash ) {
alert(hash[item]);
}
function sum() {
var sum = 0;
for( var i =0; i < arguments.length; i++ ) {
sum += arguments[i];
}
return sum;
}
sum(1,2,3,4,5); // -> 15
@ptzn
ptzn / gist:263692
Created December 25, 2009 18:15
wrapper for gem1.9 command
#!/bin/sh
RUBY19_HOME=/opt/ruby-1.9
$RUBY19_HOME/bin/gem1.9.original --config-file ~/.gemrc1.9 $@
exit $?
@ptzn
ptzn / .gemrc1.9
Created December 25, 2009 18:18
example of ~/.gemrc1.9 config
gemhome: /var/lib/gems/1.9
gempath:
- /home/user/.gem/ruby/1.9
- /usr/lib/ruby/gems/1.9
@ptzn
ptzn / gist:263697
Created December 25, 2009 18:19
chage-ruby script
#!/bin/sh
BIN_DIR=/usr/bin
RUBY18_BIN_DIR=/usr/bin
RUBY19_BIN_DIR=/opt/ruby-1.9/bin
GEMS_HOME=/var/lib/gems
if([ -z "$1" ] || ([ "$1" != "1.8" ] && [ "$1" != "1.9" ]))
then
echo "Usage: change_ruby VERSION (1.8 or 1.9)"
@ptzn
ptzn / gist:263701
Created December 25, 2009 18:29
emacs bookmarks configuration
(setq bm-restore-repository-on-load t)
(require 'bm)
;; Включаем/выключаем закладку - Alt+F5.
(global-set-key (kbd "<m-f5>") 'bm-toggle)
;; Переход на следующую закладку - F5.
(global-set-key (kbd "<f5>") 'bm-next)
;; Переход на предыдущую закладку - Shift+F5.
(global-set-key (kbd "<s-f5>") 'bm-previous)
;; Сохраняем закладки между сессиями.
@ptzn
ptzn / gist:263704
Created December 25, 2009 18:31
highlight current line in emacs
(global-hl-line-mode t)
(set-face-background 'hl-line "#1F3333")