Skip to content

Instantly share code, notes, and snippets.

View controversial's full-sized avatar
🧙‍♂️
doing magic

Luke Deen Taylor controversial

🧙‍♂️
doing magic
View GitHub Profile
@controversial
controversial / YoutubePiP.py
Created September 20, 2015 17:46
YoutubePiP.py
import appex, bs4, dialogs, urllib2, webbrowser
if appex.is_running_extension():
starturl = appex.get_url()
else:
#ask for video url
starturl = dialogs.form_dialog(fields=[{'type':'url', 'title':'URL:', 'key':'url'}])['url']
#handle redirects, in case of shortened url
url = urllib2.urlopen(urllib2.Request(starturl)).geturl()
#keepvid page url
url = 'http://www.keepvid.com/?url='+url.split('&feature')[0]
@jsbain
jsbain / canvas_save.py
Created January 24, 2016 07:44
canvas_save.py
# coding: utf-8
from objc_util import *
import canvas
import os
def save_canvas_to_png(filename):
rootVC = UIApplication.sharedApplication().keyWindow().rootViewController()
image=rootVC.accessoryViewController().consoleViewController().canvasImageView().image()
if image:
data=ObjCInstance(c.UIImagePNGRepresentation(image))
data.writeToFile_atomically_(os.path.abspath(filename),True)
@jsbain
jsbain / notificationplayground.py
Created January 26, 2016 08:50
notificationplayground.py
# coding: utf-8
#. objc from http://www.thinkandbuild.it/interactive-notifications-with-notification-actions/
from objc_util import *
UIUserNotificationSetting = ObjCClass('UIUserNotificationSettings')
UIMutableUserNotificationCategory = ObjCClass('UIMutableUserNotificationCategory')
UIMutableUserNotificationAction = ObjCClass('UIMutableUserNotificationAction')
UIUserNotificationSettings = ObjCClass('UIUserNotificationSettings')
UILocalNotification = ObjCClass('UILocalNotification')
anonymous
anonymous / bf.py
Created October 14, 2016 03:05
Lambda.
next(_for y in [__import__('sys')] for _ in [y.setrecursionlimit(10000)] for m in [__import__('msvcrt')] for p in [lambda *s:[y.stdout.write(str(_)) for _ in s]] for h in [lambda s,i:next(_ for _ in [s.m.pop(str(s.k)),s.m.setdefault(str(s.k),i)])] for j in [lambda s,i:next(_ for o in [s.m[str(s.k)]+i] for _ in [h(s,o)])] for e in [lambda s,i:next(_ for _ in [s.n[str(s.l)].pop('p'),s.n[str(s.l)].setdefault('p',i)])] for t in [lambda s,a,v:setattr(s,a,v)] for z in [lambda s,a,v:t(s,a,getattr(s,a)+v)] for w in [lambda:next(_ for _ in [p('ERROR!'),y.exit(1)])] for b in [open(y.argv[1],"r") if len(y.argv)>1 else w()] for _ in [type('',(),{'__init__':lambda s:next(_for _ in [t(s,'c',"".join(["".join(c) for c in b.readlines()])),b.close(),t(s,'e',1),t(s,'i',len(s.c)),t(s,'p',0),t(s,'k',0),t(s,'m',{str(i):0 for i in range(5000)}),t(s,'d',1),t(s,'l',0),t(s,'n',{str(i):{'p':0} for i in range(5000)}),s._()]),'_':lambda s:next(_for c in [s.c[s.p]]for _ in [[h(s,ord(m.getch())),z(s,'p',1),t(s,'d',0)] if c==',' else None,[
@jsbain
jsbain / add_action.py
Last active December 9, 2016 06:21
add_action.py
# coding: utf-8
'''
Manipulate action (wrench) menu
example:
add_action('/stash/launch_stash.py','monitor')
save_defaults() # so it is stored for next launch
'''
from objc_util import *
@BenjyWiener
BenjyWiener / ReplayKit.py
Last active September 7, 2017 04:34
ReplayKit.py
# coding: utf-8
from objc_util import *
from Foundation import NSBundle
NSBundle.bundleWithPath_('/System/Library/Frameworks/ReplayKit.framework').load()
RPScreenRecorder = ObjCClass('RPScreenRecorder')
@omz
omz / Map View Demo.py
Created July 28, 2015 21:36
Map View Demo.py
# coding: utf-8
'''
NOTE: This requires the latest beta of Pythonista 1.6 (build 160022)
Demo of a custom ui.View subclass that embeds a native map view using MapKit (via objc_util). Tap and hold the map to drop a pin.
The MapView class is designed to be reusable, but it doesn't implement *everything* you might need. I hope that the existing methods give you a basic idea of how to add new capabilities though. For reference, here's Apple's documentation about the underlying MKMapView class: http://developer.apple.com/library/ios/documentation/MapKit/reference/MKMapView_Class/index.html
If you make any changes to the OMMapViewDelegate class, you need to restart the app. Because this requires creating a new Objective-C class, the code can basically only run once per session (it's not safe to delete an Objective-C class at runtime as long as instances of the class potentially exist).
'''

Titles from the MoMA

(As generated by an AI)

Imperial Ornament From the Gifted, 1967-78
Whisper From the Portfolio Projects, May 16, 1994
Lines at the Root of the Ballet (c. 1934)
Man with Four Bosses (January 25-28, 1963)
The Owls and Floating Graduation (August 12-13, 1965)
Reclining Corners, 10 April 1989

@RubaXa
RubaXa / index.html
Created December 12, 2017 06:36
Repaint: offsetWidth vs. getBoundingClientRect (http://jsbench.github.io/#aed00af2bf5a7393a934c517018060b9) #jsbench #jsperf
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Repaint: offsetWidth vs. getBoundingClientRect</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
@steventroughtonsmith
steventroughtonsmith / main.m
Created March 24, 2016 08:08
Load Mach-O executable at runtime and execute its entry point
void callEntryPointOfImage(char *path, int argc, char **argv)
{
void *handle;
int (*binary_main)(int binary_argc, char **binary_argv);
char *error;
int err = 0;
printf("Loading %s\n", path);
handle = dlopen (path, RTLD_LAZY);