Skip to content

Instantly share code, notes, and snippets.

@mba811
mba811 / Gollum.md
Created April 13, 2015 08:32
self host a gollum wiki

nginx configuration:

user root admin;

worker_processes  1;

# pid of nginx master process
pid /var/run/nginx.pid;

events {

Zero downtime deploys with unicorn + nginx + runit + rvm + chef

Below are the actual files we use in one of our latest production applications at Agora Games to achieve zero downtime deploys with unicorn. You've probably already read the GitHub blog post on Unicorn and would like to try zero downtime deploys for your application. I hope these files and notes help. I am happy to update these files or these notes if there are comments/questions. YMMV (of course).

Other application notes:

  • Our application uses MongoDB, so we don't have database migrations to worry about as with MySQL or postgresql. That does not mean that we won't have to worry about issues with the database with indexes being built in MongoDB or what have you.
  • We use capistrano for deployment.

Salient points for each file:

#!/bin/bash
rows=%filltext:name=Rows:default=6%
columns=%filltext:name=Columns:default=4%
echo -n "|"
for i in `seq 1 $columns`
do
echo -n -e "\t\t\t|"
done
echo ""
echo -n "|"
@mba811
mba811 / .zshrc
Created April 7, 2015 10:08
ubuntu-zsh-zshrc
#普通命令提示符,在控制台下可以正常显示,如需使用取消注释,并把底部有关提示符的语句注释掉
##RPROMPT='%/'
#PROMPT='%{%}%n%{%}@%{%}%M %{%}%D %T %{%}%/
#%{%}>>%{%}'
#关于历史纪录的配置
# number of lines kept in history
export HISTSIZE=10000
# # number of lines saved in the history after logout
@mba811
mba811 / osx installer docker
Created March 24, 2015 13:57
mac uninstall docker
#!/bin/bash
# Stop boot2docker processes
boot2docker stop
boot2docker delete
# Remove boot2docker executable
sudo rm /usr/local/bin/boot2docker
# Remove boot2docker ISO and socket files
@mba811
mba811 / .zshrc
Last active August 29, 2015 14:17
# for golang
# mkdir $HOME/go
# mkdir -p $GOPATH/src/github.com/user
export GOPATH=$HOME/go
export PATH=$PATH:$GOPATH/bin
@mba811
mba811 / yt.js
Created March 17, 2015 12:58
Download Youtube video (and subtitles, if video has them)
var request = require('request');
var querystring = require('querystring');
var fs = require('fs');
var xml2js = require("xml2js");
var ent = require('ent');
var video_id = 'IgKWPdJWuBQ';
var quality = 'hd720'; // hd1080, hd720, large, highres (original)
Number.prototype.padLeft = function(n,str){
return Array(n-String(this).length+1).join(str||'0')+this;
}
@mba811
mba811 / xSoundCloud.py
Created March 17, 2015 12:57
SoundCloud downloader
#!/usr/bin/env python
# -*- coding: utf8 -*-
# based on xSoundCloud by Xartrick
import os
import sys
import urllib2
from urllib import urlretrieve
@mba811
mba811 / bootstrap-myproject.sh
Created March 17, 2015 07:01
bootstrap-myproject.sh
#!/bin/sh
# Setup some variables needed for bootstrapping the environment
ROOT=/home/vrde/projectz/myproject
REPOS=${ROOT}/repos
export PYTHONPATH=${REPOS}
@mba811
mba811 / .tmux
Created March 17, 2015 07:00
/.tmux.conf配置文件
# status bar
set-option -g status-utf8 on
set -g status-interval 1
set -g status-justify left # center align window list
set -g status-left-length 20
set -g status-right-length 140
set -g status-left '#[fg=green]#H #[fg=black]• #[fg=green,bright]#(uname -r | cut -c 1-6)#[default]'
set -g status-right '#[fg=green,bg=black,bright]#(tmux-mem-cpu-load 1) #[fg=red,dim]#(uptime | cut -f 4-5 -d " " | cut -f 1 -d ",") #[fg=white]%a%l:%M:%S %p#[default] #[fg=blue]%Y-%m-%d'