Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

Son Dang sondnm

🎯
Focusing
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
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;
@sondnm
sondnm / openssl-gem-install-osx.md
Created Nov 14, 2017
Install gem requiring openssl on OSX
View openssl-gem-install-osx.md

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
View arel-cheatsheet.md

Tables

posts = Arel::Table.new(:posts)
posts = Post.arel_table # ActiveRecord

Columns

posts[:id]
posts[:title]
@sondnm
sondnm / git-cheatsheet.md
Last active Dec 11, 2017
Git cheatsheet
View git-cheatsheet.md

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
@sondnm
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
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
sondnm / github-js-utils.js
Last active Mar 8, 2019
Utils using JS in Github
View github-js-utils.js
// Remove all branches in https://github.com/<username>/<repo>/branches
document.querySelectorAll("svg.octicon.octicon-trashcan").forEach(function(e) { e.parentNode.click() })
@sondnm
sondnm / prerender_recache.rb
Created Apr 12, 2019
Recache API client for prerender.io
View prerender_recache.rb
require 'net/http'
require 'json'
require 'uri'
class Prerender
ENDPOINTS = "https://api.prerender.io".freeze
def initialize(url, prerender_token)
@url = url
@prerender_token = prerender_token
@sondnm
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" ];
then
bundle exec rubocop $inspected_files --force-exclusion --auto-correct
fi
You can’t perform that action at this time.