Skip to content

Instantly share code, notes, and snippets.

View dpetzold's full-sized avatar

Derrick Petzold dpetzold

View GitHub Profile
-module(db).
-export([new/0, write/3, destroy/1, delete/2, read/2, match/2, test/0]).
new() -> [].
write(Key, Element, Db) -> [{Key, Element}|Db].
read(Key, [Head | Tail]) ->
{K, V} = Head,
if
#!/usr/bin/python
import os
import sys
import optparse
import progressbar
import time
from boto.s3.connection import S3Connection
from boto.exception import S3ResponseError
from django.conf import settings
from django.contrib.auth import models as auth_models
import cgi
import urllib
import simplejson
from <app_name> import models
class FacebookBackend:
#!/bin/sh
## BEGIN INIT INFO
# Provides: FastCGI servers for PHP
# Required-Start: networking
# Required-Stop: networking
# Default-Start: 2 3 4 5
# Default-Stop: S 0 1 6
# Short-Description: Start FastCGI servers with PHP.
# Description: Start PHP with spawn-fcgi. For use with nginx and lighttpd.
@dpetzold
dpetzold / to_ipod.py
Created August 20, 2010 22:00
Convert and video to ipod viewable using ffmpeg capturing the output to a display the encoding progress.
#!/usr/bin/python
import fcntl
import optparse
import os
import progressbar
import re
import select
import shlex
import subprocess
@dpetzold
dpetzold / fastcgi-django
Created September 7, 2010 22:28
Init script for fastcgi and django.
#! /bin/sh
### BEGIN INIT INFO
# Provides: FastCGI servers for Django
# Required-Start: networking
# Required-Stop: networking
# Default-Start: 2 3 4 5
# Default-Stop: S 0 1 6
# Short-Description: Start FastCGI servers with Django.
# Description: Django, in order to operate with FastCGI, must be started
# in a very specific way with manage.py. This must be done
* << Request >> 32770
- Begin req 32769 rxreq
- Timestamp Start: 1467657059.275449 0.000000 0.000000
- Timestamp Req: 1467657059.275449 0.000000 0.000000
- ReqStart 172.17.0.1 39322
- ReqMethod GET
- ReqURL /
- ReqProtocol HTTP/1.1
- ReqHeader User-Agent: curl/7.40.0
- ReqHeader Accept: */*
@dpetzold
dpetzold / env2secrets.py
Created May 8, 2017 22:07
Convert docker env files for use as kubernetes secrets
#!/usr/bin/python3
import argparse
import sys
from base64 import b64encode
from string import Template
parser = argparse.ArgumentParser()
parser.add_argument('env_file', nargs='?', type=argparse.FileType('r'), default=sys.stdin)
@dpetzold
dpetzold / reflect.py
Created December 20, 2017 22:09 — forked from 1kastner/reflect.py
A simple echo server to inspect http web requests
#!/usr/bin/env python
# Reflects the requests from HTTP methods GET, POST, PUT, and DELETE
# Written by Nathan Hamiel (2010)
from http.server import HTTPServer, BaseHTTPRequestHandler
from optparse import OptionParser
class RequestHandler(BaseHTTPRequestHandler):
def do_GET(self):
# https://github.com/seebi/tmux-colors-solarized/blob/master/tmuxcolors-256.conf
set-option -g status-bg colour235 #base02
set-option -g status-fg colour136 #yellow
set-option -g status-attr default
# set window split
bind-key v split-window -h
bind-key b split-window
# default window title colors