Skip to content

Instantly share code, notes, and snippets.

bash$ GLOBIGNORE="confidential.txt"
bash$ ls -l /opt/too_many_files/*
secret.txt
top_secret.txt
public.txt
-- Open These views with QGIS
-- You can label the ticks view with this expression : "CASE WHEN m % 5 = 0 THEN h END" to get hour numbers
-- Set categorized styles on typ and unit to set different styles for dials, and for the hands
-- Please tweet your best clock designs with #PostGISClock hashtag
create or replace view ticks as
select
m as id
, case when m % 5 = 0 then 'h' else 'm' end as typ
, m % 5 as h
@javisantana
javisantana / speed.sql
Created August 12, 2015 11:05
speed from a track table
WITH deltas as (
SELECT
st_distance(the_geom::geography, lag(the_geom::geography, 1) over(order by timestamp)) as ddist,
timestamp - lag(timestamp, 1) over(order by timestamp) as dt
from out_2 offset 1000
)
select avg(ddist/dt) as speed from deltas
@osantana
osantana / gist:825922
Created February 14, 2011 14:13
Our WIP fabfile deployment script
#!/usr/bin/env fab
# vim:ts=4:sw=4:tw=120:et:sm:foldmethod=indent
import os
import time
from fabric.api import *
from fabric.contrib import files
# Global Settings
@edsu
edsu / unshorten_tweet_urls.py
Created January 18, 2013 18:19
get unshortened URLs out of large batches of Twitter JSON data
#!/usr/bin/env python
"""
Feed this program line-oriented JSON tweet data (as received from the API)
on STDIN and get unshortened URLs mentioned in the tweets on STDOUT.
This module will look up multiple urls at once using the multiprocessing
library. Change CONCURRENCY to have more or less processes, defaults to 10.
"""
@DavidHernandez
DavidHernandez / Sci-fi books
Last active January 25, 2016 15:12
David's Sci-Fi book collection
The moon is a harsh mistress - Robert A. Heinlein - 5*
A canticle for Leibowitz - Walter M. Miller 4*
Flowers for Algernon - Daniel Keyes 5*
The Forever War - Joe Haldeman - 4*
The Stars my destination (also known as Tiger! Tiger!) - Alfred Bester - 5*
The Road - Cormac Mc Carthy - 4*
God is Dead - Ron Currie Jr. - 4*
The world without us - Alan Weisman (not really sci fi, but interesting, anyways) - 4*
Animal Farm - George Orwell - 5*
1984 - George Orwell - 5*
@AdoHaha
AdoHaha / test_throttle.py
Last active May 7, 2016 06:17
A throttle function decorator in Python similar to the one in underscore.js, inspired by debounce decorator from: https://gist.github.com/walkermatt/2871026
#!/usr/bin/python
import unittest
import time
from throttle import throttle
class TestThrottle(unittest.TestCase):
@throttle(1)
def increment(self):
@sgillies
sgillies / GNU parallel vs concurrent.futures console
Last active March 30, 2017 20:41
Python concurrency benchmarks
vas-y:parallelz seang$ time parallel wc ::: `find ~/writing/blog/2013 -name *.rst`
18 128 791 /Users/seang/writing/blog/2013/10/07/downgrading-my-blog.rst
106 567 4011 /Users/seang/writing/blog/2013/10/08/linking-geojson.rst
34 249 1586 /Users/seang/writing/blog/2013/10/24/joining-mapbox.rst
70 373 2910 /Users/seang/writing/blog/2013/11/24/introducing-rasterio.rst
14 45 395 /Users/seang/writing/blog/2013/12/02/geojson-website-refreshed.rst
25 158 1256 /Users/seang/writing/blog/2013/12/03/atom-extension-for-tinkerer.rst
16 74 627 /Users/seang/writing/blog/2013/11/27/new-home-on-github-for-geojson.rst
143 685 6211 /Users/seang/writing/blog/2013/12/04/json-diff-and-patch-for-geojson.rst
26 202 1237 /Users/seang/writing/blog/2013/12/05/first-blog-post-at-mapbox.rst
@agness
agness / custom_logging.py
Created August 22, 2013 17:32
Logging in Python with Tornado's pretty print formatter and routing all messages with INFO level and above to STDOUT, and all messages below to STDERR.
#!/usr/bin/env python
import sys
import logging
import tornado.log
# For pretty log messages, if available
try:
import curses
except ImportError:
curses = None
import simplejson as json
import lxml
class objectJSONEncoder(json.JSONEncoder):
"""A specialized JSON encoder that can handle simple lxml objectify types
>>> from lxml import objectify
>>> obj = objectify.fromstring("<Book><price>1.50</price><author>W. Shakespeare</author></Book>")
>>> objectJSONEncoder().encode(obj)
'{"price": 1.5, "author": "W. Shakespeare"}'
"""