Skip to content

Instantly share code, notes, and snippets.

View sweenzor's full-sized avatar

Matt Sweeney sweenzor

View GitHub Profile
@signed0
signed0 / gist:2031157
Created March 13, 2012 19:53
Google Polyline encoder & decoder
'''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.
@adamgreenhall
adamgreenhall / ercot2010_01.csv
Created January 25, 2012 22:33
fitting parameters for an ARMA model using statsmodels
time wind
2010-01-01 00:00:00 1367
2010-01-01 01:00:00 1187
2010-01-01 02:00:00 1090
2010-01-01 03:00:00 1439
2010-01-01 04:00:00 2362
2010-01-01 05:00:00 2783
2010-01-01 06:00:00 2869
2010-01-01 07:00:00 2512
2010-01-01 08:00:00 1804
@spudbean
spudbean / gist:1558257
Last active January 31, 2025 19:56
Look of disapproval and other emoticons
ಠ_ಠ
( ͡° ͜ʖ ͡°)
¯\_(ツ)_/¯
(╯°□°)╯︵ ┻━┻
http://www.fileformat.info/convert/text/upside-down.htm
WRTTN http://wrttn.me/30dbfd/
Unicode Emoticons
def decode_google_polyline(encoded):
"""
Decode a google polyline string into a list of coordinates.
See http://code.google.com/apis/maps/documentation/utilities/polylinealgorithm.html
"""
raw_numbers = [ord(c) - 63 for c in encoded[::-1]]
current_number = 0
sequence = []
@hugowetterberg
hugowetterberg / geo-distance.coffee
Created November 3, 2011 09:31
Converts the distance between the WGS 84 coordinates pointA and pointB to meters.
###
Converts the distance between the WGS 84 coordinates pointA and pointB to meters.
Ported from http://groups.google.com/group/sci.geo.satellite-nav/msg/0bfca0bf8a986395
with the suggested radii-calculation optimization.
###
module.exports.WGS84DegreesToMeters = (pointA, pointB)->
radFactor = Math.PI/180
[lat1, lon1] = [pointA[0]*radFactor, pointA[1]*radFactor]
[lat2, lon2] = [pointB[0]*radFactor, pointB[1]*radFactor]
@simme
simme / Install_tmux
Created October 19, 2011 07:55
Install and configure tmux on Mac OS X
# First install tmux
brew install tmux
# For mouse support (for switching panes and windows)
# Only needed if you are using Terminal.app (iTerm has mouse support)
Install http://www.culater.net/software/SIMBL/SIMBL.php
Then install https://bitheap.org/mouseterm/
# More on mouse support http://floriancrouzat.net/2010/07/run-tmux-with-mouse-support-in-mac-os-x-terminal-app/
@vgoklani
vgoklani / Viterbi.py
Created October 14, 2011 17:51
Viterbi algorithm for Hidden Markov Models (HMM) taken from wikipedia
#!/usr/bin/python
# http://en.wikipedia.org/wiki/Viterbi_algorithm
'''
Consider two friends, Alice and Bob, who live far apart from each other and who talk together daily over the telephone about what they did that day. Bob is only interested in three activities: walking in the park, shopping, and cleaning his apartment. The choice of what to do is determined exclusively by the weather on a given day. Alice has no definite information about the weather where Bob lives, but she knows general trends. Based on what Bob tells her he did each day, Alice tries to guess what the weather must have been like.
Alice believes that the weather operates as a discrete Markov chain. There are two states, "Rainy" and "Sunny", but she cannot observe them directly, that is, they are hidden from her. On each day, there is a certain chance that Bob will perform one of the following activities, depending on the weather: "walk", "shop", or "clean". Since Bob tells Alice about his activities, those are the observations. The entire
@jpsilvashy
jpsilvashy / generate_bson_ids.rb
Created September 19, 2011 18:55
Generate 20 BSON Ids
#!/usr/bin/env ruby
# encoding: utf-8
require 'bson'
20.times do
puts BSON::ObjectId.new
end
--------- clients.py --------
class PikaPubSubPublishClient(object):
def __init__(self, host=settings.APP_MESSAGER_DEFAULT_HOST,
port=settings.APP_MESSAGER_DEFAULT_PORT,
virtual_host=settings.APP_MESSAGER_DEFAULT_VIRTUALHOST,
username=settings.APP_MESSAGER_DEFAULT_USERNAME,
password=settings.APP_MESSAGER_DEFAULT_PASSWORD,
exchange_name='ground',
@mbostock
mbostock / .block
Last active April 18, 2025 00:24
Google Maps + D3
license: gpl-3.0