Skip to content

Instantly share code, notes, and snippets.

View ideamonk's full-sized avatar
🍹
wfh

Ideamonk ideamonk

🍹
wfh
View GitHub Profile
@ideamonk
ideamonk / hammer.py
Created March 2, 2011 12:56
flatten a nasty nested list into a string
def flatten(listy_list):
return ''.join([x if type(x)==type('') else flatten(x) for x in listy_list ])
@ideamonk
ideamonk / fucked_permutations.py
Created March 2, 2011 13:31
such a fucked up piece of fuck
def findAllPerm(string):
def findAll(slist):
if len(slist)==1:
return slist
else:
biglist = []
for i in xrange(len(slist)):
temp = [slist[i]]
temp.extend(findAll(slist[:i]+slist[i+1:]))
if len(temp)==2 and type(temp[0])==type(''):
fortune -s -n 100 | cowsay -f `ls -1 /usr/local/Cellar/cowsay/3.03/share/cows/ | sed s/\.cow// | tail -n +\`echo $(( 1 + (\\\`od -An -N2 -i /dev/random\\\`) % (\\\`ls -1 /usr/local/Cellar/cowsay/3.03/share/cows/ | wc -l\\\`) ))\` | head -1`
#!/usr/bin/osascript
tell application "System Events"
set frontApp to name of first application process whose frontmost is true
end tell
tell application frontApp
if the (count of windows) is not 0 then
set window_name to name of front window
end if
#!/usr/bin/osascript
if appIsRunning("Google Chrome") then
tell application "Google Chrome"
get URL of active tab of window 1
end tell
end if
on appIsRunning(appName)
tell application "System Events" to (name of processes) contains appName
function ogg2mp3() {
for f in *
do
ffmpeg -i "$f" -ab 500k "$f.mp3"
done
}
@ideamonk
ideamonk / ALAssetUsage.m
Created April 17, 2012 23:38 — forked from debuggerman/ALAssetUsage.m
using AssetsLibrary to read saved images album in iOS
void (^assetEnumerator)(ALAsset* result, NSUInteger index, BOOL*);
void (^groupEnumerator)(ALAssetsGroup*, BOOL *);
void (^faliure)(NSError*);
groupEnumerator = ^(ALAssetsGroup *group, BOOL *stop){
[group enumerateAssetsUsingBlock:assetEnumerator];
};
# Wrote this to find free licenses of TotalFinder , after which they discontinued their coupon offers
import base64, string, urllib2, itertools, multiprocessing
totallist = list(set(j+"".join(i) for i in list(itertools.permutations(string.ascii_uppercase*3, 3)) for j in string.digits))
baseurl = base64.decodestring('aHR0cDovL3NpdGVzLmZhc3RzcHJpbmcuY29tL2JpbmFyeWFnZS9wcm9kdWN0L3RvdGFsZmluZGVy\nZnJlZT9jb3Vwb249VEhBTktT\n')
def isValid(code):
url = baseurl+code
if not("is not a valid coupon." in urllib2.urlopen(url).read()):
print code, url
@ideamonk
ideamonk / database.yml
Created July 9, 2012 07:29
DRY-ish db config
# A DRY-ish config
common: &common
adapter: postgresql
encoding: unicode
template: template0
pool: 5
username: amal
password:
@ideamonk
ideamonk / headers_fix.sh
Created July 9, 2012 08:08
Fix for missing headers while building native extensions
# E.g. rb-fsevent gem fails with
# fsevent/fsevent_watch.c:1:10: fatal error: 'stdio.h' file not found
#
# XCode 4.3.3 , OSX Lion 10.7.3
#
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/