Skip to content

Instantly share code, notes, and snippets.

omz /
Created November 10, 2012 12:32
from scene import *
from random import randint, random, choice
from sound import play_effect
from colorsys import hsv_to_rgb
from math import sin
from functools import partial
from copy import copy
class Star (object):
def __init__(self):
omz /
Created December 9, 2013 11:01
# This script adds a "Webclip" shortcut to your homescreen.
# The shortcut can be used to open a web page in full-screen mode,
# or to launch a custom URL (e.g. a third-party app).
# You'll be asked for a title, a URL, and an icon (from your camera roll)
import plistlib
import BaseHTTPServer
import webbrowser
import uuid
from io import BytesIO
omz /
Last active August 8, 2023 14:44
File Transfer script for Pythonista (iOS)
# File Transfer for Pythonista
# ============================
# This script allows you to transfer Python files from
# and to Pythonista via local Wifi.
# It starts a basic HTTP server that you can access
# as a web page from your browser.
# When you upload a file that already exists, it is
# renamed automatically.
# From Pythonista's settings, you can add this script
# to the actions menu of the editor for quick access.
omz /
Last active August 8, 2023 14:43
# FontInstaller (by @olemoritz)
# This script installs a custom TTF font on iOS (system-wide).
# It can be used in one of two ways:
# 1. Simply run it in Pythonista, you'll be prompted for the URL of the font
# you'd like to install (if there's a URL in the clipboard, it'll be used by default)
# 2. Use it as an 'Open in...' handler, i.e. select this file in Pythonista's 'Open in...
# menu' setting. This way, you can simply download a ttf file in Safari and open it in
omz / Pythonista Theme
Last active August 8, 2023 14:42
Pythonista Theme
View Pythonista Theme
# 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 / UI Debugging
Last active August 3, 2023 14:08
UI Debugging
View UI Debugging
# Pythonista script to show the UI Debugging overlay (private API) described in this blog post:
from objc_util import ObjCClass, on_main_thread
UIDebuggingInformationOverlay = ObjCClass('UIDebuggingInformationOverlay')
def toggle_overlay():
omz / CoreML Image
Created July 8, 2018 10:36
CoreML Image
View CoreML Image
This is a demo of how you can use the CoreML framework (via objc_util) to classify images in Pythonista. It downloads the trained 'MobileNet' CoreML model from the Internet, and uses it to classify images that are either taken with the camera, or picked from the photo library.
import requests
import os
import io
import photos
import dialogs
omz /
Last active July 25, 2023 09:01
# coding: utf-8
'''Creates a zip archive of your Pythonista files and serves them via HTTP in your local network.'''
import sys
if sys.version_info[0] >= 3:
from http.server import SimpleHTTPRequestHandler, HTTPServer
from SimpleHTTPServer import SimpleHTTPRequestHandler
from BaseHTTPServer import HTTPServer
omz / Check dictionary
Created March 10, 2016 17:36
Check dictionary
View Check dictionary
# coding: utf-8
Demo of using the built-in iOS dictionary to check words
NOTES: This is quite slow, it might be possible to use the spell-checking
dictionary for this instead, haven't tried that yet.
If no dictionary is downloaded yet, the API will always return True
(probably so that the "Define" menu item can be shown before
a dictionary has been downloaded).
omz /
Created November 10, 2012 17:25
import SimpleHTTPServer
import SocketServer
import webbrowser
import os
Handler = SimpleHTTPServer.SimpleHTTPRequestHandler
httpd = SocketServer.TCPServer(("", 0), Handler)
port = httpd.server_address[1]'http://localhost:' + str(port), stop_when_done=True)