Skip to content

Instantly share code, notes, and snippets.

@lucasfais
lucasfais / gist:1207002
Created Sep 9, 2011
Sublime Text 2 - Useful Shortcuts
View gist:1207002

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@hrldcpr
hrldcpr / tree.md
Last active Jun 9, 2021
one-line tree in python
View tree.md

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!

@signed0
signed0 / gist:2031157
Created Mar 13, 2012
Google Polyline encoder & decoder
View gist:2031157
'''Provides utility functions for encoding and decoding linestrings using the
Google encoded polyline algorithm.
'''
def encode_coords(coords):
'''Encodes a polyline using Google's polyline algorithm
See http://code.google.com/apis/maps/documentation/polylinealgorithm.html
for more information.
@akhenakh
akhenakh / tools.py
Created Jun 19, 2012
flask jsonify with support for MongoDB from tools import jsonify
View tools.py
try:
import simplejson as json
except ImportError:
try:
import json
except ImportError:
raise ImportError
import datetime
from bson.objectid import ObjectId
from werkzeug import Response
@mbostock
mbostock / .block
Last active Feb 25, 2020
Margin Convention
View .block
license: gpl-3.0
redirect: https://observablehq.com/@d3/margin-convention
@springmeyer
springmeyer / re-concoct.xml
Created Aug 27, 2012
Re-implement the visualization from https://github.com/shawnbot/concoct in one fell swoop using Mapnik 2.1
View re-concoct.xml
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE Map [
<!-- compositing mode: https://github.com/mapnik/mapnik/blob/master/include/mapnik/image_compositing.hpp#L42-79 -->
<!ENTITY comp_op "darken">
<!-- leave blank to render all data or set to some integer to render faster -->
<!ENTITY row_limit "">
<!-- size of marker ellipse -->
@tylermenezes
tylermenezes / remove-rdio-garbage.js
Created Dec 9, 2012
Removes unavailable and preview albums from rdio. This is particularly useful after using the "Sync" feature, since it's useless and generates hundreds of "Unavailable" albums. Scroll to the bottom of your collection first, since it's lazy loaded.
View remove-rdio-garbage.js
(function(){
var i = 0;
var count = $('.Album.unavailable,.Album.preview').length;
console.log('Found ' + count + ' albums to remove');
var timeout = 0;
$('.Album.unavailable,.Album.preview').each(function(){
var instance_i = i++;
var album = $(this);
album.trigger('mouseover').mouseenter();
album.find('a,div,span,image').trigger('mouseover').mouseenter();
@mbostock
mbostock / .block
Last active Sep 26, 2018
Projected TopoJSON
View .block
license: gpl-3.0
height: 800
@jdiscar
jdiscar / gist:9144764
Last active Nov 11, 2020
RGB Value to Nearest Color Name (Python)
View gist:9144764
"""
Original Author Ernesto P. Adorio, Ph.D
Original Source: http://my-other-life-as-programmer.blogspot.com/2012/02/python-finding-nearest-matching-color.html
Modifed By: JDiscar
This class maps an RGB value to the nearest color name it can find. Code is modified to include
ImageMagick names and WebColor names.
1. Modify the minimization criterion to use least sum of squares of the differences.
2. Provide error checking for input R, G, B values to be within the interval [0, 255].
@gka
gka / index.html
Last active Dec 10, 2019
Parliament seating diagrams
View index.html
<!DOCTYPE html>
<html>
<head>
<script src="http://d3js.org/d3.v3.min.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
<style id="jsbin-css">
path { stroke: red; fill: none; stroke-width:2; opacity: 0.4}
</style>
</head>