Skip to content

Instantly share code, notes, and snippets.

@ptbrowne
ptbrowne / gist:1462440
Created Dec 11, 2011 — forked from jamescasbon/template.py
Pure python templates using with statement
View gist:1462440
"""
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()
View gist:1502206
#
# HCI memory structure - core interface
#
#
## Objects as structures
namespace java fr.sciencespo.medialab.hci.memorystructure.domain
View PA2.py
#!/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 Mar 16, 2012
PA3 computer graphics
View PA3.c
#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 Mar 16, 2012
pouring water with bfs
View pouring_water.py
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 Mar 21, 2012
pouring water scala
View pouring.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
heap based priority queue
View priority_queue.py
#!/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 Oct 28, 2012
generation of menu from json file (html part)
View menufromjson.html
<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 Dec 26, 2015
TamperMonkey extension to draw sequence diagram in Github
View sequence-diagram-in-github.js
// ==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
View curl_to_requests.py
import re
import pprint
import requests
TRIMMABLE_HEADERS = [
'Accept',
'Host',
'Origin',
'Accept-Encoding',
'Accept-Language',
You can’t perform that action at this time.