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 / 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 / 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:
@omz
omz / HowOld.py
Created May 1, 2015 10:43
HowOld.py
# coding: utf-8
# Batch-upload script for how-old.net (Pythonista)
import photos
import requests
import json
import ui
from io import BytesIO
result_size = 320
@omz
omz / Height map 1.py
Created February 29, 2016 19:15
Height map 1.py
# coding: utf-8
# Optimized version of the code in this forum post: https://forum.omz-software.com/topic/2850/2-problems-with-shape-nodes-and-sprite-nodes
from scene import *
import random
import ui
import math
def render_bottom_texture(width=100.0):
import scene, ui
shadercode_text = '''
// Modified Mandelbrot code from shadertoy.com
// https://www.shadertoy.com/view/XdtSRN
// used make_color function from ccc (pythonista forum)
// https://github.com/cclauss/fractal_hacks/blob/master/cc_mandelbrot.py
precision highp float;
varying vec2 v_tex_coord;
@omz
omz / Geotag Photos.py
Last active January 6, 2024 05:42
Geotag Photos.py
#!python3
'''
This is a proof-of-concept script for tagging photos with location data on iOS.
* First, it shows all photos that have no location data *and* are editable.
* Then, a grid of photos in temporal proximity is shown. You can pick multiple photos here.
* When you tap Done, the photo you selected first will get tagged with the average location of the photos you picked in the second step.
'''
import photos
@omz
omz / Pythonista Theme Editor.py
Last active November 16, 2025 10:49
Pythonista Theme Editor.py
# coding: utf-8
'''
Basic theme editor for Pythonista 1.6 (beta)
WARNING: Use at your own risk! User themes aren't "officially" supported, and
this may break in future versions. If you enter invalid JSON or anything else
that the app can't deal with, it *will* crash -- your input is not validated
in any way.
'''
@omz
omz / Add Playground Page.py
Created June 17, 2016 00:27
Add Playground Page.py
#! python3
# Share sheet extension script for adding new pages to Swift Playgrounds (experimental)
# HOW TO USE:
# 1. Add this script as a shortcut to the Pythonista extension (either from Pythonista's settings or the share sheet extension itself)
# 2. Tap the "Share" button in the Playground app's library.
# 3. Select the playground that you want to add a page to
# 4. Select "Run Pythonista Script" in the share sheet
# 5. Run this script, to select the chapter and page title.