Skip to content

Instantly share code, notes, and snippets.

jsbain

Block or report user

Report or block jsbain

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View multicb.py
import cb, threading
class Service(object):
'''wrapper for a cb.Service. Can index characteristics by
s[uuid] or s[index]
'''
def __init__(self,service):
self.primary=service.primary
self.uuid=service.uuid
self.characteristics={}
View avplayer.py
'''
minimal avplayer example
'''
from objc_util import *
AVPlayerItem=ObjCClass('AVPlayerItem')
AVPlayer=ObjCClass('AVPlayer')
AVPlayerLayer=ObjCClass('AVPlayerLayer')
import photos
def pick_asset():
assets = photos.get_assets(media_type='video')
@jsbain
jsbain / mail.py
Last active Aug 30, 2019
mail.py
View mail.py
# coding: utf-8
import objc_util
from objc_util import *
# setup an array of objects we cannot discard
objc_util.retain=getattr(objc_util,'retain',[])
root_vc = UIApplication.sharedApplication().keyWindow().rootViewController()
def mailComposeController_didFinishWithResult_error_(self, sel, controller, result, error):
root_vc.dismissModalViewControllerAnimated_(True)
View iosurface.py
from objc_util import *
from ctypes import *
from contextlib import contextmanager
import ui
import numpy as np
''' define ctypes signatures'''
IOSurfaceCreate=c.IOSurfaceCreate
IOSurfaceCreate.argtypes=[c_void_p]
IOSurfaceCreate.restype=c_void_p
View selectNextTab.py
from objc_util import *
@on_main_thread
def select(idx):
import editor
tvc=editor._get_editor_tab().parentViewController()
tbv=tvc.tabBarView()
tvs=tbv.tabViews()
if idx < len(tvs):
tvc.tabBarView().tabSelected_(tvs[idx])
View Untitled_20.py
from scene import *
from math import floor
class SceneTimers(Scene):
def setup(self):
t1=LabelNode()
t2=LabelNode()
t3=LabelNode()
View plotView.py
import ui
import numpy as np
W=1024
import time
from objc_util import *
CAShapeLayer=ObjCClass('CAShapeLayer')
View audioengine.py
from objc_util import *
AVAudioEngine = ObjCClass('AVAudioEngine').alloc().init()
AVAudioSession = ObjCClass('AVAudioSession')
AVAudioRecorder = ObjCClass('AVAudioRecorder')
shared_session = AVAudioSession.sharedInstance()
category_set= shared_session.setCategory_withOptions_error_(
ns('AVAudioSessionCategoryRecord'),
0x2, #duckothers
None)
@jsbain
jsbain / savefile.py
Last active Mar 1, 2019
savefile.py
View savefile.py
#coding: utf-8
import requests
import appex,console,time,os
unquote=requests.utils.unquote
urlparse=requests.utils.urlparse
url=appex.get_url()
p=urlparse(url)
urlfilename=unquote(unquote(urlparse(appex.get_url()).path.split('/')[-1]))
console.hud_alert('downloading '+urlfilename)
View objc_classes.py
from objc_util import *
import weakref
import functools
''' Attempt at making more natural objc class in pythonista.
decorate python class with @objclass to create an ObjCClass.
set superclass and protocols class attributes, if desired.
You can’t perform that action at this time.