Skip to content

Instantly share code, notes, and snippets.

@zh012
zh012 / so_collections.md
Last active August 29, 2015 14:24
SO collections
@zh012
zh012 / dokku-alt.md
Last active October 30, 2015 18:50
dokku-alt on ec2

dokku-alt

Install dokku-alt on server

sudo apt-get update
sudo apt-get install linux-image-extra-$(uname -r)
sudo modprobe aufs
sudo bash -c "$(curl -fsSL https://raw.githubusercontent.com/dokku-alt/dokku-alt/master/bootstrap.sh)" < /dev/null
// from http://stackoverflow.com/a/29304414
var download = function(content, fileName, mimeType) {
var a = document.createElement('a');
if (navigator.msSaveBlob) { // IE10
return navigator.msSaveBlob(new Blob([content], { type: mimeType }), fileName);
} else if ('download' in a) { //html5 A[download]
a.href = 'data:' + mimeType + ',' + encodeURIComponent(content);
a.setAttribute('download', fileName);
document.body.appendChild(a);
@zh012
zh012 / cmds.md
Last active August 29, 2015 14:20
useful commands

Linux

sudo netstat -taupen

Firefox

emulate media types
@zh012
zh012 / vagrant.md
Last active August 29, 2015 14:20
Vagrantfile dynamically loads multiple vm configures
##Vargantfile
```Ruby
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
@zh012
zh012 / django_orm_standalone.md
Created April 23, 2015 19:54
Django ORM standalone by hbdgaf@stackoverflow

Using django ORM without a settings file. Here's how:

In the stand-alone app launcher file:

from django.conf import settings
from django.core.management import execute_from_command_line

#Django settings
settings.configure(DEBUG=False,

DATABASES = {

@zh012
zh012 / finder_shortcut.md
Last active August 29, 2015 14:19
Keyboard shortcut to bring up Finder window
  1. Open Automator and choose the service template.

  2. Change the input type from selected text to no input.

  3. Add a Launch Application action and drop Finder on the pop-up button from /System/Library/CoreServices/.

  4. Save the service and give it a shortcut in System Preferences > Keyboard > Shortcuts > Services.