Skip to content

Instantly share code, notes, and snippets.

View sondnm's full-sized avatar
🎯
Focusing

Son Dang sondnm

🎯
Focusing
View GitHub Profile
@sondnm
sondnm / motivation-solarized-light.css
Created November 28, 2016 15:04
Light solarized theme for chrome app Motivation (count your age)
/*
* 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 November 14, 2017 08:26
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
sondnm / arel-cheatsheet.md
Created December 1, 2017 15:42
Arel cheatsheet

Tables

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

Columns

posts[:id]
posts[:title]
@sondnm
sondnm / git-cheatsheet.md
Last active December 11, 2017 02:45
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
@sondnm
sondnm / gist:a136b2dba649a7c753ae94ddff28912d
Created June 9, 2018 08:24 — forked from giannisp/gist:ebaca117ac9e44231421f04e7796d5ca
Upgrade PostgreSQL 9.6.5 to 10.0 using Homebrew (macOS)
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 October 5, 2018 05:17
Transition from 11 digits to 10 digits Vietnam phone number
{
"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 March 8, 2019 05:32
Utils using JS in Github
// Remove all branches in https://github.com/<username>/<repo>/branches
document.querySelectorAll("svg.octicon.octicon-trashcan").forEach(function(e) { e.parentNode.click() })
@sondnm
sondnm / git-rubocop-pre-commit
Created May 28, 2019 09:25
Simple git hook to run Rubocop before committing
# .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
@sondnm
sondnm / lions-unix-source-code.c
Created March 2, 2020 15:38
Lions' Commentary on UNIX source code
0100: /* fundamental constants: cannot be changed */
0100: /* fundamental constants: cannot be changed */
0101:
0102:
0103: #define USIZE 16 /* size of user block (*64) */
0104: #define NULL 0
0105: #define NODEV (-1)
0106: #define ROOTINO 1 /* i number of all roots */
0107: #define DIRSIZ 14 /* max characters per directory */
0108:

Keybase proof

I hereby claim:

  • I am sondnm on github.
  • I am sondnm (https://keybase.io/sondnm) on keybase.
  • I have a public key ASCdm3ZFC1nMWSTi8axuQ26HLaJwJ7LUtlqczUMkKeYsAwo

To claim this, I am signing this object: