Skip to content

Instantly share code, notes, and snippets.


Son Dang sondnm

Block or report user

Report or block sondnm

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
sondnm / git-rubocop-pre-commit
Created May 28, 2019
Simple git hook to run Rubocop before committing
View git-rubocop-pre-commit
# .git/hooks/pre-commit
#! /bin/sh
inspected_files=$(git diff --diff-filter=ACMR --name-only HEAD)
if [ $(echo $inspected_files | wc -w) -gt "0" ];
bundle exec rubocop $inspected_files --force-exclusion --auto-correct
sondnm / prerender_recache.rb
Created Apr 12, 2019
Recache API client for
View prerender_recache.rb
require 'net/http'
require 'json'
require 'uri'
class Prerender
ENDPOINTS = "".freeze
def initialize(url, prerender_token)
@url = url
@prerender_token = prerender_token
sondnm / github-js-utils.js
Last active Mar 8, 2019
Utils using JS in Github
View github-js-utils.js
// Remove all branches in<username>/<repo>/branches
document.querySelectorAll("svg.octicon.octicon-trashcan").forEach(function(e) { })
sondnm / phone-number-transition.json
Created Oct 5, 2018
Transition from 11 digits to 10 digits Vietnam phone number
View phone-number-transition.json
"0162": "032",
"0163": "033",
"0164": "034",
"0165": "035",
"0166": "036",
"0167": "037",
"0168": "038",
"0169": "039",
"0120": "070",
sondnm / gist:a136b2dba649a7c753ae94ddff28912d
Created Jun 9, 2018 — forked from giannisp/gist:ebaca117ac9e44231421f04e7796d5ca
Upgrade PostgreSQL 9.6.5 to 10.0 using Homebrew (macOS)
View gist:a136b2dba649a7c753ae94ddff28912d
After automatically updating Postgres to 10.0 via Homebrew, the pg_ctl start command didn't work.
The error was "The data directory was initialized by PostgreSQL version 9.6, which is not compatible with this version 10.0."
Database files have to be updated before starting the server, here are the steps that had to be followed:
# need to have both 9.6.x and latest 10.0 installed, and keep 10.0 as default
brew unlink postgresql
brew install postgresql@9.6
brew unlink postgresql@9.6
brew link postgresql
sondnm /
Last active Dec 11, 2017
Git cheatsheet

Retrieve logs in a specific period

git log --since 2017/12/01 --until 2017/12/07 --oneline

# Logs last week in Linux
git log --since  "`date -d '1 week ago' '+%Y/%m/%d'`" --oneline
# Logs last week in OSX
git log --since "`date -v-1w '+%Y/%m/%d'`" --oneline


posts =
posts = Post.arel_table # ActiveRecord


sondnm /
Created Nov 14, 2017
Install gem requiring openssl on OSX

With gem install

$ gem install eventmachine -v '1.0.7' --with-cppflags=-I/usr/local/opt/openssl/include

With bundler:

  • Make sure you have bundle config file ~/.bundle/config
  • Add options when building gem
sondnm / motivation-solarized-light.css
Created Nov 28, 2016
Light solarized theme for chrome app Motivation (count your age)
View motivation-solarized-light.css
* How to change theme:
* Replace the file in .config/chromium/Default/Extensions/[APP_ID]/[APP_VERSION]/css/style.css with this file.
:root {
--base3: #fdf6e3;
--base1: #93a1a1;
--blue: #268bd2;
--green: #859900;
You can’t perform that action at this time.