This is some superscript text.
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
''' | |
Pythonista Find and Replace | |
=========================== | |
Notices | |
------- | |
Copyright 2013 Harry Jubb. | |
This program is free software: you can redistribute it and/or modify |
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
#!/bin/bash | |
function setjdk { | |
local ver=${1?Usage: setjdk <version>} | |
export JAVA_HOME=$(/usr/libexec/java_home -v $ver) | |
PATH=$(echo $PATH | tr ':' '\n' | grep -v Java | tr '\n' ':') | |
export PATH=$JAVA_HOME/bin:$PATH | |
java -version |
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
{ | |
"//field": "These 'double quote' 'double quote' are used as comments, because JSON doesnt' allow comment", | |
"field": {}, | |
"#another-field": "Another comment", | |
"another-field": {}, | |
"/*stuff": "Be careful to use them when you have full control of the content :)", | |
"stuff": [], | |
"bla": "bla" | |
} |
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
# This is a really old post, in the comments (and stackoverflow too) you'll find better solutions. | |
def find(key, dictionary): | |
for k, v in dictionary.iteritems(): | |
if k == key: | |
yield v | |
elif isinstance(v, dict): | |
for result in find(key, v): | |
yield result | |
elif isinstance(v, list): |
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 canvas | |
canvas.set_size(512, 512) | |
from_point = (10, 10) | |
cp1 = (40, 200) #control point 1 | |
cp2 = (350, 50) #control point 2 | |
to_point = (300, 300) | |
# Draw the actual curve: |
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
# Demo of how to generate a list of prime numbers and cache them | |
# in a data file for fast access (using the marshal module). | |
def gen_primes(n): | |
# Source: http://code.activestate.com/recipes/366178-a-fast-prime-number-list-generator/#c19 | |
s = range(0, n+1) | |
s[1] = 0 | |
bottom = 2 | |
top = n // bottom | |
while (bottom * bottom <= n): |
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
# Play a blues melody on Pythonista on the iPad (iOS) | |
import sound | |
import time | |
def playNotes(inNotes, inWithEmphisis=False): | |
for note in inNotes: | |
sound.play_effect('Piano_' + note) | |
if (inWithEmphisis): | |
time.sleep(0.25) | |
sound.play_effect('Piano_' + note) |
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
Git 1.6: | |
git ls-files --others -i --exclude-standard | |
Git 1.4, 1.5: | |
git ls-files --others -i \ | |
--exclude-from="`git rev-parse --git-dir`/info/exclude" \ | |
--exclude-per-directory=.gitignore | |
from: http://wtanaka.com/node/7875 |
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
<html> | |
<head> | |
<!-- | |
In this example, I started with the 5-minute example provided by Google | |
on the following page: | |
https://developers.google.com/drive/ | |
I modified the example code, so that I could write the following |