Skip to content

Instantly share code, notes, and snippets.

View phalkunz's full-sized avatar
🏠
Working from home

Saophalkun Ponlu phalkunz

🏠
Working from home
  • Wellington, New Zealand
View GitHub Profile
@phalkunz
phalkunz / git-origin-branch-sync-status.sh
Last active August 29, 2015 14:03
Script to check whether local branch and the origin's counterpart are in sync
###
# Returns a code that determine whether local branch and its origin's counterpart
# are in sync. In sync, in this case, means there's no commits in local branch
# that have not been pushed to the origin. In short, it means the following
# command returns nothing.
#
# git log {branch} --not origin/{branch}
#
# The code will be be in `$?` variable after the funciton call.
# The status code can be:
@phalkunz
phalkunz / echoc.sh
Last active August 29, 2015 14:05
Echo string in color based on `--type`
###
#
# Echo string in color based on `--type`.
# Read `colorEcho()` funncton for more info on type.
#
# AUTHOR:
#
# Saophalkun Ponlu (phalkunz@gmail.com)
#
###
@phalkunz
phalkunz / simple-template-func.js
Last active August 29, 2015 14:05
A really simple template function
/**
* A really simple template function.
*
* USAGE:
*
* 1. Ivoke `prepareTemplate(template)` by provide template string as an argument
* 2. The above invocation returns another function which called by with data argument
**/
function prepareTemplate(template) {
@phalkunz
phalkunz / scss-show-rule-path.vim
Created October 7, 2014 08:16
Vim command for displaying rule path
"""
" USAGE:
"
" 1. Place the cursor in the rule that you want to look up
" 2. :SCSSShowRulePath
"""
command! ScssShowRulePath :call ScssRulePath()
function! ScssRulePath()
let start_line_num = 0

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@phalkunz
phalkunz / responsive-embed-video.scss
Last active August 29, 2015 14:16
Scale embedded video that respects to its apsect ratio using CSS
/**
* Usage:
*
* Set custom (percentage or absolute) width on .video-outer-wrapper
*
* ``html
* <div class="video-outer-wrapper">
* <div class="video-wrapper">
* <iframe ... ></iframe>
* </div>
@phalkunz
phalkunz / callback-threshold.js
Last active July 12, 2016 04:50
Make sure a callback won't run more than once during a specified duration
(function() {
var __timerIDs = {};
/**
* Make sure the callback won't run more than once
* during a specified duration.
*
* This function relies on variable __timerIDs
* in outer scope.
*
@phalkunz
phalkunz / express-passport-local.md
Last active April 25, 2023 13:15
Setup local (username/password) authentication in express.js (using passport.js)

Setup the project folder

    mkdir passport-local
    npm init
    # Use default values for npm init prompts

Install required packages

@phalkunz
phalkunz / composer.json
Created April 13, 2018 02:57
Git pre-commit hook with PHPCS
{
...
"scripts": {
"post-install-cmd": "(cd .git/hooks/; ln -s -f ../../mysite/tools/git-pre-commit-hook ./pre-commit)"
},