Skip to content

Instantly share code, notes, and snippets.

View ptbrowne's full-sized avatar

Patrick Browne ptbrowne

View GitHub Profile
@ptbrowne
ptbrowne / gist:1462440
Created December 11, 2011 20:04 — forked from jamescasbon/template.py
Pure python templates using with statement
"""
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()
#
# HCI memory structure - core interface
#
#
## Objects as structures
namespace java fr.sciencespo.medialab.hci.memorystructure.domain
@ptbrowne
ptbrowne / PA2.py
Created March 4, 2012 11:37
NLP : PA2
#!/usr/bin/env python
#-*- coding:utf-8 -*-
# #Natural Language Processing in Python
# #Assignment #2
# Exercises: 4, 8, 12, 13, 18, 25, 26 (Chapter 2)
# Your Turn: Pages 44, 55
from __future__ import division
from PA1 import count_initial_indent, strip_initial_indent, write_doc
@ptbrowne
ptbrowne / PA3.c
Created March 16, 2012 06:46
PA3 computer graphics
#include <iostream>
#include <fstream>
#include <stdlib.h>
#include <math.h>
#include <sys/types.h>
#include <GL/glut.h>
#include "FrameXform.h"
#include "WaveFrontOBJ.h"
@ptbrowne
ptbrowne / pouring_water.py
Created March 16, 2012 09:22
pouring water with bfs
from copy import copy
def ancesters(child, parents):
"""
when given a child and a child->parent dict, returns all child's ancesters
from youngest to oldest
"""
yield child
while parents.get(child):
child = parents.get(child)
@ptbrowne
ptbrowne / pouring.scala
Created March 21, 2012 12:19
pouring water scala
import collection.mutable.HashSet
import collection.mutable.Queue
import collection.mutable.ArraySeq
import scala.io.Source
import java.io.File
case class Container(capacity: Int, filled: Int) {
// overload + and - methods
def +(toAdd: Int) = {
@ptbrowne
ptbrowne / priority_queue.py
Created May 7, 2012 08:36
heap based priority queue
#!/usr/bin/env python
#-*- coding:utf-8 -*-
#author : Patrick Browne
from time import time
from random import randint
class Heap(list):
@ptbrowne
ptbrowne / menufromjson.html
Created October 28, 2012 18:03
generation of menu from json file (html part)
<html>
<head>
<title>Menu from Json</title>
<script src="../../lib/jquery-1.7.2.js"></script>
<script src="../../lib/bootstrap/js/bootstrap.js"></script>
<link href="../../lib/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<style>
body {
margin:20px;
}
@ptbrowne
ptbrowne / sequence-diagram-in-github.js
Last active December 26, 2015 07:49
TamperMonkey extension to draw sequence diagram in Github
// ==UserScript==
// @name Sequence Diagram in Github
// @version 0.1
// @description Use https://github.com/bramp/js-sequence-diagrams to put sequence diagrams in Github
// @match https://github.com/*/*/issues/*
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js
// @require https://cdnjs.cloudflare.com/ajax/libs/lodash.js/2.2.1/lodash.min.js
// @run-at document-end
// example in Github Issues
@ptbrowne
ptbrowne / curl_to_requests.py
Last active January 1, 2016 12:59
curl to requests
import re
import pprint
import requests
TRIMMABLE_HEADERS = [
'Accept',
'Host',
'Origin',
'Accept-Encoding',
'Accept-Language',