Skip to content

Instantly share code, notes, and snippets.


Rati Wannapanop ratiw

  • Nonthaburi, Thailand
View GitHub Profile
fajrif / gist:1265203
Created Oct 5, 2011
git clone specific tag
View gist:1265203
git clone <repo-address>
git tag -l
git checkout <tag-name>
git branch -D master
git checkout -b master
CristinaSolana / gist:1885435
Created Feb 22, 2012
Keeping a fork up to date
View gist:1885435

1. Clone your fork:

git clone

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://
git fetch upstream
kflorence / scrollbarWidth.js
Created Jul 10, 2012
Calculate scroll bar width cross-browser
View scrollbarWidth.js
function getScrollBarWidth() {
var inner = document.createElement('p'); = "100%"; = "200px";
var outer = document.createElement('div'); = "absolute"; = "0px"; = "0px"; = "hidden";
philsturgeon / gist:5465246
Last active May 23, 2022
API Golden Rules
View gist:5465246

Never Expose DB Results Directly

  1. If you rename a field, then your users are fucked. Convert with a hardcoded array structure.
  2. Most DB drivers [for PHP] will show integers as numeric strings and false as "0", so you want to typecast them.
  3. Unless you're using an ORM with "hidden" functionality, people will see passwords, salts and all sorts of fancy codes. If you add one and forget to put it in your $hidden array then OOPS!

Use the URI sparingly, and correctly

  1. Use the query string for paired params instead of /users/id/5/active/true. Your API does not need to be SEO optimised.
  2. ?format=xml is stupid, use an Accept: application/xml header. I added this to the CodeIgniter Rest Server once for lazy people, and now people think it's a thing. It's not.
rxaviers / gist:7360908
Last active Nov 27, 2022
Complete list of github markdown emoji markup
View gist:7360908


:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue:
mobilemind /
Last active Nov 27, 2022
how to delete a git tag locally and remote
# delete local tag '12345'
git tag -d 12345
# delete remote tag '12345' (eg, GitHub version too)
git push origin :refs/tags/12345
# alternative approach
git push --delete origin tagName
git tag -d tagName
liunian / gist:9338301
Last active Jul 9, 2022
Human Readable File Size with PHP
View gist:9338301
function human_filesize($bytes, $decimals = 2) {
$size = array('B','kB','MB','GB','TB','PB','EB','ZB','YB');
$factor = floor((strlen($bytes) - 1) / 3);
return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . @$size[$factor];
echo human_filesize(filesize(''));
View example.conf
server {
# Redirect any subdomain to the root domain
# to be captured by next server block
server_name *;
return 301 $scheme://$request_uri;
server {
root /var/www;
index index.html index.htm;
vladikoff /
Last active Sep 11, 2022
Setup Persistent Aliases & Macros in Windows Command Prompt (cmd.exe) using DOSKey

Setup Persistent Aliases & Macros in Windows Command Prompt (cmd.exe) using DOSKey

Saved from, Date: May 14, 2010 Author: Jesse Webb

Our development machines here at Point2 are not standardized; we have a mixture of Windows XP, 7, and Mac OSX/Unix computers. I find myself constantly switching back and forth between command prompt interfaces when pair programming. As a result, I catch myself using “ls” to list a directories contents regardless of what system I am on. I am currently using a Windows XP machine for my developer box and I wanted to setup an alias to the “ls” command to actually perform a “dir”. Here is how I accomplished it…

There is a command available in a Window’s shell that let’s you “alias” command to whatever you please: DOSKey. It allows you to create “macros” to execute one or more other commands with a custom nam

yoavniran /
Last active Nov 22, 2022
The Ultimate Unit Testing Cheat-sheet For Mocha, Chai, Sinon, and Jest