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/python | |
import urllib,urllib2, sys | |
BASE_URL = 'http://192.168.100.101:5000' | |
ADMIN_PASS = 'YOUR ADMIN PASS' | |
# Login to admin interface | |
parameters = {'username' : 'admin', 'passwd':ADMIN_PASS,'service_type':'1'} | |
request = urllib2.Request(BASE_URL+'/webman/modules/login.cgi', urllib.urlencode(parameters)) |
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
# typical to sum over your list of items perhaps | |
# performing some calculation on each item | |
normalizing_constant = \ | |
sum([calc(item) for item in items if filter(item)]) | |
r = random.random() | |
for item in items: | |
prob = get_probability(item) / normalizing_constant |
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
# Bulk add a bunch of urls to your Instapaper account | |
$ for link in `cat links.txt`; do curl --basic --user username:password --data url=$link http://www.instapaper.com/api/add; done |
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
// I have some code that needs to use the following | |
// construct repeatedly | |
for(i=0;i<classes.length;i++){ | |
var c = classes[i]; | |
for(j=0;j<centers.length;j++){ | |
var k = centers[k]; | |
// do something with [c,k], like, | |
// demand[[c,k]] = expression; |
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
# returns seconds till next tuesday @ noon - 5 minutes | |
exports.reckonTimeoutValue = ()-> | |
# num days till next tuesday | |
tuesOffset = | |
2 : 7 | |
3 : 6 | |
4 : 5 | |
5 : 4 | |
6 : 3 |
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/local/bin/macruby | |
framework "ScriptingBridge" | |
safari = SBApplication.applicationWithBundleIdentifier("com.apple.Safari") | |
safari.windows.each {|window| | |
window.tabs.each { |tab| | |
cmd = "open -a '/Applications/Google\ Chrome.app/' #{tab.URL}" | |
`#{cmd}` | |
} |
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/bash | |
cdparanoia -B | |
ls | while read fn; do lame $fn; done; | |
mp3wrap -v album.mp3 *.mp3 | |
mp3val album_MP3WRAP.mp3 -f -nb | |
mv album_MP3WRAP.mp3 album.mp3 | |
cp album.mp3 ~/Dropbox/Public/ |
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
[12] pry(main)> class Fixnum | |
[12] pry(main)* def in(l) | |
[12] pry(main)* l.include? self | |
[12] pry(main)* end | |
[12] pry(main)* end | |
=> nil | |
[13] pry(main)> 1.in [1,2,3] | |
=> true |
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/ruby | |
# gif-it | |
if ARGV.length < 3 | |
puts "usage: gif-it <filename> <start-time> <duration>" | |
end | |
fn = ARGV.shift | |
start_time = ARGV.shift | |
duration = ARGV.shift |
OlderNewer