This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # git config --global core.excludesfile /usr/local/git/exclude/exclude | |
| # see http://groups.google.com/group/peepcode/browse_thread/thread/fe6f9c1fc9d6e725 | |
| # Rivals | |
| .svn | |
| .hg | |
| # Archives | |
| *.zip | |
| *.gz |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # /usr/local/sbin/post-firewall | |
| # $1 = vlan1 | |
| # $2 = 192.168.1.1 | |
| iptables -t nat -I PREROUTING 1 -p tcp -d "$2" --dport 80 -j DNAT --to "$2":8082 | |
| iptables -t nat -D PREROUTING -i "$1" -p tcp --dport 80 -j DROP | |
| iptables -t nat -I PREROUTING 2 -i "$1" -p tcp --dport 8082 -j DROP | |
| iptables -I INPUT 1 -i "$1" -d "$2" -p tcp --syn --dport 8082 -j ACCEPT |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function source_of (array, up_to_dimension) { | |
| // Your implementation | |
| } | |
| source_of([1, [2, [3]]], 0) == '[1, ?]' | |
| source_of([1, [2, [3]]], 1) == '[1, [2, ?]]' | |
| source_of([1, [2, [3]]], 2) == '[1, [2, [3]]]' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * Handy URL params access | |
| * @example | |
| * location.href = 'http://www.google.com/search?q=foo+bar&client=firefox' | |
| * location.params == {q: 'foo+bar', client: 'firefox'} | |
| */ | |
| // JS 1.6 | |
| location.params = {}; | |
| location.search.substr(1).split('&').forEach(function(el){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| DirectoryIndex index.html index.htm index.xhtml index.xml index.php | |
| AddType message/rfc822 mht | |
| AddType application/octet-stream safariextz | |
| AddType application/atom+xml atom | |
| AddType application/msword doc | |
| AddType application/opensearchdescription+xml osd | |
| AddType application/pdf pdf | |
| AddType application/rdf+xml rdf | |
| AddType application/rss+xml rss |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * 'Hello world'.insert(6, 'happy ') == 'Hello happy world' | |
| * 'Hello world'.insert(-1, '!!!') == 'Hello world!!!' | |
| * @param at {Number} index | |
| * @param text {String} | |
| * @see http://ruby-doc.org/core/classes/String.html#M000773 | |
| */ | |
| String.prototype.insert = function (at, text) { | |
| if (at < 0) { | |
| at += this.length + 1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // this gist is response to http://dmitry.baranovskiy.com/post/201475166 | |
| // Code by Dmitry Baranovskiy | |
| var w=window,e=w.addEventListener,v=w.attachEvent;e&&e("load",a,!1);v&&v("onload",a);google.timers.load.t.prt=+new Date; | |
| // Mine optimization. 4 characters less! | |
| window[/*@cc_on'attachEvent'||@*/'addEventListener'](/*@cc_on'on'+@*/'load',a,0);google.timers.load.t.prt=+new Date; | |
| // I found /*@cc_on @*/ trick at http://lusever.livejournal.com/43326.html |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| window.addEventListener('load', function(){ | |
| //Works in Opera | |
| //Doesnt' work in Greasemonkey | |
| alert('window') | |
| }, false) | |
| window.wrappedJSObject.addEventListener('load', function(){ | |
| //Doesn't work in Opera | |
| //Works in Greasemonkey. See http://wiki.greasespot.net/UnsafeWindow | |
| alert('wrappedJSObject') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| result = re.search(r"#[a-f0-9]{3}", 'Roses are #f00') | |
| result.group(0) == '#f00' # True | |
| result[0] # Damn! TypeError: '_sre.SRE_Match' object is unsubscriptable | |
| # Why result cannot be accessed like array? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| a=['first', 'last']; | |
| a[-1] == null; | |
| a[-1] = a[a.length-1]; | |
| a[-1] == 'last' |