This file contains 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
// Run with jsFiddle at http://jsfiddle.net/MarkRushakoff/jQwGz/ | |
_.mixin({ | |
bindFiltered : function(object, filterFunc) { | |
var funcNames = _(object).chain().functions().filter(filterFunc).value(); | |
var args = [object].concat(funcNames); | |
return _.bindAll.apply(_, args); | |
}, | |
bindMatching : function(object, regex) { |
This file contains 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
<html> | |
<head> | |
<script type="text/javascript" src="https://www.google.com/jsapi"></script> | |
<script> | |
google.load("jquery", "1.7.1"); | |
function findLeaks(jQuery) { | |
var cache = {}; | |
jQuery.each(jQuery.cache, function(key, val) { |
This file contains 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
var foregroundScreenRefreshRate = 1500; | |
var backgroundScreenRefreshRate = 9000; | |
jasmine.getEnv().updateInterval = foregroundScreenRefreshRate; | |
$(window).focus(function() { | |
jasmine.getEnv().updateInterval = foregroundScreenRefreshRate; | |
}); | |
$(window).blur(function() { |
This file contains 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 add(a, b) { | |
return a + b; | |
} |
This file contains 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
syn on | |
set syn=auto | |
filetype on | |
filetype plugin on | |
filetype indent on | |
autocmd FileType haml set ts=2 shiftwidth=2 | |
autocmd FileType ruby set ts=2 shiftwidth=2 | |
autocmd FileType javascript set nocindent |
This file contains 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
#!/usr/bin/env ruby | |
cmd = %q[echo '3...'; sleep 1; | |
echo '2...'; sleep 1; | |
echo '1...'; sleep 1; | |
echo 'Liftoff!'] | |
puts '------ beginning command ------' | |
output_log = [] | |
IO.popen(cmd).each do |line| |
This file contains 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
> echo 'Hello!' > hello.txt | |
> # Create 2 tarballs at right about the same time: | |
> tar czf hello1.tar.gz hello.txt; tar czf hello2.tar.gz hello.txt | |
> md5 * # The tarballs have the same md5 | |
MD5 (hello.txt) = e134ced312b3511d88943d57ccd70c83 | |
MD5 (hello1.tar.gz) = bfdacca1166009500d60151d73c4da7e | |
MD5 (hello2.tar.gz) = bfdacca1166009500d60151d73c4da7e | |
> tar czf hello1.tar.gz hello.txt; tar czf hello2.tar.gz hello.txt | |
> md5 * # The tarballs have a different md5 | |
MD5 (hello.txt) = e134ced312b3511d88943d57ccd70c83 |
This file contains 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
#!/usr/bin/sh | |
git grep -c rescue . | # or whatever word it is you want | |
tr ':' "\t" | # translate grep -c delimiter to tab for sort | |
sort -nr -k2 # sort Numeric, Reverse, "kolumn" 2 |
This file contains 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 | |
BOOK_SRC="${$1:-Book.txt}" | |
cat "$BOOK_SRC" | xargs cat | # dump out all the files in the book | |
sed 's/%%.*$//g' | # naively strip comment delimiter to end of line | |
wc -w | # print out the word count |
This file contains 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
package wrapped_func | |
// Run this benchmark with `go test -bench=.` | |
import "testing" | |
func BenchmarkSendItClean(b *testing.B) { | |
total := b.N | |
c := make(chan bool) | |
for i := 0; i < total; i++ { |
OlderNewer