Skip to content

Instantly share code, notes, and snippets.

create table mydata_real (id serial, date date, value text);
create table mydata_real_y2015 (check (date >= '2015-01-01' and date < '2016-01-01')) inherits (mydata_real);
create table mydata_real_y2016 (check (date >= '2016-01-01' and date < '2017-01-01')) inherits (mydata_real);
create function mydata_nope() returns trigger language plpgsql
as $f$ begin raise exception 'insert on wrong table'; return NULL; end; $f$;
create trigger mydata_nope before insert on mydata_real execute procedure mydata_nope();
create view mydata as select * from mydata_real;
@mattdeboard
mattdeboard / .bash_profile
Created November 16, 2015 20:06 — forked from fieg/.bash_profile
.bash_profile for OSX including autocomplete for ssh hosts, default variables and some aliases
_complete_ssh_hosts ()
{
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
comp_ssh_hosts=`cat ~/.ssh/known_hosts | \
cut -f 1 -d ' ' | \
sed -e s/,.*//g | \
grep -v ^# | \
uniq | \
grep -v "\[" ;
class JsonSerializableMixin(object):
def __json__(self):
"""
Converts all the properties of the object into a dict for use in json.
You can define the following in your class
_json_eager_load :
list of which child classes need to be eagerly loaded. This applies
to one-to-many relationships defined in SQLAlchemy classes.
# example location parts of nginx.conf
# add your own AWS keys, server lines etc, and set your aws domains, paths
http {
# you will need the luacrypto in the cpath, download from http://luacrypto.luaforge.net/
lua_package_cpath "/home/justin/lua/luacrypto-0.2.0/src/l?.so.0.2.0;;";
server {
listen 80;
@mattdeboard
mattdeboard / nginx.conf
Created December 9, 2012 21:08 — forked from justincormack/nginx.conf
Using Lua and Nginx to proxy Amazon web services example
# example location parts of nginx.conf
# add your own AWS keys, server lines etc, and set your aws domains, paths
http {
# you will need the luacrypto in the cpath, download from http://luacrypto.luaforge.net/
lua_package_cpath "/home/justin/lua/luacrypto-0.2.0/src/l?.so.0.2.0;;";
server {
listen 80;
import operator
from haystack.query import SearchQuerySet, SQ
stuff = ['foo', 'bar', 'baz']
the_filters = reduce(operator.or_, [SQ(tag=tag_name) for tag_name in stuff])
sqs = SearchQuerySet().filter(the_filters)
from seo.models import jobListing
from directseo.serializers import XMLExtraSerializer
def get_data_from_xmlextraserializer():
host = 'find.ibm.jobs'
jobs = jobListing.objects.filter(buid__id=2432,country_short='MEX')
s = XMLExtraSerializer([{'name':'url', 'type':'CharField'}])
@mattdeboard
mattdeboard / spotify.el
Created August 6, 2011 23:05
Small minor mode to control spotify from emacs
;;Small minor mode to control spotify from emacs
(defun spotify-play () "Play Spotify" (interactive)
(shell-command "dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Play"))
(defun spotify-pause () "Pause Spotify" (interactive)
(shell-command "dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Pause"))
(defun spotify-playpause () "Play/Pause Spotify" (interactive)
(shell-command "dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause"))
def foo():
for x in range(5):
yield x
yield x*2
(letfn [(first [x]
(lazy-seq
(when (<= x 5)
(cons x (second x)))))
(second [x]