Skip to content

Instantly share code, notes, and snippets.

View maddievision's full-sized avatar
always sparkly

maddie lim ✨ maddievision

always sparkly
View GitHub Profile
@maddievision
maddievision / gistget.py
Created February 23, 2013 12:22
Gist Getter for Pythonista
# Will prompt a URL to grab gist files, it will pre-populate with current clipboard contents.
# You can also just enter the gist ID by itself.
# Will write each file by its filename
import sys
import requests
import os
import console
import clipboard
import json
@maddievision
maddievision / au.py
Last active December 14, 2015 03:29
concept au python library
from coreaudio import Session
from ctypes import int16
from audiounit import Graph, Unit
from coremidi import MusicPlayer
graph = Graph({ "sample_rate": 44100, "channels": 2, "format": int16 })
mixer = Unit("Mixer")
graph.add(mixer)
sampler1 = Unit("AUSampler")
sampler2 = Unit("AUSampler")
@maddievision
maddievision / paste.diff
Created February 24, 2013 22:23
Full song copy/paste
Index: OpenMPT/mptrack/CommandSet.cpp
===================================================================
--- OpenMPT/mptrack/CommandSet.cpp (revision 1533)
+++ OpenMPT/mptrack/CommandSet.cpp (working copy)
@@ -650,6 +650,8 @@
DefineKeyCommand(kcToggleNoteOffRecordPC, 1895, _T("Toggle Note Off record (PC keyboard)"));
DefineKeyCommand(kcToggleNoteOffRecordMIDI, 1896, _T("Toggle Note Off record (MIDI)"));
DefineKeyCommand(kcFindInstrument, 1897, _T("Pick up nearest instrument number"));
+ DefineKeyCommand(kcEditCopyAllPatterns, 1898, _T("Copy Song"));
+ DefineKeyCommand(kcEditPasteAllPatterns, 1899, _T("Paste Song"));
@maddievision
maddievision / Drafts.py
Created March 4, 2013 02:41
Very simple wrapper for Drafts URL scheme for Pythonista http://omz-software.com/pythonista
import urllib
import webbrowser
URL_BASE = "drafts://x-callback-url/create?"
CALLBACK_URL_BASE = "pythonista://"
def do_action(actiontype,txt,cb=CALLBACK_URL_BASE):
surl = URL_BASE + 'text=' + urllib.quote(txt) + '&action=' + urllib.quote(actiontype) + '&x-success=' + urllib.quote(cb)
webbrowser.open(surl)
print "Action Complete"
def message(txt,cb=CALLBACK_URL_BASE):
do_action('Message',txt,cb)
@maddievision
maddievision / callback.md
Last active August 8, 2023 14:43
callback - A simple small module for Pythonista (http://omz-software.com/pythonista) which aims to make an easy callback URL handling & argument passing system.

callback

A simple small module for Pythonista (http://omz-software.com/pythonista) which aims to make an easy callback URL handling & argument passing system.

Usage

  1. import callback
  2. Create a handler instance handler = callback.InfoHandler(sys.argv)
  3. Decorate command handlers with @handler.cmd(cmdname)
  4. Call handler.handle() (and if it returns False, there was nothing to handle!)
@maddievision
maddievision / TweetBot.py
Created March 4, 2013 03:41
Very simple wrapper for TweetBot URL scheme for Pythonista http://omz-software.com/pythonista
import urllib
import webbrowser
CALLBACK_URL_BASE = 'pythonista://'
url = "tweetbot://x-callback-url/post?"
def tweet(txt,cb=CALLBACK_URL_BASE):
data = {
'text': txt,
'callback_url': cb
}
@maddievision
maddievision / TestTableViewController.py
Last active December 14, 2015 11:38
"thinking out loud" again.. a concept iOS Table View Controller in Python
import UIKit
from NSFoundation import IndexPath
class TestTableViewController(UIKit.TableViewController):
def __init__(self):
super.__init__(self)
#do stuff
self.storage = [1,2,3,4,5]
self.title = "Test Data"
add_button = UIKit.BarButtonItem.system_button(UIKit.BAR_BUTTON_ADD_ITEM,handler=on_add_button)
@maddievision
maddievision / app.py
Last active December 14, 2015 13:28
idealised conceptual iOS python app. again (not complete)
import pyios
import helpers
from boxcore import Session, Playlist
class BoxListView(pyios.TableView):
def __init__(self,session):
super(BoxListView,self).__init__(self)
self.session = session
self.title = "Box Play"
self.show_edit_button = True
@maddievision
maddievision / join.py
Last active December 14, 2015 15:08
join with outer join support
def join(t,col,rt,rcol=None,outer=False):
if not rcol:
rcol = col
for entry in t:
matches = [d for d in rt if d[rcol] == entry[col]]
for match in matches:
yield entry,match
if len(matches) == 0 and outer:
yield entry,None
@maddievision
maddievision / gist:5243396
Created March 26, 2013 05:40
more fantasy land
LISP
(defun lazy-mapcan (fun lst)
(labels ((f (lst-cur)
(if (lazy-null lst-cur)
(force (lazy-mapcan fun (lazy-cdr lst)))
(cons (lazy-car lst-cur) (lazy (f (lazy-cdr lst-cur)))))))
(lazy (unless (lazy-null lst)
(f (funcall fun (lazy-car lst)))))))
1 (semi-compact)