Skip to content

Instantly share code, notes, and snippets.

@michaelhood
michaelhood / .block
Created June 18, 2017 06:34 — forked from ColinEberhardt/.block
London Marathon Finish Times 2016
license: mit
@michaelhood
michaelhood / TrueColour.md
Created June 8, 2017 09:05 — forked from XVilka/TrueColour.md
True Colour (16 million colours) support in various terminal applications and terminals

Colours in terminal

It's a common confusion about terminal colours... Actually we have this:

  • plain ascii
  • ansi escape codes (16 colour codes with bold/italic and background)
  • 256 colour palette (216 colours + 16 ansi + 24 gray) (colors are 24bit)
  • 24bit true colour ("888" colours (aka 16 milion))
printf "\x1b[${bg};2;${red};${green};${blue}m\n"
@michaelhood
michaelhood / histogram.sql
Created June 4, 2017 19:03 — forked from wolever/histogram.sql
Functions to create and draw histograms with PostgreSQL.
-- Functions to create and draw histograms with PostgreSQL.
--
-- psql# WITH email_lengths AS (
-- -# SELECT length(email) AS length
-- -# FROM auth_user
-- -# LIMIT 100
-- -# )
-- -# SELECT * FROM show_histogram((SELECT histogram(length, 0, 32, 6) FROM email_lengths))
-- bucket | range | count | bar | cumbar | cumsum | cumpct
-- --------+-------------------------------------+-------+--------------------------------+--------------------------------+--------+------------------------
@michaelhood
michaelhood / gist:e703700cb960546670dba2ddf1281f15
Created April 27, 2017 04:33 — forked from Coornail/gist:4015909
Chrome sqlite vacuum on OsX
#!/bin/sh
DIRECTORY='~/Library/Application Support/Google/Chrome/'
TMPFILE=`mktemp /tmp/chrome_cleanup.XXXXXX`
find "$DIRECTORY" >> $TMPFILE
SQLITE_FILES=`mktemp /tmp/chrome_cleanup.XXXXXX`
SAVEIFS=$IFS
@michaelhood
michaelhood / xcode-cli-tools.sh
Created January 21, 2017 10:19 — forked from trinitronx/xcode-cli-tools.sh
Script to download & install XCode Command Line tools on OSX 10.7 or 10.8. Lifted from jedi4ever/veewee template.
#!/bin/sh
OSX_VERS=$(sw_vers -productVersion | awk -F "." '{print $2}')
# Get Xcode CLI tools
# https://devimages.apple.com.edgekey.net/downloads/xcode/simulators/index-3905972D-B609-49CE-8D06-51ADC78E07BC.dvtdownloadableindex
# https://developer.apple.com/downloads/index.action
TOOLS=clitools.dmg
if [ ! -f "$TOOLS" ]; then
if [ "$OSX_VERS" -eq 7 ]; then
DMGURL=http://devimages.apple.com/downloads/xcode/command_line_tools_for_xcode_os_x_lion_april_2013.dmg
@michaelhood
michaelhood / embedded.go
Created November 10, 2016 20:30 — forked from joshrotenberg/embedded.go
embedded nsqd
package main
// This is a basic example of running an nsqd instance embedded. It creates
// and runs an nsqd with all of the default options, and then produces
// and consumes a single message. You are probably better off running a
// standalone instance, but embedding it can simplify deployment and is
// useful in testing.
// See https://github.com/nsqio/nsq/blob/master/nsqd/options.go and
// https://github.com/nsqio/nsq/blob/master/apps/nsqd/nsqd.go for
@michaelhood
michaelhood / build_oracle_jdk_debs.sh
Created November 4, 2016 23:33 — forked from notpeter/build_oracle_jdk_debs.sh
Oracle Java JDK - Make Debian/Ubuntu deb packages
#!/usr/bin/env bash
set -u
# Downloads Oracle JDK tarball and makes fancy debs out of it.
# Output is full of warnings, but the packages work. ;)
# Example URL='http://download.oracle.com/otn-pub/java/jdk/8u45-b14/jdk-8u45-linux-x64.tar.gz'
MAJOR=8
MINOR=45
BUILD=14
@michaelhood
michaelhood / gist:56206183da20ceccd908e1247c22c7f6
Created August 6, 2016 16:07 — forked from debasishg/gist:8172796
A collection of links for streaming algorithms and data structures
  1. General Background and Overview
'''pass_socket.py
Written September 14, 2012
Released into the public domain.
Works on Python 2.6, 2.7, and may need minor changes for 3+.
'''
import multiprocessing
#!/usr/bin/env python
"""
@author Sunil Mallya
Sample code to show a parent - child like process communication model where parent listens on a port and passes the pickled file descriptor
to the child process to read the bytes off the socket. The communication in this snippet is via a Queue which is thread/process safe
Just to be clear, the parent process is still accepting the connection and we are sending a live fd to the child
"""
import os
import sys