Skip to content

Instantly share code, notes, and snippets.

View brettkelly's full-sized avatar

Brett Kelly brettkelly

View GitHub Profile
$(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 / DeleteAddressBookBirthdays.scpt
Created November 11, 2011 23:33
Delete Selected Birthdays from Address Book
(*
Brett Kelly wrote this.
http://nerdgap.com
*)
tell application "Address Book"
-- init our lists of stuff
set peeps to every person
set bdays to {}
set bdaynames to {}
@brettkelly
brettkelly / gist:1419008
Created December 1, 2011 18:59
norcross
select uniqueids from downloadkeys
where timestamp in
(select timestamp from downloadkeys order by timestamp desc limit 10)
order by timestamp desc