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
| def flatten(listy_list): | |
| return ''.join([x if type(x)==type('') else flatten(x) for x in listy_list ]) |
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
| 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(''): |
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
| 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` |
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
| #!/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 |
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
| #!/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 |
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 ogg2mp3() { | |
| for f in * | |
| do | |
| ffmpeg -i "$f" -ab 500k "$f.mp3" | |
| done | |
| } |
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
| void (^assetEnumerator)(ALAsset* result, NSUInteger index, BOOL*); | |
| void (^groupEnumerator)(ALAssetsGroup*, BOOL *); | |
| void (^faliure)(NSError*); | |
| groupEnumerator = ^(ALAssetsGroup *group, BOOL *stop){ | |
| [group enumerateAssetsUsingBlock:assetEnumerator]; | |
| }; | |
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
| # 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 |
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 DRY-ish config | |
| common: &common | |
| adapter: postgresql | |
| encoding: unicode | |
| template: template0 | |
| pool: 5 | |
| username: amal | |
| password: |
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
| # 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/ |