Skip to content

Instantly share code, notes, and snippets.

@jsbain
jsbain / clk.py
Created May 11, 2016 18:37
clk.py
import ui,time
import bz2
from base64 import b64decode
import threading
import math
from objc_util import on_main_thread
#https://gist.github.com/b8e6f213d19e9d4668a7f28bbd1efe9f
def run_async(func):
@jsbain
jsbain / clk.py
Created May 11, 2016 19:13
clk.py
import ui,time
import bz2
from base64 import b64decode
import threading
import math
from objc_util import on_main_thread
def run_async(func):
@jsbain
jsbain / clk.py
Created May 11, 2016 19:54
clk.py
import ui,time
import bz2
from base64 import b64decode
import threading
import math
from objc_util import on_main_thread
import time
import sound
@jsbain
jsbain / pyui_example.py
Created May 31, 2016 09:09
pyui_example.py
# coding: utf-8
# coding: utf-8
import ui
#unpack pyuis
pyuistr='''
[ {
"class" : "View",
"attributes" : {
"custom_class" : "MyView",
"background_color" : "RGBA(1.000000,1.000000,1.000000,1.000000)",
@jsbain
jsbain / SlideMenu.py
Created June 1, 2016 04:19
SlideMenu.py
# coding: utf-8
import ui
from pythonista_gestures.Gestures import Gestures
class SideMenuSlideView(ui.View):
def __init__(self, master_view, detail_view):
#need to instantiate with master and detail subviews as args.
self.g=Gestures()
self.prev_location=None
@jsbain
jsbain / SlideMenu.py
Created June 1, 2016 05:05
SlideMenu.py
# coding: utf-8
# based on @cook code https://forum.omz-software.com/topic/3181/ui-view-and-touch
# uses https://github.com/mikaelho/pythonista-gestures
import ui
from pythonista_gestures.Gestures import Gestures
class SideMenuSlideView(ui.View):
def __init__(self, master_view, detail_view):
#need to instantiate with master and detail subviews as args.
@jsbain
jsbain / loadhistory.py
Created June 7, 2016 15:59
savehistory.py
from objc_util import UIApplication
with open('history.py','r') as f:
UIApplication.sharedApplication().keyWindow().rootViewController().accessoryViewController().consoleViewController().history= f.readlines()
@jsbain
jsbain / Dropbox File Picker.py
Created June 15, 2016 05:17
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)
@jsbain
jsbain / launchpy2.py
Created June 15, 2016 07:23
launchpy2.py
'''Dual interpreter experiment: try launching py2 script from py3.
Result: success.... but globals are cleared,- same as if play button is pressed
'''
import sys
from objc_util import *
import editor,os
@on_main_thread
def _get_editor_tab():
''' from editor.py in py3, gets the texteditorviewcontroller.
@jsbain
jsbain / Audio.py
Created June 24, 2016 17:03
Audio.py
from objc_util import *
import ctypes
import numpy as np
import matplotlib.image
import io,ui
AVAudioEngine=ObjCClass('AVAudioEngine')
AVAudioSession=ObjCClass('AVAudioSession')
def setup():
error=ctypes.c_void_p(0)
session=AVAudioSession.sharedInstance()