Skip to content

Instantly share code, notes, and snippets.

View hungpk's full-sized avatar
😁
Available

Kent Pham hungpk

😁
Available
  • Ho Chi Minh City, Vietnam
View GitHub Profile

WAL-E needs to be installed on all machines, masters and slaves.

How to install WAL-E

Only one machine, the master, writes WAL segments via continuous archiving. The configuration for the master postgresql.conf is:

archive_mode = on
archive_command = 'envdir /etc/wal-e.d/env wal-e wal-push %p'
archive_timeout = 60

Ideal Postgres environment

Documentation

  • Documented replication topology
  • Documented network topology
  • Documented interface topology - including users, passwords, connection estimates, load balancers, connection proxies
  • Documented procedure, schedule for failover and testing
  • Documented procedure, schedule for disaster recovery and testing
@hungpk
hungpk / pgcluu-s3.sh
Last active August 29, 2015 14:07
Collect PostgreSQL stat using pgcluu_collectd and put it to S3
#!/bin/sh
HOST=$1
BASE_DIR=$2
S3BUCKET=<s3-bucket>
NOW=`date +"%Y-%m-%d"`
PREFIX=pgcluu
DATA_DIR=$BASE_DIR/$PREFIX-$NOW
#kill current process
pgcluu_collectd -k -f $BASE_DIR/current/pg_cluu_collectd.pid
@hungpk
hungpk / mail.rb
Last active August 29, 2015 14:08 — forked from noxqsgit/mail.rb
#!/usr/bin/env ruby
require 'net/smtp'
unless (2..3).include? ARGV.length
puts 'Usage: mail.rb SUBJECT TO [FROM]'
exit 1
end
subject, to, from_ = ARGV
module ActionMailer
class Base
def perform_delivery_from_header(tmail)
method = tmail.header.delete("x-delivery-method") || :server_2
send "perform_delivery_#{method}", tmail
end
def perform_delivery_server_1(tmail)
self.class.smtp_settings = {
address: "server1.smtp.com",
@hungpk
hungpk / gist:810c88ab0ebd5b337f3d
Created November 2, 2015 14:27 — forked from ryansobol/gist:5252653
15 Questions to Ask During a Ruby Interview

Originally published in June 2008

When hiring Ruby on Rails programmers, knowing the right questions to ask during an interview was a real challenge for me at first. In 30 minutes or less, it's difficult to get a solid read on a candidate's skill set without looking at code they've previously written. And in the corporate/enterprise world, I often don't have access to their previous work.

To ensure we hired competent ruby developers at my last job, I created a list of 15 ruby questions -- a ruby measuring stick if you will -- to select the cream of the crop that walked through our doors.

What to expect

Candidates will typically give you a range of responses based on their experience and personality. So it's up to you to decide the correctness of their answer.

server {
# see: http://wiki.nginx.org/Pitfalls
# see: http://wiki.nginx.org/IfIsEvil
listen 80;
root /app;
index index.html index.htm index.php;
error_page 404 /index.php;
# Make site accessible from http://set-ip-address.xip.io
@hungpk
hungpk / happy_git_on_osx.md
Last active May 9, 2017 04:05 — forked from trey/happy_git_on_osx.md
Creating a Happy Git Environment on OS X

Creating a Happy Git Environment on OS X

Step 1: Install Git

brew install git bash-completion bash-git-prompt

Configure things:

git config --global user.name "Your Name"

git config --global user.email "[email protected]"

@hungpk
hungpk / visor-archivos-online.md
Created October 4, 2017 06:54 — forked from izazueta/visor-archivos-online.md
Google Docs Viewer & Office Web Apps Viewer

Google Docs Viewer

Only files under 25 MB can be previewed with the Google Drive viewer.

Google Drive viewer helps you preview over 16 different file types, listed below:

  • Image files (.JPEG, .PNG, .GIF, .TIFF, .BMP)
  • Video files (WebM, .MPEG4, .3GPP, .MOV, .AVI, .MPEGPS, .WMV, .FLV)
  • Text files (.TXT)
  • Markup/Code (.CSS, .HTML, .PHP, .C, .CPP, .H, .HPP, .JS)
  • Microsoft Word (.DOC and .DOCX)
@hungpk
hungpk / gulpfile.js
Created October 11, 2017 11:01 — forked from danharper/gulpfile.js
New ES6 project with Babel, Browserify & Gulp
var gulp = require('gulp');
var sourcemaps = require('gulp-sourcemaps');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var browserify = require('browserify');
var watchify = require('watchify');
var babel = require('babelify');
function compile(watch) {
var bundler = watchify(browserify('./src/index.js', { debug: true }).transform(babel));