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
function getQueryParam(name) {
window.location.search
const paramStr = window.location.search.substr(1).split('&').find(param => param.includes(`${name}=`));
const nameValue = paramStr.split('=');
if (nameValue.length === 2) {
return nameValue[1];
}
return null;
@phalkunz
phalkunz / latest-checkouts.sh
Last active September 3, 2019 11:47
Get latest git checkout
history | grep -e "\d\+\s\+git checkout [^-.]\+" | awk '{ print $NF }' | tail -n 10
@phalkunz
phalkunz / sass-spacing-helper.scss
Last active September 3, 2019 11:47
Sass spacing helper
/**
* This is based on https://getbootstrap.com/docs/4.1/utilities/spacing/
*/
$directioMap: (
top: t,
right: r,
left: l,
bottom: b
);
@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)"
},
@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 / 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 / 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>

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname

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:

@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