This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os, cmd, sys, re, glob, os.path, shutil, zipfile, tarfile, gzip, string, urllib2, ui | |
# Credits | |
# | |
# The python code here was written by pudquick@github | |
# | |
# License | |
# | |
# This code is released under a standard MIT license. | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Source: https://gist.github.com/5212628 | |
# | |
# All-purpose gist tool for Pythonista. | |
# | |
# When run directly, this script sets up four other scripts that call various | |
# functions within this file. Each of these sub-scripts are meant for use as | |
# action menu items. They are: | |
# | |
# Set Gist ID.py - Set the gist id that the current file should be | |
# associated with. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
""" | |
Created on Sat Jul 12 09:33:29 2014 | |
@author: henryiii | |
""" | |
import random | |
import numpy as np | |
from functools import partial |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
""" | |
Created on Sat Jul 12 09:33:29 2014 | |
@author: henryiii | |
""" | |
import random | |
import numpy as np | |
import ui |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime, logging | |
def elapsed_datetime(start_datetime, end_datetime = datetime.datetime.now()): | |
return end_datetime - start_datetime # returns a datetime.timedelta | |
def find_day(days_on_earth, ref_datetime=datetime.datetime(2014,8,23), ref_is_start=True): | |
'''find day (datetime obj) corresponding to days_on_earth, tuple of days, hours, min, sec. | |
ref_is_start == True means ref date is start, return end date. itherwise, return start date given this end date | |
''' | |
dt=datetime.timedelta(**dict(zip(['days','hours','minutes','seconds'],days_on_earth))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pipista v2, by pudquick, updated for pythonista 1.5 by jsbain | |
# todo: consolidate unzip, ungzip, unbzip, and untar. tarfile supports compressed archives, so can use that directly. use is_zipfile, is_tarfile rather than magic packet stuff. there is a lot of duplicate code elsewhere that should be modularized | |
# 2) option to use site-packages rather than pypi-modules | |
# 3) make sure to cleanup .tmp on errors. | |
import os, os.path, sys, urllib2, requests, tempfile, zipfile, shutil, gzip, tarfile, xmlrpclib, ConfigParser | |
__pypi_base__ = os.path.abspath(os.path.dirname(__file__)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as N | |
import wave, sound, os, ui | |
def get_signal_data(frequency=440, duration=1, volume=32767, samplerate=44100): | |
"""Outputs a numpy array of intensities""" | |
samples = duration * samplerate | |
period = samplerate / float(frequency) | |
omega = N.pi * 2 / period | |
t = N.arange(samples, dtype=N.float) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import notification, uuid, sys | |
def reminder(message, delay=3600*24, uid=None, | |
sound_name='default', | |
action=None, action_args=(), | |
interval=3600, | |
num_reminders=5): | |
''' call a script after a delay, and keep reminding until the notification is acknowledged. | |
uses a uid to access all instances of this reminder, for deleting or finding when the next instance is scheduled. | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import threading | |
class propertyListener(threading.Thread): | |
'''create a listener on one or more of a view's properties, and dispatches a callback whenever those properties change. | |
NOTE: it is highly recommended that the propertyListener instance is part of s custom view class, and in that class's will_close method, call stop() on the instance. otherwise, it will continue to poll even after the view is closed, and could cause problems later. | |
cosntructor args: | |
view - the view to watch | |
propertylist - list of properties to watch. must be a list even if only one prop, e.g ['frame'] | |
action the callback to call. the function should be of the following form |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ui | |
class TabbedView(ui.View): | |
def __init__(self,tablist=[], frame=(0,0)+ui.get_screen_size()): | |
'''takes an iterable of Views, using the view name as the tab selector. | |
empty views sre just given generic names''' | |
self.tabcounter=0 #unique counter, for name disambiguation | |
self.buttonheight=30 #height of buttonbar | |
#setup button bar | |
self.tabbuttons=ui.SegmentedControl(frame=(0,0,self.width, self.buttonheight)) | |
self.tabbuttons.action=self.tab_action |
OlderNewer