Skip to content

Instantly share code, notes, and snippets.

View mattbornski's full-sized avatar

Matt Bornski mattbornski

View GitHub Profile
@mattbornski
mattbornski / feature_branch.sh
Last active December 19, 2015 14:09
Feature branch workflow
# Create feature branch from development branch
# Let's start from the most up-to-date version
git checkout <develop-branch>
git pull
# And create a feature branch to do our work out of the way
git checkout -b <feature-branch> <develop-branch>
# And use it
git checkout <feature-branch>
# Do work here
@mattbornski
mattbornski / image.sh
Created May 21, 2013 22:59
Imaging a USB flash drive from a Mac (suitable for making a bootable Ubuntu flash drive, for instance).
#!/bin/bash
echo "Searching for available ISO..."
find ~ -name "*.iso" -type f -size +1048576 | xargs ls -l
read -e -p "Which ISO should be used? " ISO_FILE
if [ "${ISO_FILE}" == "" ] ; then
echo "No ISO selected!"
exit 1
fi
echo "Using ${ISO_FILE}"
@mattbornski
mattbornski / apache-logs-hive.sql
Created November 13, 2012 00:08 — forked from emk/apache-logs-hive.sql
Apache log analysis with Hadoop, Hive and HBase
-- This is a Hive program. Hive is an SQL-like language that compiles
-- into Hadoop Map/Reduce jobs. It's very popular among analysts at
-- Facebook, because it allows them to query enormous Hadoop data
-- stores using a language much like SQL.
-- Our logs are stored on the Hadoop Distributed File System, in the
-- directory /logs/randomhacks.net/access. They're ordinary Apache
-- logs in *.gz format.
--
-- We want to pretend that these gzipped log files are a database table,
@mattbornski
mattbornski / stdout.py
Created August 8, 2012 21:41
Streaming stdout from a Python subprocess in Python 2.6-2.7
#!/usr/bin/env python
# I was frustrated that no matter what buffer setting I passed to communicate,
# I could not get stdout from my subprocess until the process had completed.
# I googled around and came up with this, which illustrates the problem and a
# solution.
# http://stackoverflow.com/questions/2804543/read-subprocess-stdout-line-by-line
# http://bugs.python.org/issue3907
# http://docs.python.org/library/io.html
@mattbornski
mattbornski / timezone.md
Created March 29, 2012 22:36
Determine timezone from lat/long

Goal: To take this: https://graph.facebook.com/105464892820215 And derive this: America/Los Angeles From which we can then derive UTC-0800 or UTC-0700, as appropriate under the daylight madness scheme in effect on the date of interest.

It seems oddly hard to figure out what timezone a given point in space is located in. Looking around, there are only a few APIs which provide this information (http://www.earthtools.org/webservices.htm#timezone and http://www.worldweatheronline.com/time-zone-api.aspx), and only a few datasets which seem to contain it; most of them are in serious GIS formats, and expect you to query them in some manual fashion using a proprietary GIS tool.

I'm not really interested in that; I want a piece of code I can just ask "what timezone is this in" and get an answer, without installing some huge piece of software I don't have a license to or worrying about rate limits from somebody's API. So I'm going to take a shapefile I found here (http://efele.net/maps/tz/world/) and see if we can

@mattbornski
mattbornski / pypy.sh
Created March 2, 2012 18:27
Installing PyPy
#/bin/bash
# Dependencies
#sudo apt-get install gcc make python-dev libffi-dev pkg-config libz-dev libbz2-dev libncurses-dev libexpat1-dev libssl-dev libgc-dev python-sphinx python-greenlet
# To build from source (WARNING will take fucking forever)
#wget https://bitbucket.org/pypy/pypy/get/release-1.8.tar.bz2
#tar jxvf release-1.8.tar.bz2
#cd pypy-pypy-2346207d9946/pypy/translator/goal/
#python translate.py -Ojit
@mattbornski
mattbornski / gist:1730918
Created February 3, 2012 16:15
Streamlining node-inspector on Mac OS X (Debugging, NodeJS, Node Inspector, Javascript, Mac)
#!/bin/bash
_TCP_PORT=`jot -r 1 10000 65000`
while :
do
# Check to see if this port is allocated
lsof -i 4TCP:$_TCP_PORT || break
_TCP_PORT=`jot -r 1 10000 65000`
done
node-inspector --web-port=$_TCP_PORT &