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

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 / gist:2411184
Created April 18, 2012 04:56 — forked from stojg/async-social-load.js
Async loading of javascript with callback
(function(d, s) {
var js, fjs = d.getElementsByTagName(s)[0], load = function(url, id, callback) {
if (d.getElementById(id)) {return;}
js = d.createElement(s);js.src = url;js.id = id;js.async=true;
fjs.parentNode.insertBefore(js,fjs);
if(callback!=undefined) {
js.onload=callback;
//Extra for internet explorer
js.onreadystatechange = function () { if(this.readyState == 'complete' || this.readyState == 'loaded') { callback(); } }
}
@phalkunz
phalkunz / js-func-url-vars.js
Created May 16, 2012 04:51
Function for extracting url query string variables from the `window.location`
/**
* Returns a literal object with properties mapped to the query string variables
* For example:
* input (page url): http://www.test.com/index?one=1&two=2
* value: { 'one': 1, 'two': 2 }
*/
function urlVars() {
var search = window.location.search;
if(search === '' || !search || search === '?') {
@phalkunz
phalkunz / js-time-profiler.js
Created June 19, 2012 02:11
Simple JS running time profiler
/**
* Profiling (running time). For dev purpose only.
*/
(function() {
window._profiler = {
'profiles': []
};
_profiler.time = function(name) {
_profiler.profiles[name] = new Date();
};
@phalkunz
phalkunz / mountain-lion-brew-setup.markdown
Created July 30, 2012 10:22 — forked from myobie/mountain-lion-brew-setup.markdown
Get Mountain Lion and Homebrew to Be Happy

Get Mountain Lion and Homebrew to Be Happy

1) Install XCode 4.4 into /Applications

Get it from http://developer.apple.com. You will not be able to submit apps to any stores using this XCode version, so turn away if that is something you might want to do.

2) Install Command Line Tools

In XCode's Preferences > Downloads you can install command line tools.