Skip to content

Instantly share code, notes, and snippets.

View bpceee's full-sized avatar
💭
In meditation

Ken Bi bpceee

💭
In meditation
  • Auckland, New Zealand
View GitHub Profile
@bpceee
bpceee / gist:e447405a777a3c67b5a5
Created December 28, 2015 06:28 — forked from Mithrandir0x/gist:3639232
Difference between Service, Factory and Provider in AngularJS
// Source: https://groups.google.com/forum/#!topic/angular/hVrkvaHGOfc
// jsFiddle: http://jsfiddle.net/pkozlowski_opensource/PxdSP/14/
// author: Pawel Kozlowski
var myApp = angular.module('myApp', []);
//service style, probably the simplest one
myApp.service('helloWorldFromService', function() {
this.sayHello = function() {
return "Hello, World!"
@bpceee
bpceee / printPrototypeChain.js
Created December 13, 2015 09:09 — forked from LukeChannings/printPrototypeChain.js
prints the prototype chain for a constructed object.
/**
* prints the prototype chain for a constructed object.
* @param {Object} a constructed object.
* @param asArray {Boolean} if true, the chain will be returned as an array.
*/
function printPrototypeChain(instance, asArray) {
var chain = []
while (instance = Object.getPrototypeOf(instance)) {
@bpceee
bpceee / dropzone-directive.js
Created October 24, 2015 03:49 — forked from compact/dropzone-directive.js
AngularJS directive for Dropzone.js
/**
* An AngularJS directive for Dropzone.js, http://www.dropzonejs.com/
*
* Usage:
*
* <div ng-app="app" ng-controller="SomeCtrl">
* <button dropzone="dropzoneConfig">
* Drag and drop files here or click to upload
* </button>
* </div>
@bpceee
bpceee / uri.js
Last active August 29, 2015 14:27 — forked from jlong/uri.js
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@bpceee
bpceee / qcUpdateRouter.python
Last active August 29, 2015 14:06
qingcloud update router
import qingcloud.iaas
from qingcloud.iaas.router_static import RouterStaticFactory
access_key = 'xxx'
secret_key = 'xxx'
conn = qingcloud.iaas.connect_to_zone('gd1', access_key, secret_key)
router = 'rtr-xxxxxxxx'
# add port forwarding static
@bpceee
bpceee / install_nginx.sh
Last active August 29, 2015 14:00 — forked from simonw/gist:92481
Compile nginx standalone without root access
# Compile nginx standalone without root access
mkdir ~/installed
mkdir ~/installed/nginx
mkdir ~/src
cd ~/src
# PCRE dependency - we'll compile against this statically
wget http://kent.dl.sourceforge.net/sourceforge/pcre/pcre-7.8.tar.gz
tar -xzvf pcre-7.8.tar.gz
#!/usr/bin/env python
"""Simple HTTP Server With Upload.
This module builds on BaseHTTPServer by implementing the standard GET
and HEAD requests in a fairly straightforward manner.
"""