Skip to content

Instantly share code, notes, and snippets.

View ptbrowne's full-sized avatar

Patrick Browne ptbrowne

View GitHub Profile
class LeafletJSONField(JSONField):
widget = LeafletWidget(width='100%', height='400px')
def process_formdata(self, valuelist):
if valuelist:
value = valuelist[0]
if not value:
self.data = None
return
try:
@ptbrowne
ptbrowne / make-gif.sh
Last active October 4, 2016 07:49
make-gif
#!/bin/sh
# Make a gif from a video using optimized palette
#
# Usage: make-gif video.mov video.gif 200
#
# Will output a gif with width 200px
# You can use iw in the width expression to have the width of the input
# video : iw*0.5 will make the gif half the size of the video (useful
# for Retina displays)
#
@ptbrowne
ptbrowne / csv-mail-filter.py
Created September 6, 2016 12:42
Parse mailFilters.xml from Gmail to CSV, only supports to and forwardTo
from collections import defaultdict
from xml.etree import cElementTree as ET
def etree_to_dict(t):
# remove namespace
if hasattr(t.tag, 'find'):
i = t.tag.find('}')
if i >= 0:
t.tag = t.tag[i+1:]
@ptbrowne
ptbrowne / webpack-dev-server-index.js
Created May 11, 2016 16:19
webpack-dev-server-client
var url = require('url');
var SockJS = require("sockjs-client");
var stripAnsi = require('strip-ansi');
var scriptElements = document.getElementsByTagName("script");
var scriptHost = scriptElements[scriptElements.length-1].getAttribute("src").replace(/\/[^\/]+$/, "");
// If this bundle is inlined, use the resource query to get the correct url.
// Else, get the url from the <script> this file was called with.
var urlParts;
if (typeof __resourceQuery === "string" && __resourceQuery) {
// ==UserScript==
// @name Ornikar Keyboard Shortcuts
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Add ABCD shortcuts to Ornikar questions
// @author Patrick Browne
// @match https://www.ornikar.com/*
// @grant none
// ==/UserScript==
@ptbrowne
ptbrowne / gist:bc5d875e782b7ca32040
Created January 7, 2016 16:14
bad-itinerary.json
{
"_id": "568e49392da99e28c3842b14",
"archived": false,
"arrival": [
5.378861000000001,
43.2942346
],
"custom": false,
"departure": [
5.386108399999999,
@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',
@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 / tmux.conf
Last active November 11, 2015 10:20 — forked from spicycode/tmux.conf
My tmux conf
# 0 is too far from ` ;)
set -g base-index 1
set-window-option -g pane-base-index 1
# No confirm before kill
bind-key x kill-pane
# Use ` as prefix
unbind C-b
set -g prefix `
@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;
}