Skip to content

Instantly share code, notes, and snippets.

View visualmotive's full-sized avatar

Chris Mueller visualmotive

View GitHub Profile

Keybase proof

I hereby claim:

  • I am visualmotive on github.
  • I am cmueller (https://keybase.io/cmueller) on keybase.
  • I have a public key whose fingerprint is 7CCB B4B4 3A60 7BD5 49DF 72EA 580A 4F51 768E A27A

To claim this, I am signing this object:

@visualmotive
visualmotive / README.md
Last active August 29, 2015 13:58
Tetris with Sticky Gravity - Thumbtack PyCon Programming Challenge 2014

Sticky gravity is explained in depth here: http://tetrisconcept.net/wiki/Line_clear#Sticky

The playfield is divided into connected segments using flood fill. Any blocks that are adjacent horizontally or vertically are marked as one segment, that is, they are treated as having "stuck" together. Each segment falls independently until it meets the floor or another block. Additional line clears may result.

Sample input and expected output are included in this Gist.

@visualmotive
visualmotive / input_1
Created April 9, 2014 00:26
Sample Tetris input - Thumbtack PyCon Programming Challenge 2014
..........
..........
..........
..........
..........
..........
..........
..........
..........
..........
@visualmotive
visualmotive / compress.js
Created January 17, 2014 02:05
Save/load forms in localStorage. Useful for filling out forms over and over.
(function(){var f="data-form-local-storage-button-container";if(document.getElementById(f)){jQuery(f).show();return}var e=document.createElement("div"),c=document.getElementsByTagName("body")[0];e.id=f;e.style.position="fixed";e.style.top="0";e.style.right="0";e.style.padding="5px 10px";e.style.zIndex=1001;e.style.fontSize="12px";e.style.color="#222";e.style.backgroundColor="#eee";function a(h,j){var i=document.getElementsByTagName("head")[0],b=false,g=document.createElement("script");g.src=h;g.onload=g.onreadystatechange=function(){if(!b&&(!this.readyState||this.readyState=="loaded"||this.readyState=="complete")){b=true;j();g.onload=g.onreadystatechange=null;i.removeChild(g)}};i.appendChild(g)}if(typeof jQuery!="undefined"){return d()}else{if(typeof $=="function"){otherlib=true}}a("//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js",function(){if(typeof jQuery=="undefined"){alert("couldn't load jquery?")}return d()});function d(){e.innerHTML="<button data-local-storage-form-load>Load</button><button
@visualmotive
visualmotive / ctags
Created December 11, 2013 19:15
Using ctags nicely with git. Add the following files to ~/.git_template/hooks and ctags will always be up to date with your latest git merges/commits/rebases. This also puts the `tags` file into your repo's .git directory, so it won't clutter your workspace.
#!/bin/sh
set -e
PATH="/usr/local/bin:$PATH"
trap "rm -f .git/tags.$$" EXIT
ctags --tag-relative -Rf.git/tags.$$ --exclude=.git --languages=-sql
mv .git/tags.$$ .git/tags
@visualmotive
visualmotive / experiment.py
Created October 12, 2012 18:16
Mixpanel API with A/B tests
#! /usr/bin/env python
#
# Mixpanel, Inc. -- http://mixpanel.com/
#
# Python API client library to consume mixpanel.com analytics data.
#
# Modified by Chris Mueller at Thumbtack for A/B tests
import hashlib
import urllib
(function($) {
$.fn.slide = function strength(options) {
var defaults = {
'direction': 'left', // can also be 'right'
'duration': 500,
'callback': function() {}
};
if (options === 'left' || options === 'right') {
@visualmotive
visualmotive / rotary_example.html
Created May 23, 2011 23:10
Rotary Maps Example
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
#map { width: 640px; height: 480px; border: 1px solid #000; }
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script src="https://github.com/thumbtack/rotarymaps/raw/master/release/rotarymaps_min.0.2.js"></script>
// Python equivalent:
// string[start:end]
function tt_str_slice($string, $start=NULL, $end=NULL) {
$length = strlen($string);
if ($start === NULL) {
$start = 0;
} else if ($start < 0) {
$start = $length + $start;
if ($start < 0) {