Skip to content

Instantly share code, notes, and snippets.

@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
user www-data;
worker_processes 1;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
sendfile on;
var page = new WebPage(),
address, output, size;
//capture and captureSelector functions adapted from CasperJS - https://github.com/n1k0/casperjs
capture = function(targetFile, clipRect) {
var previousClipRect;
var clipRect = {top: 0, left:0, width: 40, height: 40};
if (clipRect) {
if (!isType(clipRect, "object")) {
throw new Error("clipRect must be an Object instance.");
#
# Wide-open CORS config for nginx
#
location / {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
#