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
DROP FUNCTION IF EXISTS get_role_to_actor_and_actor_to_role( INOUT BIGINT, OUT JSONB, OUT JSONB ); | |
CREATE OR REPLACE FUNCTION get_role_to_actor_and_actor_to_role( | |
INOUT program_id BIGINT, | |
OUT actor_to_role JSONB, | |
OUT role_to_actor JSONB) | |
RETURNS RECORD IMMUTABLE | |
AS $plpython_function$ | |
import json | |
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
# Haproxy config file for SSL and basic authentication | |
# | |
# Since ssl is needed, we need to use | |
# `make TARGET=linux26 USE_OPENSSL=1 ADDLIB=-lz` to install haproxy. | |
# Also, haproxy version must be haproxy-1.5-dev19 or above. | |
# | |
# An example curl command that queryies pic-collage.com/api/collages/feed is | |
# `curl -k -v -u 'collages:password' 'https://ec2-ip.compute-1.amazonaws.com/api/collages/feed'` | |
userlist collages_dyno |
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/env python3 | |
# vim: ft=python ts=4 sw=4 expandtab | |
# | |
# Copyright (c) 2013 Reed Kraft-Murphy <reed@reedmurphy.net> | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining a copy | |
# of this software and associated documentation files (the "Software"), to deal | |
# in the Software without restriction, including without limitation the rights | |
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
# copies of the Software, and to permit persons to whom the Software is |
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
sudo yum install gcc python27 python27-devel postgresql-devel | |
sudo curl https://bootstrap.pypa.io/ez_setup.py -o - | sudo python27 | |
sudo /usr/bin/easy_install-2.7 pip | |
sudo pip2.7 install psycopg2 |
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 csv | |
from xml.etree import ElementTree | |
from petl import tocsv, fromcsv, convertall | |
def tocsvunicode(table, filename, encoding='utf-8', **kwds): | |
data = (map(lambda x: unicode(x).encode(encoding), row) for row in table) | |
tocsv(data, filename, **kwds) | |
def fromcsvunicode(source=None, dialect=csv.excel, encoding='utf-8', **kwargs): | |
table = fromcsv(source, dialect, **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
#!/bin/bash -v | |
# Add your app build steps here | |
# Assume that these steps produce a "dist" folder at this level | |
# Prepare packer variables | |
repoName=$1 | |
imageVersion=$2 | |
chmod 700 fetch.sh | |
./fetch.sh $repoName $imageVersion > variables.json |
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
# coding=UTF-8 | |
from __future__ import division | |
import nltk | |
import re | |
import requests | |
# Add your freebase key here | |
# If you don't have one, register at https://code.google.com/apis/console | |
FREEBASE_KEY = "" |
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 nltk | |
with open('sample.txt', 'r') as f: | |
sample = f.read() | |
sentences = nltk.sent_tokenize(sample) | |
tokenized_sentences = [nltk.word_tokenize(sentence) for sentence in sentences] | |
tagged_sentences = [nltk.pos_tag(sentence) for sentence in tokenized_sentences] | |
chunked_sentences = nltk.batch_ne_chunk(tagged_sentences, binary=True) |
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/env python | |
# Simple [boto3](https://github.com/boto/boto3) based EC2 manipulation tool | |
# | |
# To start an instance, create a yaml file with the following format: | |
# | |
# frankfurt: | |
# - subnet-azb: | |
# - type: t2.micro | |
# image: image-tagname |
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/env python | |
import argparse, getpass | |
class Password(argparse.Action): | |
def __call__(self, parser, namespace, values, option_string): | |
if values is None: | |
values = getpass.getpass() | |
setattr(namespace, self.dest, values) |