Skip to content

Instantly share code, notes, and snippets.

@cspickert
cspickert / chromeforacause.scpt
Created December 17, 2010 21:25
A simple AppleScript for use with Chrome for Mac and the Chrome for a Cause extension.
-------------------------------------------------------------------------------
-- This is a simple AppleScript for use with Google Chrome (Chrome.app) and the
-- [Chrome for a Cause extension](http://bit.ly/gU4eQS). It will open a new tab
-- and then close it after a 1 second delay 250 times (the daily limit for the
-- extension). See the instructions below to use.
--
-- From AppleScript Editor:
--
-- 1. Open AppleScript Editor (/Applications/Utilities/AppleScript Editor.app).
-- 2. Copy this script into the text window and click Run.
@cspickert
cspickert / Sticky.py
Created February 20, 2011 22:18
A PyObjC StickiesDatabase reader.
from Foundation import *
from AppKit import NSAttributedString
import os
class Sticky(NSObject):
"""A Stickies document.
Attributes (from class dump):
int windowColor
int windowFlags
@cspickert
cspickert / ABGitConfig.py
Created March 18, 2011 00:19
A short PyObjC script to set git-config user parameters via the Address Book Framework.
#!/usr/bin/python
from objc import YES, NO, NULL
from Foundation import *
from AddressBook import *
import os
# Set the path to git
GIT = "/usr/local/bin/git"
@cspickert
cspickert / GenModelStrings.py
Created April 8, 2011 22:03
Additions to NSEntityDescription and NSPropertyDescription allowing access to their localized names in an NSManagedObjectModel's -localizationDictionary. Localization dictionary key reference: http://bit.ly/e9O8RK
#
# A short script to generate a xxModel.strings for a given xx.xcdatamodel file.
#
from objc import YES, NO, NULL
from Foundation import *
from CoreData import NSManagedObjectModel
from os import popen as system, rmdir, remove
from optparse import OptionParser
from tempfile import mkdtemp
import sys
@cspickert
cspickert / UIView+UIImageCreation.m
Created August 30, 2011 20:28
Create a UIImage from a UIView
@interface UIView (UIImageCreation)
- (UIImage *)createImageFromRect:(CGRect)frame;
- (UIImage *)createImage;
@end
@implementation UIView (UIImageCreation)
- (UIImage *)createImageFromRect:(CGRect)frame
@cspickert
cspickert / sudo_install.sh
Created September 8, 2011 20:04
How to run Installer.app as root in Mac OS X
sudo /System/Library/CoreServices/Installer.app/Contents/MacOS/Installer
@cspickert
cspickert / oplop.py
Created October 3, 2011 14:22
An implementation of the Oplop password hashing algorithm in Python.
#!/usr/bin/env python
"""Generate a password using the Oplop password hashing algorithm.
For more information: http://code.google.com/p/oplop/wiki/HowItWorks"""
from sys import argv, stdout
from hashlib import md5
from base64 import urlsafe_b64encode as b64
import re
@cspickert
cspickert / v8cgi-brew-error-1.txt
Created November 20, 2011 15:11
Homebrew install error: v8cgi (November 20, 2011)
==> Checking out http://v8cgi.googlecode.com/svn/trunk/
/usr/bin/svn up --force /Users/cameron/Library/Caches/Homebrew/v8cgi--svn
At revision 934.
/usr/bin/svn export --force /Users/cameron/Library/Caches/Homebrew/v8cgi--svn /private/tmp/homebrew-v8cgi-HEAD-Xywf
Export complete.
==> scons -j 4 arch=x64 library=shared socket=1 process=1 cgi=1 mysql=0 gl=0 module=0 config_file=/usr/local/etc/v8cgi.conf v8_path=/usr/local/Cellar/v8/HEAD dom=0 gd=0 sqlite=0
scons -j 4 arch=x64 library=shared socket=1 process=1 cgi=1 mysql=0 gl=0 module=0 config_file=/usr/local/etc/v8cgi.conf v8_path=/usr/local/Cellar/v8/HEAD dom=0 gd=0 sqlite=0
scons: Reading SConscript files ...
Checking for C header file sys/mman.h... yes
Checking for C function sleep()... yes
@cspickert
cspickert / GoogleSpreadsheets.py
Created January 20, 2012 23:40
Export a Google Spreadsheet using python.
#!/usr/bin/python
import re, urllib, urllib2
class Spreadsheet(object):
def __init__(self, key):
super(Spreadsheet, self).__init__()
self.key = key
class Client(object):
@cspickert
cspickert / subclass.js
Created February 14, 2012 14:32
How to subclass in JS
// Source: http://www.golimojo.com/etc/js-subclass.html
function subclass(constructor, superConstructor)
{
function surrogateConstructor()
{
}
surrogateConstructor.prototype = superConstructor.prototype;