Skip to content

Instantly share code, notes, and snippets.

View mingliangguo's full-sized avatar

Mingliang mingliangguo

View GitHub Profile
@mingliangguo
mingliangguo / .bash_profile
Created June 21, 2011 10:45 — forked from wimleers/.bash_profile
My bash prompt. Inelegant code, yet elegant result.
# Colorizing. Source: http://systhread.net/texts/200703bashish.php.
DULL=0
BRIGHT=1
FG_BLACK=30
FG_RED=31
FG_GREEN=32
FG_YELLOW=33
FG_BLUE=34
@mingliangguo
mingliangguo / .bash_profile
Created June 22, 2011 02:47 — forked from wimleers/.bash_profile
My bash prompt. Inelegant code, yet elegant result.
# Colorizing. Source: http://systhread.net/texts/200703bashish.php.
DULL=0
BRIGHT=1
FG_BLACK=30
FG_RED=31
FG_GREEN=32
FG_YELLOW=33
FG_BLUE=34
@mingliangguo
mingliangguo / apiexamples.js
Created July 26, 2012 10:22 — forked from jrburke/apiexamples.js
Description of browser-friendly module APIs: AMD and Loader Plugins
//*******************************************
// Level 1, basic API, minimum support
//*******************************************
/*
Modules IDs are strings that follow CommonJS
module names.
*/
//To load code at the top level JS file,
//or inside a module to dynamically fetch
@mingliangguo
mingliangguo / gist:3291698
Created August 8, 2012 03:06 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@mingliangguo
mingliangguo / keyrepeat.shell
Last active October 24, 2016 14:38 — forked from kconragan/keyrepeat.shell
keyrepeat.shell
# Mac OS X Lion introduced a new, iOS-like context menu when you press and hold a key
# that enables you to choose a character from a menu of options. If you are on Lion
# try it by pressing and holding down 'e' in any app that uses the default NSTextField
# for input.
#
# It's a nice feature and continues the blending of Mac OS X and iOS features. However,
# it's a nightmare to deal with in Sublime Text 2 if you're running Vintage (Vim) mode,
# as it means you cannot press and hold h/j/k/l to move through your file. You have
# to repeatedly press the keys to navigate.
@mingliangguo
mingliangguo / Sublime Text 2 - Useful Shortcuts (Mac OS X)
Last active October 24, 2016 14:37 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts (Mac OS X)
h1. Sublime Text 2 - Useful Shortcuts (Mac OS X)
h2. General
| *⌘T* | go to file |
| *⌘⌃P* | go to project |
| *⌘R* | go to methods |
| *⌃G* | go to line |
| *⌘KB* | toggle side bar |
| *⌘⇧P* | command prompt |
Error: Failed to update tap: caskroom/versions
brew untap caskroom/cask
brew update
brew cleanup --force -s
rm -rf "$(brew --cache)"
brew tap caskroom/cask
This removed what I believe is a unnecessary single quote in the rm command and a period that was probably not intended after the last command
Also in my case, I needed to add sudo for the remove command
var xhr = new XMLHttpRequest();
xhr.open("GET", "https://api.box.com/2.0/files/76537235577/thumbnail.png?min_height=150&min_width=150", true);
xhr.setRequestHeader("Authorization", "Bearer your_access_token");
xhr.responseType = "arraybuffer";
xhr.onload = function(e) {
if (this.status == 200) {
var uInt8Array = new Uint8Array(this.response);
var i = uInt8Array.length;
var binaryString = new Array(i);
@mingliangguo
mingliangguo / get box thumbnail url
Created August 1, 2016 03:52
A simpler version to get box thumbnail URI
var xhr = new XMLHttpRequest();
xhr.open("GET", "https://api.box.com/2.0/files/76537235577/thumbnail.png?min_height=150&min_width=150", true);
xhr.setRequestHeader("Authorization", "Bearer your_access_token");
xhr.responseType = "arraybuffer";
xhr.onload = function(e) {
if (this.status == 200) {
var uInt8Array = new Uint8Array(this.response);
var blob = new Blob([uInt8Array], {type: 'application/octet-binary'}); // pass a useful mime type here
var url = URL.createObjectURL(blob);
@mingliangguo
mingliangguo / use blob to read thumbnail content
Created August 3, 2016 02:45
An even simpler version to get box thumbnail URL (or any other binary content)
var xhr = new XMLHttpRequest();
xhr.open("GET", "https://api.box.com/2.0/files/76537235577/thumbnail.png?min_height=150&min_width=150", true);
xhr.setRequestHeader("Authorization", "Bearer your_access_token");
xhr.responseType = "blob";
xhr.onload = function(e) {
if (this.status == 200) {
var blob = xhr.response;
var url = URL.createObjectURL(xhr.response);