Skip to content

Instantly share code, notes, and snippets.

View joujiahe's full-sized avatar

Johnson Chou joujiahe

View GitHub Profile
@joujiahe
joujiahe / terminal-shortcuts.txt
Last active August 29, 2015 14:05
Terminal Shortcuts
Control + L clear screen
Control + A cursor to start
Control + E cursor to end
Control + W delete a word
Control + U delete a line
Control + R autocomplete
@joujiahe
joujiahe / launch-clean-chrome
Created November 3, 2014 08:18
Launch Chrome with a clean profile
# OSX
open -a "Google Chrome" --args --user-data-dir=/dev/null
# Linux
google-chrome --user-data-dir=/dev/null
# Windows
"C:\Users\username\AppData\Local\Google\Chrome\Application\chrome.exe" --user-data-dir=/dev/null
@joujiahe
joujiahe / ie-detect.js
Created November 20, 2014 06:43
IE detection in JavaScript
function msieversion() {
var ua = window.navigator.userAgent,
msie = ua.indexOf("MSIE ");
// If IE, alert version
if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./))
alert(parseInt(ua.substring(msie + 5, ua.indexOf(".", msie))));
else
alert('otherbrowser');
@joujiahe
joujiahe / zsh256colors
Last active August 29, 2015 14:11
Show zsh 256 colors
for code in {000..255}; do print -P -- "$code: %F{$code}Test%f"; done
@joujiahe
joujiahe / route.js
Created September 2, 2015 18:38
Sample of JavaScript regexp route.
function route(url, params) {
return url.replace(/:(\w+)/g, function (match, p) {
return params[p];
});
}
@joujiahe
joujiahe / ellipsis.css
Created September 28, 2015 06:55
CSS Ellipsis
.ellipsis {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
@joujiahe
joujiahe / catch-any-error.js
Created May 12, 2016 05:42
Catch all error in browser
(function(){
/**
* Capture error data for debugging in web console.
*/
var captures = [];
/**
* Wait until `window.onload`, so any external scripts
@joujiahe
joujiahe / gitflow-breakdown.md
Created June 15, 2016 04:01 — forked from JamesMGreene/gitflow-breakdown.md
A comparison of using `git flow` commands versus raw `git` commands.

Initialize

gitflow git
git flow init git init
git commit --allow-empty -m "Initial commit"
git checkout -b develop master

Connect to the remote repository

@joujiahe
joujiahe / url_to_drive.js
Created November 7, 2017 10:32 — forked from denilsonsa/url_to_drive.js
Google Apps Script to upload a file from an URL directly to Google Drive.
// url_to_drive.gs
// Google Apps Script
// Allows uploading a URL directly to Google Drive.
//
// Live link:
// https://script.google.com/macros/s/AKfycbzvhbHS4hnWPVBDHjQzZHA0qWq0GR-6hY7TbYsNto6hZ0MeAFZt/exec
//
// Source-code:
// https://gist.github.com/denilsonsa/8134679
// https://script.google.com/d/1Ye-OEn1bDPcmeKSe4gb0YSK83RPMc4sZJt79SRt-GRY653gm2qVUptoE/edit
@joujiahe
joujiahe / idbkeyrange_forprefix.js
Created July 20, 2018 01:56 — forked from inexorabletash/idbkeyrange_forprefix.js
Helper for creating an IDBKeyRange for all keys with a given prefix
// Basic p(r)olyfill for proposed feature
// This defines no successor of empty arrays, so the range for prefix
// [] or [[],[]] has no upper bound.
// An alternate definition would preclude adding additional nesting,
// so the range for prefix [] would have upper bound [[]] and the
// range for prefix [[], []] would have upper bound [[], [[]]].
IDBKeyRange.forPrefix = function(prefix) {
// Ensure prefix is a valid key itself: