Skip to content

Instantly share code, notes, and snippets.

View jasonjohnson's full-sized avatar
👾

Jason Johnson jasonjohnson

👾
View GitHub Profile
@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."

@jasonjohnson
jasonjohnson / p.pickle
Created March 2, 2014 17:02
Disallow python pickle opcodes.
cos
system
(S'/bin/sh'
tR.
@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:guest@127.0.0.1:5672")
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 / 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
@jasonjohnson
jasonjohnson / nugget.py
Created May 16, 2014 01:12
sketch for simple python database lib?
from nugget import use, bind, find, load, save
# Open a database.
use(":memory:")
# Create a class to bind to a database table.
class Contact(object):
pass
# Associate a class with a database table.
@jasonjohnson
jasonjohnson / decoder.py
Last active August 29, 2015 14:01
bencode thing
from string import digits
class Decoder(object):
def __init__(self, source):
self.offset = 0
self.source = source
def current(self):
return self.source[self.offset]
@jasonjohnson
jasonjohnson / client.sh
Created June 14, 2014 02:50
ZF2 JSON-RPC
#!/bin/bash
curl \
-X POST \
-d '{"method": "add", "params": [1, 2], "id": 1}' \
http://127.0.0.1:8080/server.php
@jasonjohnson
jasonjohnson / composer.json
Created July 24, 2014 15:09
Symfony Router
{
"require": {
"symfony/routing": "2.5.*",
"symfony/http-foundation": "2.5.*"
}
}
@jasonjohnson
jasonjohnson / gist:161356
Created August 4, 2009 17:17
day_of_week
<?php
function day_of_week($day, $month, $year = null, $limit = 20) {
$found_day = false;
$days = array();
$time = mktime(0, 0, 1, $month, 1, ($year?$year:date('Y')));
if(date('Y', $time) == $day)
$found_day = true;