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
''' | |
given a Model with: | |
category = models.CharField(max_length=32, choices=CATEGORY_CHOICES) | |
pubdate = models.DateTimeField(default=datetime.now) | |
<other fields> | |
Fetch the item from each category with the latest pubdate. | |
''' |
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 | |
# current Git branch | |
branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,') | |
# v1.0.0, v1.5.2, etc. | |
versionLabel=v$1 | |
# establish branch and tag name variables | |
devBranch=develop |
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
""" | |
A really stupid python template language inspired by coffeekup, markaby. | |
Do not use this code, it will ruin your day. A byproduct of insomnia. | |
TL;DR | |
----- | |
This module defines a template language that allows us to do: | |
d = Doc() |
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
# SNAKES GAME | |
# Use ARROW KEYS to play, SPACE BAR for pausing/resuming and Esc Key for exiting | |
import curses | |
from curses import KEY_RIGHT, KEY_LEFT, KEY_UP, KEY_DOWN | |
from random import randint | |
curses.initscr() | |
win = curses.newwin(20, 60, 0, 0) |
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
" type :L to open a file at ~/notes/log/<current date> | |
fun! OpenLog() | |
let fname = strftime("%Y_%m_%d") | |
exe ":e ~/notes/log/" . fname | |
endfun | |
command L call OpenLog() |
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 flask import Flask, jsonify, Blueprint, current_app | |
import json | |
## REST api ################################################################### | |
api = Blueprint('api', __name__) | |
@api.route("/users") | |
def users(): | |
return jsonify(users=[ |
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
driver = 'mysql+pymysql://' | |
driver = 'postgresql+psycopg2://' | |
app.config['SQLALCHEMY_DATABASE_URI'] = driver \ | |
+ os.environ['RDS_USERNAME'] + ':' + os.environ['RDS_PASSWORD'] \ | |
+'@' + os.environ['RDS_HOSTNAME'] + ':' + os.environ['RDS_PORT'] \ | |
+ '/' + os.environ['RDS_DB_NAME'] |
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 json | |
from bs4 import BeautifulSoup | |
import re | |
of = open("all_output.txt", "wb") | |
for file_num in range(1,102): | |
filename = "%03d.json" % file_num | |
print filename |
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 | |
# | |
# chkconfig: 2345 55 25 | |
# description: Openresty | |
# processname: nginx | |
# config: /usr/local/openresty/nginx/conf/nginx.conf | |
# pidfile: /usr/local/openresty/nginx/logs/nginx.pid | |
### BEGIN INIT INFO | |
# Provides: nginx | |
# Required-Start: $local_fs $remote_fs $network $named $syslog $time |
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 | |
''' | |
This script converts the output of Ansible's dynamic ec2.py to a flatly formmated static inventory file. | |
Before running this script run `python ./ec2.py --refresh-cache > ec2-dynamic.json` | |
See: http://docs.ansible.com/ansible/ec2_module.html | |
''' |
OlderNewer