Skip to content

Instantly share code, notes, and snippets.

View brettkelly's full-sized avatar

Brett Kelly brettkelly

View GitHub Profile
import re
import urllib
reg = '[\&|\?]q=(?P<terms>[^\?\&$]+)'
rx = re.compile(reg)
tests = [
'http://www.evernote.com/about/kb/search?lang=en&q=test',
'http://www.evernote.com/about/kb/search?q=foo+bar&lang=en',
$(function(){
$("#apple").submit(
function(event){
var price = $("#app_price").val();
var units = $("#units").val();
$("#gross").val(price * units);
$("#loss").val(((price * units) * 0.3) + 99);
$("#output").val(((price * units) * 0.7) - 99);
}
);
@brettkelly
brettkelly / gist:806991
Created February 1, 2011 23:59
yt player thingie
var playerEmbedId = 'ytOverlayPlayer';
var playerTargetId = 'videoOverlayTarget';
var player = null;
var playerObj = null;
var QUERY_URL_BASE = 'http://www.youtube.com/v/';
jQuery.fn.apicenter = function () {
this.css("position","fixed");
this.css("top", ( $(window).scrollTop() + $(window).height() - this.height()-100 ) + "px");
@brettkelly
brettkelly / TextExpander.py
Created April 20, 2011 18:02
Select a random snippet and write it to STDOUT
#!/usr/bin/env python
import random, sys
# define our list of candidate snippets
s = ["%snippet:typo1%","%snippet:typo2%","%snippet:typo3%"]
# select one at random and write it to STDOUT
sys.stdout.write(random.choice(s))
This a message about typos.\n\nAnd it has multiple lines!
class ArticleFolderCollection(object):
"""A simple iterable collection for ArticleFolder objects"""
def __init__(self):
self.folders = []
def __iter__(self):
for f in self.folders:
yield f
def __contains__(self, folder):
class ArticleFolderCollection(object):
"""A simple iterable collection for ArticleFolder objects"""
def __init__(self):
self.folders = []
def __iter__(self):
for f in self.folders:
yield f
def __contains__(self, folder):
Help on package svn:
NAME
svn
FILE
/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/svn/__init__.py
DESCRIPTION
# __init__.py: defines this directory as the 'svn' package
@brettkelly
brettkelly / KindleEvernoteSync.py
Created July 29, 2011 18:22 — forked from jplattel/KindleEvernoteSync.py
Synchronize all your Kindle clippings and notes into Evernote
import os
import time
document = open("My Clippings.txt","r")
data = "".join(document.readlines())
notes = []
try:
clippings = data.split('==========')
for clip in clippings:
@brettkelly
brettkelly / GetMessageUrl
Created November 8, 2011 21:43
Get the message:// URL of the selected message in Mail.app
tell application "Mail"
set selectedMsgs to selection
repeat with theMsg in selectedMsgs
set message_url to "message://%3c" & (the message id of theMsg) & "%3e"
tell application "Finder"
set the clipboard to message_url as text
end tell
exit repeat -- leave the repeat loop after one pass
end repeat
end tell