Skip to content

Instantly share code, notes, and snippets.

View jasonjohnson's full-sized avatar
👾

Jason Johnson jasonjohnson

👾
View GitHub Profile
@jasonjohnson
jasonjohnson / sqlite.py
Last active August 29, 2015 14:01
python sqlite example
import sqlite3 as db
connection = db.connect(":memory:")
# Use the built-in row factory class and auto-commit
# all data modifications.
connection.row_factory = db.Row
connection.isolation_level = None
class Scanner(object):
def __init__(self, stream):
self.offset = 0
self.stream = stream
def current(self):
return self.stream[self.offset]
def step(self):
self.offset += 1
@jasonjohnson
jasonjohnson / main.go
Created April 3, 2014 21:47
Golang AMQP
package main
import (
"fmt"
"github.com/streadway/amqp"
"log"
)
func main() {
connection, err := amqp.Dial("amqp://guest:[email protected]:5672")
@jasonjohnson
jasonjohnson / p.pickle
Created March 2, 2014 17:02
Disallow python pickle opcodes.
cos
system
(S'/bin/sh'
tR.
@jasonjohnson
jasonjohnson / python.md
Last active August 29, 2015 13:55
A collection of resources for learning Python.

Introduction

The best way to learn Python is to write Python, but these guides will provide an excellent starting point for the library landscape, coding standards, and community. This is by no means comprehensive! Once this is in an actual repository I will gladly accept relevant modifications.

Guides

The Hitchhiker’s Guide to Python!

"This opinionated guide exists to provide both novice and expert Python developers a best-practice handbook to the installation, configuration, and usage of Python on a daily basis."

TSDB="/root/opentsdb/build/tsdb"
ZK="zk0,zk1,zk2"
IN="truncate.txt"
FN="sum"
START=`date -d '2 years ago' '+%Y/%m/%d-%H:%M'`
STOP=`date -d '4 hours ago' '+%Y/%m/%d-%H:%M'`
echo $START
#!/bin/bash
while true; do
let now=`date +%s`
let val=`shuf -i 70-85 -n 1`
echo "put my.cpu.load $now $val host=blick" | nc -w 30 localhost 4242
done
./build/tsdb tsd \
--port=4242 \
--staticroot=build/staticroot \
--cachedir=/home/jason/Projects/opentsdb-cache/ \
--zkquorum=127.0.0.1:2181
-module(main).
-export([run/0, hold/0, example/0]).
hold() ->
receive
% ...
after
1000 ->
io:format("Timed out: ~p~n", [self()])
import os
import sys
os.environ["PYSDL2_DLL_PATH"] = "lib"
import sdl2
import sdl2.ext as ext
def run():
ext.init()