This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
# Github-flavored markdown to HTML, in a command-line util. | |
# | |
# $ cat README.md | ./ghmarkdown.rb | |
# | |
# Notes: | |
# | |
# You will need to install Pygments for syntax coloring | |
# | |
# $ pip install pygments |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Copyright (c) 2012, Matthew Schinckel. | |
All rights reserved. | |
Based on an algorithm at http://jsres.blogspot.com.au/2008/01/convert-hsv-to-rgb-equivalent.html | |
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyModel(models.Model): | |
... | |
def save(self, *args, **kwargs): | |
if self.pk: | |
old_version = self.__class__.objects.get(pk=self.pk) | |
# 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ 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'; } ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
# 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
OlderNewer