Skip to content

Instantly share code, notes, and snippets.

View schinckel's full-sized avatar

Matthew Schinckel schinckel

View GitHub Profile
schinckel / jekyllmarkdown.rb
Created January 9, 2012 14:26
Jekyll renderer for
View jekyllmarkdown.rb
# Github-flavored markdown to HTML, in a command-line util.
# $ cat | ./ghmarkdown.rb
# Notes:
# You will need to install Pygments for syntax coloring
# $ pip install pygments
schinckel / LICENSE
Last active December 13, 2015 22:30
Copyright (c) 2012, Matthew Schinckel.
All rights reserved.
Based on an algorithm at
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
View gist:1591723
class MyModel(models.Model):
def save(self, *args, **kwargs):
old_version = self.__class__.objects.get(
# Now we have self and old_version, which are different
# instances of the same object.
if old_version.foo_field != self.foo_field:
# foo_field is changed, do stuff.
super(MyModel, self).save(*args, **kwargs)
schinckel / file.plist
Created January 11, 2012 10:19
Jekyll Syntax Grammar for TextMate
View file.plist
{ patterns = (
{ begin = '(---[ ]*\n)';
end = '(---[ ]*\n)';
name = 'source.yaml.header.markdown.jekyll';
patterns = ( { include = 'source.yaml'; } );
{ begin = '\{% +highlight +(js)( +linenos)? +%\}';
end = '\{% +endhighlight +%\}\n';
name = 'source.$1.embedded.html.markdown';
patterns = ( { include = 'source.js'; } );
schinckel / jquery.couch.longpoll.js
Created January 22, 2012 11:29
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.
schinckel / test_ouput
Created March 21, 2012 01:08 — 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'...
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/", line 27, in setUp
self.model = MyModel.objects.create(name='test 1')
schinckel /
Created May 22, 2012 12:37
Increment all of the dates within a TCX file by a certain amount.
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:
time = datetime.datetime.strptime(['dt'], "%Y-%m-%dT%H:%M:%S")
time = time + offset
schinckel / selectable.js
Created April 2, 2013 11:39
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.
View get-django-view-class
from django.views.generic.base import View
def get_class(func):
if not getattr(func, 'func_closure', None):
for closure in func.func_closure:
contents = closure.cell_contents
if not contents:
schinckel /
Last active August 9, 2017 18:01 — forked from bradrydzewski/ Install Postgres9.4
# 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 precise-pgdg main 9.4'
sudo apt-get update