Skip to content

Instantly share code, notes, and snippets.

Matthew Schinckel schinckel

View GitHub Profile
View textmate_environment_variables.rb
#!/usr/bin/env ruby
###############################################################
#
# Paste this into a TextMate document,
# press ⇧^⌥R and choose 'Ruby' from the menu that appears,
# and then press ⌘R to run this in the context of TextMate
# to see all TextMate environment variables and their values
#
###############################################################
View textmate_environment_variables.rb
#!/usr/bin/env ruby
###############################################################
#
# Paste this into a TextMate document,
# press ⇧^⌥R and choose 'Ruby' from the menu that appears,
# and then press ⌘R to run this in the context of TextMate
# to see all TextMate environment variables and their values
#
###############################################################
@schinckel
schinckel / data.sql
Created Feb 22, 2015
Ten pin bowling score calculation
View data.sql
-- Game 1
INSERT INTO bowling.frame VALUES
(1, 1, 1, 7, 2, NULL),
(1, 1, 2, 3, 7, NULL),
(1, 1, 3, 6, 4, NULL),
(1, 1, 4, 10, NULL, NULL),
(1, 1, 5, 10, NULL, NULL),
(1, 1, 6, 10, NULL, NULL),
(1, 1, 7, 9, 1, NULL),
(1, 1, 8, 10, NULL, NULL),
View Boiled Chocolate Cake
Boil together:
* 125g butter
* 1 cup water
* 1 1/2 cups sugar
* 2 tablespoons cocoa
* 1/2 teaspon bicarb soda
Simmer 5 mins.
@schinckel
schinckel / install.sh
Last active Aug 9, 2017 — forked from bradrydzewski/install.sh
Drone.io Install Postgres9.4
View install.sh
#!/bin/bash
# remove existing 9.3 installation
sudo /etc/init.d/postgresql stop
sudo apt-get --force-yes -fuy remove --purge postgresql postgresql-9.1 postgresql-client
# install 9.4
sudo apt-get install python-software-properties
sudo add-apt-repository 'deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main 9.4'
sudo apt-get update
View get-django-view-class
from django.views.generic.base import View
def get_class(func):
if not getattr(func, 'func_closure', None):
return
for closure in func.func_closure:
contents = closure.cell_contents
if not contents:
@schinckel
schinckel / selectable.js
Created Apr 2, 2013
Knockout extension: selectable observableArray
View selectable.js
/*
Provide an observableArray with some smarts related to selection
of an item, or items within it.
If 'multiple' is passed in, then it is a multiply selectable
array, and has two new attributes: ``selectedItems`` and ``selectedIndexes``.
If 'multiple' is not passed in, then it new attributes of
``selectedItem`` and ``selectedIndex`` are created.
@schinckel
schinckel / increment_tcx_dates.py
Created May 22, 2012
Increment all of the dates within a TCX file by a certain amount.
View increment_tcx_dates.py
import re
import datetime
time_re = re.compile('(?P<dt>\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2})')
offset = datetime.timedelta(minutes=5,seconds=1)
for line in lines:
if time_re.search(line):
time = datetime.datetime.strptime(time_re.search(line).groupdict()['dt'], "%Y-%m-%dT%H:%M:%S")
time = time + offset
@schinckel
schinckel / test_ouput
Created Mar 21, 2012 — forked from chronossc/test_ouput
Tests with models.
View test_ouput
(github_projects_2)felipe@felipe-G51JX:~/projects/github_projects_2/clones/django-object-config/sample_project$ m test object_config --failfast --noinput
Creating test database for alias 'default'...
E
======================================================================
ERROR: test_option_create_many (object_config.tests.OptionsTest)
Test many items creation
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/felipe/projects/github_projects_2/clones/django-object-config/sample_project/object_config/tests.py", line 27, in setUp
self.model = MyModel.objects.create(name='test 1')
@schinckel
schinckel / jquery.couch.longpoll.js
Created Jan 22, 2012
Long-polling handler for CouchDB
View jquery.couch.longpoll.js
/*
# jquery.couch.longpoll.js #
A handler that can be used to listen to changes from a CouchDB database,
using long-polling.
This seemed to be a bit simpler than using continuous polling, which I
was unable to get working with jQuery.
You can’t perform that action at this time.