Skip to content

Instantly share code, notes, and snippets.

Notes on Docker.

Starting a Docker machine

docker-machine start :name: && eval "$(docker-machine env :name:)"

Where :name: is the name of the machine you want to start, e.g. to start default:

@swinton
swinton / Code.gs
Created October 1, 2015 21:48
No big deal. Just some code for a Google Spreadsheet to list events from a Google Calendar, to help track + report time. If you like it, you can use it!
var settings = getSettings();
function updateTimesheet() {
/**
* Export Google Calendar Events to a Google Spreadsheet.
*
* Reference Websites:
* https://developers.google.com/apps-script/reference/calendar/calendar
* https://developers.google.com/apps-script/reference/calendar/calendar-event

Version numbers in npm follow a standard called "SemVer". This stands for "Semantic Version". The specification for this standard can be found at http://semver.org.

The tl;dr version is that for a version like this:

  1.2.3
  ^ ^ ^
  | | `-- Patch version. Update for every change.
@swinton
swinton / s3cmd.md
Last active September 8, 2015 16:05
HOWTO: S3cmd

HOWTO: S3cmd

Recursively copy everything in S3 bucket to pwd

s3cmd get --recursive s3://my-awesome-bucket/

Recursively copy everything in pwd to a bucket and make it public

E.g. great for publishing a website to S3!

Advanced Query Search

Use Advanced Query Search (AQS), to refine your search results. In the search box, type a keyword from the table below, followed by a colon and what to search for. For example, to find messages with a subject that contains “report”, enter subject:report in the search box.

CREATE TABLE person (
id INTEGER PRIMARY KEY,
first_name TEXT,
last_name TEXT,
age INTEGER
);
CREATE TABLE pet (
id INTEGER PRIMARY KEY,
owner_id INTEGER,
@swinton
swinton / SQL.md
Last active October 9, 2015 19:23

Exercises

  • What is the schema below trying to model?
  • Write a query that lists all the pets owned by Zed.
  • Write a query that finds all pets older than 10 years.
  • Write a query that shows what the most popular breed of pet is.
  • How would you ensure this query performed well?
  • Insert yourself and your pets (or imaginary pets) into the database.
  • Sadly, Fluffy the Unicorn just died, write a query that updates the data to show this.
  • How would you change this schema so that a pet can be owned by multiple people?
@swinton
swinton / autossh.plist
Created February 12, 2015 20:20
launchd plist for running a SOCKS proxy with an autossh tunnel wotsit.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>swinton.autossh</string>
<key>KeepAlive</key>
<dict>
<key>NetworkState</key>
<true/>
@swinton
swinton / proxy.pac
Created February 11, 2015 02:26
Example proxy.pac, using a SOCKS proxy for certain hosts.
function FindProxyForURL(url, host) {
var useSocks = ["imgur.com"];
for (var i= 0; i < useSocks.length; i++) {
if (shExpMatch(host, useSocks[i])) {
return "SOCKS localhost:9999";
}
}
return "DIRECT";
"""
How Django generates SECRET_KEYs for new Django projects.
See:
https://github.com/django/django/blob/1.7.1/django/core/management/commands/startproject.py#L27
"""
from django.utils.crypto import get_random_string
# Create a random secret_key