Skip to content

Instantly share code, notes, and snippets.

@gsf
gsf / ubu-on-mac.md
Last active April 15, 2024 12:47
Ubuntu VM on macOS with QEMU

Ubuntu VM on macOS with QEMU

For work I have an Intel Core i5 MacBook. With the Docker Desktop license changes I looked into minikube and Multipass but both failed when I got on our VPN with Cisco AnyConnect due to bridged networking in hyperkit (see links at bottom).

I realized I would be happy SSHing into a local Linux VM but passed on VirtualBox to avoid depending on legacy system extensions. I landed on libvirt for the VM, then realized I could remove libvirt from the equation to finally end up at this quick, simple setup for an Ubuntu VM on macOS with QEMU.

First, install QEMU (see https://wiki.qemu.org/Hosts/Mac for other o

import csv
import googlemaps
import os
import re
import time
gmaps = googlemaps.Client(key=os.getenv('GOOGLE_API_KEY'))
origins = ['559 Carpenter Ln, Philadelphia, PA 19119, USA']
@gsf
gsf / gist:1336733
Created November 3, 2011 15:11
Node.js Summon portal
var crypto = require('crypto');
var http = require('http');
var querystring = require('querystring');
var url = require('url');
var util = require('util');
var accessID = 'xxxxx';
var key = 'xxxxxxxxxx';
var host = 'api.summon.serialssolutions.com';
var summon = http.createClient(80, host);
@gsf
gsf / gist:5377654
Last active July 31, 2017 06:07
Dev Chromebook
  1. Switch the Chromebook to developer mode.

  2. Download crouton.

  3. Create a chroot for a CLI environment.

crosh> shell
chronos@localhost /$ sudo sh -e ~/Downloads/crouton -t cli-extra
@gsf
gsf / cgitrc
Created July 30, 2017 02:50
cgit at subdirectory on nginx and uwsgi
css=/s/cgit.css
logo=/s/cgit.png
virtual-root=/s/
remove-suffix=1
scan-path=/srv/git/
@gsf
gsf / gist:2576755
Created May 2, 2012 14:05
JSON stringifying and parsing in the Chrome console
> JSON.stringify({aList: '\tthing1\n\tthing2\n'})
"{"aList":"\tthing1\n\tthing2\n"}"
> JSON.parse('{"aList":"\tthing1\n\tthing2\n"}')
▼ SyntaxError: Unexpected token
▶ arguments: Array[1]
▶ get message: function getter() { [native code] }
▶ get stack: function getter() { [native code] }
▶ set message: function setter() { [native code] }
▶ set stack: function setter() { [native code] }
type: "unexpected_token"
@gsf
gsf / base16-hterm.js
Last active July 11, 2016 22:37 — forked from petrhosek/pref.js
// Disable bold.
term_.prefs_.set('enable-bold', false);
// Use this for base16-default.
term_.prefs_.set('background-color', "#151515");
term_.prefs_.set('foreground-color', "rgba(255, 255, 255, 0.8)");
term_.prefs_.set('cursor-color', 'rgba(255, 255, 255, 0.5)');
term_.prefs_.set('color-palette-overrides', [
'#151515',
@gsf
gsf / deva.md
Created December 27, 2013 04:09
deva notes

Dev script that does the following:

  1. Restarts the server on changes (a la node-dev)
  2. Bundles up browserify
  3. Restarts and re-bundles on template changes
  4. Compiles lesscss files
  5. Reload browser on any change
@gsf
gsf / try.sh
Last active December 29, 2015 03:29
sh/bash try/catch on error message grep
#!/bin/sh
# Attempt command, printing all output to stdout, catching errors
# based on a regex, erroring out on all other errors
if output=`some-command 2>&1`
then
echo "$output"
else
if echo "$output" | grep 'regex string'
then
something --other --than bailing
@gsf
gsf / gist:6958141
Last active December 25, 2015 09:59
Death tracks

[Originally posted in a comment at http://www.westphillylocal.com/2013/10/11/a-woman-critically-injured-in-hit-and-run-accident-near-38th-and-spruce/.]

I'm not kidding. Road-level trolley tracks and cyclists simply do not mix. I've been in accidents due to tracks in Philadelphia and San Francisco -- the two cities I've lived in with tracks in the streets. Nearly every cyclist I know in Philadelphia has been in at least one minor accident involving tracks, and several have real horror stories. A friend broke several bones in her face due to a slip on the tracks just weeks ago.

But you're right. I may be overestimating in my "thousands of injuries" claim. Unfortunately, we don't have solid data around this issue to reason from. No one keeps track of the number of bicycle accidents caused by trolley tracks, and cycling accidents in general are sorely under-reported. According to the 2012 PennDot Crash Facts & Statistics [1], there were 1,369 total bicycle accidents in Pennsylvania. Considering the estimated 36