Skip to content

Instantly share code, notes, and snippets.

@omz
omz / Color picker.py
Created February 7, 2015 03:23
Color picker.py
import ui
from random import randint
import console
import clipboard
# Generate some random hex colors:
colors = ['#%X%X%X' % (randint(0,255), randint(0,255), randint(0,255)) for i in xrange(25)]
def tapped(sender):
r, g, b, a = sender.background_color
hex_color = '#%X%X%X' % (int(r*255), int(g*255), int(b*255))
@omz
omz / DispatchGroupMail.py
Created April 23, 2015 17:09
DispatchGroupMail.py
# coding: utf-8
# Starting point for emailing a group of people via Dispatch...
# The people in the group are identified by a unique string in the Notes field.
# TODO: Support setting the group identifier with an argument when launching the script via URL scheme (LCP...) - subject, body etc. could also be passed as arguments.
# Change this:
group_note = 'Group1'
@omz
omz / Mask Example.py
Created July 19, 2015 22:43
Mask Example.py
# Minimal example for ui.Image.clip_to_mask
# Note: Due to the changed image names, this requires Pythonista 1.6 (beta), but it could work in 1.5bwith different image names.
import ui
with ui.ImageContext(256, 256) as ctx:
mask_img = ui.Image.named('iow:beaker_256')
img = ui.Image.named('test:Peppers')
mask_img.clip_to_mask()
img.draw()
@omz
omz / gist:2134449
Created March 20, 2012 11:52
Highlighter plain text format
FooBar.pdf
================================================================================
p. 4 | highlight | yellow
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis
nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim id est laborum.
@omz
omz / Shell.py
Created November 13, 2012 16:13
Shell
# Based on https://gist.github.com/4063716
#
# Provides a simple shell with basic
# commands for dealing with files and
# directories.
#
# This script will try and prevent
# unsafe file operations outside of
# Documents directory.
#
@omz
omz / Untitled 1.py
Created November 30, 2012 17:34
Untitled 1
#coding: utf-8
# Original script by Federico Viticci:
# http://www.macstories.net/reviews/fantastical-for-iphone-review/
# Modified to work better with international characters
import webbrowser
import clipboard
import urllib
import console
@omz
omz / Touch Colors.py
Created February 28, 2013 15:00
Touch Colors
# Variation of the 'Basic Scene' template that shows every
# touch in a different (random) color that stays the same
# for the duration of the touch.
from scene import *
from colorsys import hsv_to_rgb
from random import random
class TouchColors (Scene):
def setup(self):
@omz
omz / DoubleTap.py
Created February 28, 2013 20:48
DoubleTap
from scene import *
from time import time
import sound
MAX_DOUBLE_TAP_DELAY = 0.25
class DoubleTapScene (Scene):
def setup(self):
self.last_touch_up_time = 0
self.double_tap_start_time = 0
@omz
omz / Primes.py
Created March 3, 2013 15:48
Primes
# 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):
@omz
omz / Curve Demo.py
Created March 5, 2013 02:30
Curve Demo
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: