Skip to content

Instantly share code, notes, and snippets.

View wgaylord's full-sized avatar

William Gaylord wgaylord

View GitHub Profile
@omz
omz / FontInstaller.py
Last active January 31, 2025 20:34
FontInstaller
# 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
@pudquick
pudquick / lzma_decompress.py
Created April 8, 2015 21:47
Python ctypes wrapper around liblzma for the purposes of (naive) lzma file decompression, for use with OS X 10.7+
# Example usage of the function:
# decompress('somefile.pack.lzma', 'somefile.pack')
# Decompresses a lzma compressed file from the first input file path to the second output file path
import sys
from ctypes import CDLL, Structure, c_void_p, c_size_t, c_uint, c_uint32, c_uint64, create_string_buffer, addressof, sizeof, byref
class lzma_stream(Structure):
_fields_ = [
@omz
omz / PythonistaBackup.py
Last active January 6, 2024 05:44
PythonistaBackup.py
# 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
else:
from SimpleHTTPServer import SimpleHTTPRequestHandler
from BaseHTTPServer import HTTPServer
@AbrarSyed
AbrarSyed / build.gradle
Created October 28, 2015 15:22
tweaker-server example
plugins {
id "net.minecraftforge.gradle.tweaker-server" version "2.0.2"
}
version = "1.0"
group= "com.yourname.modid" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "modid"
minecraft {
version = "1.8"
@omz
omz / Add Web Tab.py
Last active April 15, 2025 01:31 — forked from steventroughtonsmith/Add Web Tab.py
Insert a custom browser tab into Pythonista
# coding: utf-8
from objc_util import *
import console
import urllib
import dialogs
WKWebView = ObjCClass('WKWebView')
UIViewController = ObjCClass('UIViewController')
UIBarButtonItem = ObjCClass('UIBarButtonItem')
NSURLRequest = ObjCClass('NSURLRequest')
@controversial
controversial / ProgressBadge.py
Last active July 19, 2022 19:31
ProgressBadge.py
from objc_util import *
import time
import notification
APP=UIApplication.sharedApplication()
DISPLAYMODE=0
def setBadge(text):
APP.setApplicationBadgeString_(text)
@omz
omz / Barcode Scanner.py
Created February 19, 2016 00:36
Barcode Scanner.py
# coding: utf-8
# Barcode scanner demo for Pythonista
# Based on http://www.infragistics.com/community/blogs/torrey-betts/archive/2013/10/10/scanning-barcodes-with-ios-7-objective-c.aspx
from objc_util import *
from ctypes import c_void_p
import ui
import sound
found_codes = set()
@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):
@omz
omz / EmbedPyui.py
Last active December 21, 2021 21:17
EmbedPyui.py
# coding: utf-8
'''
This is a little helper script to make it easier
to create single-file scripts with Pythonista, while
still taking advantage of the UI editor.
It'll essentially convert the .pyui file to a compact
string representation that you can embed directly
in your script. The code to unpack and load the UI
is also auto-generated for convenience.
@omz
omz / Spellcheck word.py
Created March 10, 2016 20:01
Spellcheck word.py
# coding: utf-8
from objc_util import ObjCClass
UITextChecker = ObjCClass('UITextChecker')
def check_word(word, lang='en_US'):
c = UITextChecker.new().autorelease()
check = c.rangeOfMisspelledWordInString_range_startingAt_wrap_language_
misspelled_range = check(word, (0, len(word)), 0, False, lang)
return (misspelled_range.location != 0)