Skip to content

Instantly share code, notes, and snippets.

View wrboyce's full-sized avatar

Will Boyce wrboyce

View GitHub Profile
// 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);
}
import subprocess
def pbcopy(data):
p = subprocess.Popen(['pbcopy'], stdin=subprocess.PIPE)
p.stdin.write(data)
p.stdin.close()
return p.wait()
@wrboyce
wrboyce / bookmarklet.js
Last active January 3, 2016 22:49
uCTF Debugger Bookmarklet
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
#!/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
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?
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
""" 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):
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]
>>> def f1(): print 'f1'; return True
...
>>> def f2(): print 'f2'; return True
...
>>> f1() & f2()
f1
f2
True
>>> f1() and f2()
f1
from math import sqrt
def fib(n):
x = (1+sqrt(5))/2
y = -(1/x)
return (x**n - y**n) / sqrt(5)