Skip to content

Instantly share code, notes, and snippets.

@omz
omz / SlimIt-Installer.py
Created October 21, 2013 17:11
SlimIt-Installer
ply_url = 'https://pypi.python.org/packages/source/p/ply/ply-3.4.tar.gz'
slimit_url = 'https://pypi.python.org/packages/source/s/slimit/slimit-0.8.1.zip'
print 'Downloading SlimIt...'
from urllib import urlretrieve
import tarfile
import zipfile
import shutil
import os
try:
@omz
omz / ShortcutGenerator.py
Created December 9, 2013 11:01
ShortcutGenerator
# 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
omz / Untitled 4.py
Created January 2, 2014 15:05
Untitled 4
import console
import clipboard
import os
img = clipboard.get_image()
if img:
img.save('temp.jpg')
console.quicklook('temp.jpg')
os.remove('temp.jpg')
else:
@omz
omz / ShowLastPhotoMap.py
Last active March 21, 2019 16:04
ShowLastPhotoMap
# Shows the location of the last photo in the canera roll in the Maps app.
# (thanks to @HyShai for pointing out that the latitude/longitude refs are necessary)
import photos
import webbrowser
meta = photos.get_metadata(-1)
gps = meta.get('{GPS}')
if gps:
latitude = str(gps.get('Latitude', 0.0)) + gps.get('LatitudeRef', '')
@omz
omz / FontInstaller.py
Last active August 8, 2023 14:43
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
@omz
omz / Sound Demo.py
Created April 7, 2014 16:40
Sound Demo
# Simple demo of playing a looping sound using the (currently undocumented) sound.Player class
import sound
import os
from scene import *
class MyScene (Scene):
def setup(self):
self.player = sound.Player(os.path.expanduser('~/Pythonista.app/Beep.caf'))
self.player.number_of_loops = -1 #repeat forever
@omz
omz / Dropbox File Picker.py
Last active May 17, 2020 21:47
Dropbox File Picker.py
# IMPORTANT SETUP INSTRUCTIONS:
#
# 1. Go to http://www.dropbox.com/developers/apps (log in if necessary)
# 2. Select "Create App"
# 3. Select the following settings:
# * "Dropbox API app"
# * "Files and datastores"
# * "(No) My app needs access to files already on Dropbox"
# * "All file types"
# * (Choose any app name)
@omz
omz / UpsideDownText.py
Created June 28, 2014 18:31
UpsideDownText.py
import ui
# Mapping based on http://www.upsidedowntext.com/unicode
CHARMAP = {'!': '\xc2\xa1', '"': ',,',
"'": ',', '&': '\xe2\x85\x8b',
')': '(', '(': ')', ',': "'",
'.': '\xcb\x99',
'1': '\xc6\x96',
'0': '0', '3': '\xc6\x90',
'2': '\xe1\x84\x85',
/*
Batch-Rename Layers -- plugin for Sketch 2 (http://www.bohemiancoding.com/sketch/)
INSTALLATION
------------
Select "Reveal Plugins Folder..." in the "Plugins" menu,
then put this file in the folder that shows up in the Finder.
@omz
omz / SSHClient.py
Created January 7, 2015 21:21
SSHClient.py
# Very simple SSH client for Pythonista
import paramiko
import console
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
host = console.input_alert('Connect to')
user, passwd = console.login_alert('Login')
ssh.connect(host, username=user, password=passwd)
print 'Connected to %s. Type `exit` to disconnect.' % host