View launcher.py
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
from android import Android | |
droid = Android() | |
def launch_script(path, visible=False): | |
visibilty = 'FORE' if visible else 'BACK' | |
activity = 'com.googlecode.android_scripting.action.LAUNCH_{0}GROUND_SCRIPT'.format(visibilty) | |
extras = {'com.googlecode.android_scripting.extra.SCRIPT_PATH': path} | |
package = 'com.googlecode.android_scripting' | |
classname = 'com.googlecode.android_scripting.activity.ScriptingLayerServiceLauncher' |
View wrapping_cursor.py
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
def set_terminal_keybindings(): | |
"""If IPython is running in the classic terminal mode, this function | |
is called once, and is not called otherwise. We could have just used | |
an if-block, but this way also keeps the variables local.""" | |
from prompt_toolkit.keys import Keys | |
from prompt_toolkit.filters import Filter | |
class StartOfLine(Filter): |
View maestro.py
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
import os | |
from IPython.core.magic import register_line_magic as line_magic | |
@line_magic | |
def maestro(name): | |
quote = lambda text: '"{}"'.format(text) | |
command = " osascript -e 'tell application {0} to do script {1}' " | |
os.system(command.format(quote("Keyboard Maestro Engine"), quote(name))) |
View fileserver.py
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
import os | |
from IPython.core.magic import register_line_magic as line_magic | |
@line_magic | |
def fileserver(args): | |
path, port = args.split(" ") if args else (".", "8080") | |
os.system('ruby -run -ehttpd "{}" -p{}'.format(path, port)) |
View nyan.py
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
@line_magic | |
def nyan(path): os.system("pygmentize -g {0} | less -R".format(path)) |
View barcode.py
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
def render(digits): | |
'''This function converts its input, a string of decimal digits, into a | |
barcode, using the interleaved 2 of 5 format. The input string must not | |
contain an odd number of digits. The output is an SVG string. | |
Wikipedia [ITF Format]: http://en.wikipedia.org/wiki/Interleaved_2_of_5 | |
''' | |
top = '<svg height="58" width="{0}" style="background:white">' |
View fetch_phaser_world.py
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
def download(issues): | |
"""This function downloads a given range of Phaser World back | |
issues into the current working directory. Any arguments will | |
be passed to the `range` function to define the list of issue | |
numbers that will be downloaded.""" | |
import os | |
url_template = "https://phaser.io/images/newsletter/pdf/issue{}.pdf" |
View docs.py
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
from htme import * | |
subpages = { | |
"unknown": { | |
"type": 'Unknown User', | |
"body": 'Your <a href="{URL}">Google Account</a> is unknown.' | |
}, | |
"denial": { | |
"type": 'Unauthorized User', | |
"body": 'Your rank is too low to access this part of the app.' |
View common.coffee
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
# shorthand wrapper for `console.log` | |
put = (args...) -> console.log args... | |
# initialise undefined vars: `[a, b, c] = init 3` | |
init = (amount) -> undefined for n in [1..amount] | |
# decorator for defining constructors (see example.coffee) | |
factory = (mutator) -> (args...) -> | |
mutator (self = Object.create null), args... | |
return self |
View replace.py
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
import re | |
def replace(string, substitutions): | |
substrings = sorted(substitutions, key=len, reverse=True) | |
regex = re.compile('|'.join(map(re.escape, substrings))) | |
return regex.sub(lambda match: substitutions[match.group(0)], string) |
OlderNewer