Skip to content

Instantly share code, notes, and snippets.

@omz
omz / gist:1102091
Created July 24, 2011 01:40
Creating arbitrarily-colored icons from a black-with-alpha master image (iOS)
// Usage example:
// input image: http://f.cl.ly/items/3v0S3w2B3N0p3e0I082d/Image%202011.07.22%2011:29:25%20PM.png
//
// UIImage *buttonImage = [UIImage ipMaskedImageNamed:@"UIButtonBarAction.png" color:[UIColor redColor]];
// .h
@interface UIImage (IPImageUtils)
+ (UIImage *)ipMaskedImageNamed:(NSString *)name color:(UIColor *)color;
@end
@omz
omz / gist:2134449
Created March 20, 2012 11:52
Highlighter plain text format
FooBar.pdf
================================================================================
p. 4 | highlight | yellow
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis
nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim id est laborum.
@omz
omz / FileTransfer.py
Last active August 8, 2023 14:44
File Transfer script for Pythonista (iOS)
# File Transfer for Pythonista
# ============================
# This script allows you to transfer Python files from
# and to Pythonista via local Wifi.
# It starts a basic HTTP server that you can access
# as a web page from your browser.
# When you upload a file that already exists, it is
# renamed automatically.
# From Pythonista's settings, you can add this script
# to the actions menu of the editor for quick access.
@omz
omz / GoogleSearch.py
Created October 17, 2012 22:45
GoogleSearch
# Google Search for Pythonista (iOS)
# Searches Google and copies the first result to the clipboard as
# a Markdown link in the form [title](url).
#
# Inspired by Brett Terpstra's SearchLink:
# http://brettterpstra.com/searchlink-automated-markdown-linking-improved/
import clipboard
def google(terms):
@omz
omz / Top Apps.py
Created November 7, 2012 20:54
Top Apps
# Shows a list of the 10 top paid apps on the App Store.
print 'Loading...'
import feedparser
import console
print 'Fetching Feed...'
feed = feedparser.parse('http://itunes.apple.com/us/rss/toppaidapplications/limit=10/xml')
entries = feed['entries']
@omz
omz / Meme Generator 1.py
Created November 7, 2012 21:00
Meme Generator 1
# Meme Generator 1
# Demonstrates how to draw text on images using PIL
# (Python Imaging Library)
#
# The script loads an image from the clipboard (or uses
# a default one if the clipboard is empty) and asks for
# two captions (top and bottom) that are then drawn onto
# the image.
import Image
@omz
omz / Meme Generator 2.py
Created November 7, 2012 21:01
Meme Generator 2
import Image
import ImageChops
import ImageDraw
import ImageFont
import ImageFilter
import clipboard
def draw_caption(img, text, outline=2, top=False):
text_img = Image.new('RGBA', img.size, (0, 0, 0, 0))
draw = ImageDraw.Draw(text_img)
@omz
omz / Drum Machine.py
Created November 7, 2012 21:03
Drum Machine
#TODO: Adjust size to screen size (iPhone)
#TODO: Clear (and random, play/pause?) buttons
from scene import *
from sound import play_effect, set_volume, load_effect
from colorsys import hsv_to_rgb
import pickle
class DrumMachine (Scene):
def setup(self):
@omz
omz / dropboxlogin.py
Created November 7, 2012 21:16
dropboxlogin
# YOU NEED TO INSERT YOUR APP KEY AND SECRET BELOW!
# Go to dropbox.com/developers/apps to create an app.
app_key = 'YOUR_APP_KEY'
app_secret = 'YOUR_APP_SECRET'
# access_type can be 'app_folder' or 'dropbox', depending on
# how you registered your app.
access_type = 'app_folder'
@omz
omz / SpaceShooter.py
Created November 10, 2012 12:32
SpaceShooter
from scene import *
from random import randint, random, choice
from sound import play_effect
from colorsys import hsv_to_rgb
from math import sin
from functools import partial
from copy import copy
class Star (object):
def __init__(self):