Skip to content

Instantly share code, notes, and snippets.

View pkqk's full-sized avatar
📯
💨 🎶 🎵 🎶

Adam Sven Johnson pkqk

📯
💨 🎶 🎵 🎶
View GitHub Profile
@pkqk
pkqk / tug-o-war.sh
Last active August 29, 2015 14:17
pull all the repos
# for each match that is a directory with a git repo in it
for dir in */.git
do
# change into directory
# dirname gets rid of the .git
# quotes around $dir in case a name with spaces comes along
pushd `dirname "$dir"`
# fetch new updates
# but only pull them into your branch if you haven't changed anything
git fetch && git pull --ff-only

Keybase proof

I hereby claim:

  • I am pkqk on github.
  • I am pkqk (https://keybase.io/pkqk) on keybase.
  • I have a public key whose fingerprint is 3B93 48C9 29A5 3871 B646 3902 1261 8403 E5AF 379E

To claim this, I am signing this object:

function timeout(callback, wait) {
var cancel = window.setTimeout(callback, wait);
return function() {
window.clearTimeout(cancel);
}
}
cancel_the_timeout = timeout(function() { alert("hi") }, 3600);
cancel_the_timeout();
@pkqk
pkqk / Rakefile
Created October 28, 2013 15:29
how to do an rspec, put your specs in spec/*_spec.rb and put this in your Rakefile then you can `rake spec` to run them
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec) do |task|
task.pattern = "spec/**/*_spec.rb"
end
@pkqk
pkqk / uniq.py
Last active December 25, 2015 09:29 — forked from ntlk/uniq.py
import sys
def process_lines(lines):
last_line = None
for line in lines:
if line != last_line:
sys.stdout.write(line)
last_line = line
process_lines(sys.stdin.readlines())
cocktails = [
(1, 'This is a name'),
(2, 'The beauty beneath'),
(3, 'woo woo'),
(4, 'martinez'),
(5, 'the crow cocktail'),
(6, 'charlie chaplain cocktail'),
(7, 'gin n it')
]
@pkqk
pkqk / database.yml
Created June 11, 2013 16:11
use a database based on branch name then when you make a new branch rake db:{create,migrate,seed}
database: &database
adapter: # your database
hostname: localhost
username: root
password:
encoding: utf8
development:
<<: *database
<% branch_name = `git symbolic-ref HEAD`.strip.split('/')[-1] %>
@pkqk
pkqk / inheritance.py
Created November 15, 2012 13:10
python class inheritance
class User(object):
def __init__(self, email, password, brands, dashboardbrands, allBrands, active=True):
self.email = email
self.password = password
self.brands = brands
self.dashboardbrands = dashboardbrands
self.allBrands = allBrands
self.active = active
class NormalUser(User):
@pkqk
pkqk / unicodecsv.py
Created November 6, 2012 18:05
Unicode safe extension to csv.DictReader
"""
Safely deal with unicode(utf-8) in csv files
removing nasty BOM surprises
"""
import csv
import codecs
@pkqk
pkqk / models.py
Created May 24, 2012 22:16
chained model filters example
# an attempt to make filter, exclude, chainable
# based on: http://zmsmith.com/2010/04/using-custom-django-querysets/
# https://code.djangoproject.com/ticket/16748
# http://djangosnippets.org/snippets/734/
from django.db import models
from django.db.models.query import QuerySet
from datetime import date, timedelta