Skip to content

Instantly share code, notes, and snippets.

# Workaround for default editable text entries on OS X .. sadly relies on curses
import curses, curses.textpad
from curses.textpad import Textbox
screen = curses.initscr()
curses.savetty()
curses.noecho()
class BackspaceTextbox(Textbox):
import base64
from scene import *
from PIL import Image
def load_keyboard(retina_display = False):
kb_filename = "keyboard.png"
if retina_display:
kb_filename = "keyboard@2x.png"
kb_image = load_image_file(kb_filename)
if not kb_image:
@pudquick
pudquick / pipista.py
Created November 20, 2012 07:23
pipista - pip module (for installing other modules) for Pythonista
import os, os.path, sys, urllib2, requests
class PyPiError(Exception):
def __init__(self, value):
self.value = value
def __str__(self):
return repr(self.value)
def _chunk_report(bytes_so_far, chunk_size, total_size):
if (total_size != None):
@pudquick
pudquick / mobile.py
Created November 22, 2012 07:08
mobile
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PayloadContent</key>
<array>
<dict>
<key>FullScreen</key>
<true/>
<key>IsRemovable</key>
<true/>
@pudquick
pudquick / webclip.py
Created November 22, 2012 10:09
Create webclippings in Pythonista
import uuid, BaseHTTPServer, select, types, clipboard, console
from SimpleHTTPServer import SimpleHTTPRequestHandler
try:
from cStringIO import StringIO
except ImportError:
from StringIO import StringIO
global mobile_config_str
mobile_config_str = ''
@pudquick
pudquick / shellista.py
Last active November 12, 2022 16:56
Advanced shell for Pythonista
import os, cmd, sys, re, glob, os.path, shutil, zipfile, tarfile, gzip
# Credits
#
# The python code here was written by pudquick@github
#
# License
#
# This code is released under a standard MIT license.
#
import sys, os.path
settings_file = sys.argv[1]
id_list_file = sys.argv[2]
f = open(settings_file)
settings = f.read()
f.close()
f = open(id_list_file)
ids = f.read()
import sys, os.path
with open(sys.argv[1]) as f, open(sys.argv[2]) as g:
settings = [x for x in f.read().split('\n')]
ids = g.read().split()
mode = 0
for i, line in enumerate(settings):
if line.strip():
if (mode == 0) and line.startswith('[') and (line.strip('[]') in ids): mode = 1
if (mode == 1): settings[i] = ';' + settings[i]
else: mode = 0
import sqlite3, plistlib
tracks_cmap = {'Album' :'album',
'Album Rating' :'album_rating',
'Artist' :'artist',
'Comments' :'comments',
'Compilation' :'compilation',
'Composer' :'composer',
'Disabled' :'disabled',
'Disc Count' :'disc_count',
@pudquick
pudquick / pipista.py
Created December 17, 2012 09:41
Version 2.0 of pipista - Unstable branch :)
import os, os.path, sys, urllib2, requests, tempfile, zipfile, shutil, gzip, tarfile
__pypi_base__ = os.path.abspath(os.path.dirname(__file__))
class PyPiError(Exception):
def __init__(self, value):
self.value = value
def __str__(self):
return repr(self.value)