Skip to content

Instantly share code, notes, and snippets.

@jsbain
jsbain / savefile.py
Created March 29, 2018 16:01
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)
@jsbain
jsbain / Untitled_191.py
Created March 29, 2018 05:23
Untitled_191.py
from scene import *
import random
import ui
A = Action
g1 ='plc:Grass_Block'
g2 ='plc:Dirt_Block'
g3 = 'plc:Brown_Block'
g4='plc:Roof_South'
@jsbain
jsbain / Untitled_188.py
Created March 9, 2018 06:42
Untitled_188.py
import scene,ui,math
class MyScene(scene.Scene):
def update(self):
t=self.t
self.background_color = ((0.5*t)%1.,
math.sin(.5*t)+0.5,
math.sin(1/3.*t)**2,
1)
v=ui.View()
@jsbain
jsbain / Untitled_187.py
Created March 7, 2018 06:11
Untitled_187.py
from objc_util import *
import ctypes
app=UIApplication.sharedApplication()
#NSURL *url = [NSURL fileURLWithPath:@"/dev/null"];
url = nsurl('/dev/null')
import os
#url= nsurl(os.path.abspath('test.aac'))
settings=ns({ns('AVSampleRateKey'):ns(44100.0),
ns('AVFormatIDKey'): ns(1633772320),
@jsbain
jsbain / Untitled_187.py
Created March 7, 2018 06:01
Untitled_187.py
from objc_util import *
import ctypes
app=UIApplication.sharedApplication()
#NSURL *url = [NSURL fileURLWithPath:@"/dev/null"];
url = nsurl('/dev/null')
import os
#url= nsurl(os.path.abspath('test.aac'))
settings=ns({ns('AVSampleRateKey'):ns(44100.0),
ns('AVFormatIDKey'): ns(1633772320),
@jsbain
jsbain / Untitled.py
Created February 27, 2018 18:25
Untitled.py
from scene import *
class LogEntry(LabelNode):
def __init__(self,text):
LabelNode.__init__(self,text)
self.anchor_point=(0,0)
self.run_action(Action.sequence(Action.fade_to(0,1.5),Action.call(self.cull)))
def cull(self):
'''remove a log entry'''
self.remove_all_actions()
self.remove_from_parent()
@jsbain
jsbain / quickstart_web.py
Created February 14, 2018 09:16
quickstart_web.py
# -*- coding: utf-8 -*-
import os
import json
import flask
import google.oauth2.credentials
import google_auth_oauthlib.flow
import googleapiclient.discovery
@jsbain
jsbain / StatusBarOverlay.py
Created February 13, 2018 08:09
StatusBarOverlay.py
# coding: utf-8
''' Statusbarmenu
A menu that lives in the status bar
A set of tools to add or delete custom buttons from the toolbar. This may not be super robust, but seems to work ok. Button objects and actions are saved so they survive global clearing, but thid has not been tested extensively. If a function relies on imports that occured outside of the function, these might dissappear -- user must make sure those modules are added to a module that is kept by pythonista, such as anything in site-packages, or name starting with __ '''
from objc_util import *
import ui,console,editor
import weakref
from functools import partial
MARGIN=10
@jsbain
jsbain / StatusBarOverlay.py
Created January 23, 2018 09:18
StatusBarOverlay.py
# coding: utf-8
''' Statusbarmenu
A menu that lives in the status bar
A set of tools to add or delete custom buttons from the toolbar. This may not be super robust, but seems to work ok. Button objects and actions are saved so they survive global clearing, but thid has not been tested extensively. If a function relies on imports that occured outside of the function, these might dissappear -- user must make sure those modules are added to a module that is kept by pythonista, such as anything in site-packages, or name starting with __ '''
from objc_util import *
import ui,console,editor
import weakref
from functools import partial
MARGIN=10
@jsbain
jsbain / editor_buttons.py
Created January 1, 2018 15:42
editor_buttons.py
import sys,os
# if you place objc_hacks in site packages, this line is not needed
sys.path.append(os.path.expanduser('~/Documents'))
from objc_hacks import apphack
#alternatively, just place apphack.py in site_packages, and import apphack
#little workaround to persistent button locations. needs fixing in apphack
if hasattr(apphack,'__persistent_views'):
__builtins__.__persistent_views=apphack.__persistent_views