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 f1(): print 'f1'; return True | |
| ... | |
| >>> def f2(): print 'f2'; return True | |
| ... | |
| >>> f1() & f2() | |
| f1 | |
| f2 | |
| True | |
| >>> f1() and f2() | |
| f1 |
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 diff_lists(old_list, new_list): | |
| """ | |
| >>> diff_lists([1,2,3], [2,3,4]) # removed 1, added 4 | |
| [('-', 1), ('+', 4)] | |
| >>> diff_lists([1,2,3], [1,2,3]) | |
| [] | |
| """ | |
| old = set(old_list) | |
| new = set(new_list) | |
| return [('-', e) for e in old-new] + [('+', e) for e in new-old] |
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
| """ Interface to the AQL (aql.co.uk/telecoms) Reseller APIs. """ | |
| import urllib | |
| class ApiInterface(object): | |
| """ Abstract AQL API """ | |
| url = '' | |
| exports = () | |
| def call(self, action, **kwargs): |
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
| unset -f compdef ## unset the above defined function which populates __deferred_compdefs | |
| autoload -U compinit | |
| compinit -i | |
| local cd | |
| for cd in ${__deferred_compdefs}; do | |
| compdef ${cd} ## process the actual compdef -- this doesn't work, a cheap fix seems to be eval "compdef ${cd}" | |
| done | |
| unset __deferred_compdefs |
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
| Welcome to EE Live Chat | |
| Kevin: | |
| How can I help? | |
| Will: | |
| Hi Kevin | |
| Will: | |
| Haha, are you really called Kevin? | |
| Will: | |
| or is this some Kevin Bacon thing? |
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 | |
| # curl https://gist.github.com/wrboyce/7547057/raw/espresso-init.sh | sh | |
| sudo add-apt-repository ppa:webupd8team/java | |
| sudo apt-get update | |
| sudo apt-get -y install git unzip lib32z1 lib32ncurses5 lib32stdc++6 oracle-java7-installer | |
| mkdir -p src | |
| cd src |
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
| javascript:(function()%7B(function()%7Bdonemanual();$('%23hideheaders').click().hide();(function()%7Bvar%20helpDiv=$('%3Cdiv/%3E').css(%7B'width':'300px','height':'300px','background':'black','position':'fixed','top':'50%25','left':'50%25','margin-top':'-150px','margin-left':'-150px','zIndex':'1000000','opacity':'0.8','padding':'30px'%7D).appendTo('body').hide();$('%3Ch3/%3E').text('Global%20Hotkeys').appendTo(helpDiv);$('%3Cbr/%3E').appendTo(helpDiv);$('%3Cp/%3E').text('%5B%20-%3E%20step').appendTo(helpDiv);$('%3Cp/%3E').text('%5D%20-%3E%20finish').appendTo(helpDiv);$('%3Cp/%3E').text('%5C%5C%20-%3E%20continue').appendTo(helpDiv);$(document).bind('keydown',function(e)%7Bswitch(e.which)%7Bcase%20219:parse('s');break;case%20221:parse('f');break;case%20220:parse('c');break;case%20191:helpDiv.show();%7D%7D);$(document).bind('keyup',function(e)%7Bif(e.which==191)helpDiv.hide();%7D);%7D)();(function()%7Bcpu._readhex=function(e)%7Bif(!e%5B1%5D)return%20write(%22%20%20%20Please%20give%20an%20expression%20to%20read%2 |
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
| import subprocess | |
| def pbcopy(data): | |
| p = subprocess.Popen(['pbcopy'], stdin=subprocess.PIPE) | |
| p.stdin.write(data) | |
| p.stdin.close() | |
| return p.wait() |
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
| // Example usage, attach a similar trigger to your Spreadsheet's onFormSubmit event | |
| function onFormSubmit(e) { | |
| var templateId = 'YOUR-DOCUMENT-ID-HERE', | |
| filenameTemplate = 'MailMerged Documents/<<Date>>/<<Client Name>>', | |
| documentId = mailMerge(templateId, filenameTemplate, e.namedValues); | |
| if (e.namedValues['Email PDF']) | |
| emailPdf(e.namedValues['Username'], documentId); | |
| } |
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
| # regular gzip | |
| major:~/Downloads% time gzip 5000M.rnd | |
| gzip 5000M.rnd 21.70s user 1.04s system 99% cpu 22.845 total | |
| major:~/Downloads% du -h 5000M.rnd.gz | |
| 4.6M 5000M.rnd.gz | |
| major:~/Downloads% time gunzip 5000M.rnd.gz | |
| gunzip 5000M.rnd.gz 8.41s user 1.59s system 92% cpu 10.783 total | |
| # pigz, multi-core gzip | |
| major:~/Downloads% time pigz 5000M.rnd | |
| pigz 5000M.rnd 49.46s user 1.57s system 1468% cpu 3.476 total |