Skip to content

Instantly share code, notes, and snippets.

View ptbrowne's full-sized avatar

Patrick Browne ptbrowne

View GitHub Profile
@ptbrowne
ptbrowne / swiper-2.4.3.css
Created September 8, 2015 13:37
swiper 2.4.3
/*
* Swiper - Mobile Touch Slider CSS
* http://www.idangero.us/sliders/swiper
*
* Vladimir Kharlampidi, The iDangero.us
* http://www.idangero.us/
*
* Copyright 2012-2013, Vladimir Kharlampidi
* The iDangero.us
* http://www.idangero.us
@ptbrowne
ptbrowne / puzzle.py
Created October 1, 2015 16:02
puzzle liseuse
# -*- coding: utf-8 -*-
from copy import deepcopy
from collections import defaultdict, namedtuple, deque
from functools import wraps
class Colors:
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKGREEN = '\033[92m'
@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 / shortcut-chrome-inspect.md
Last active October 18, 2017 17:36
Shortcut to Chrome Inspect

Chrome has made the path to inspect devices more and more difficult. Now to open the inspect devices tab, as of April 2016 it's Menu > More Devices > Developer Tools > Menu > More Tools > Inspect Devices.

Fortunately there is an easy solution : we can use customize the search engine functionality to add a shortcut via the search bar.

  1. Right click on the search bar, click 'Edit Search Engines'.
  2. At the end of the list you can add a search engine. Name it chrome inspect with the keyword insp and URL : chrome://inspect/#devices.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<script src='https://cdnjs.cloudflare.com/ajax/libs/jasmine/2.4.1/jasmine.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/jasmine/2.4.1/jasmine-html.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/jasmine/2.4.1/boot.min.js'></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jasmine/2.4.1/jasmine.css" />
// ==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 / 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) {
@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 / 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)
#
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: