Skip to content

Instantly share code, notes, and snippets.

@tnhu
tnhu / fetch2.js
Created June 2, 2016 04:05
fetch2
/*
fetch() only rejects when network error occurs (offline), fetch2() rejects all non-200 statuses
*/
const fetch2 = api => fetch(api).then(res => res.ok ? res : Promise.reject(res));
@tnhu
tnhu / excel_generator.py
Created April 22, 2016 20:38
Open and Edit an Excel template using Python's openpyxl library
from openpyxl import load_workbook
wb = load_workbook('template.xlsx')
# grab the active worksheet
ws = wb.active
# Data can be assigned directly to cells
ws['A2'] = 'Tom'
ws['B2'] = 30
@tnhu
tnhu / visor-archivos-online.md
Last active December 10, 2018 12:15 — forked from izazueta/visor-archivos-online.md
Google Docs Viewer & Office Web Apps Viewer
@tnhu
tnhu / gist:9766c1db1731d2275f9d
Created September 29, 2015 01:07 — forked from helinwang/gist:ea9a2e88f20278d2cb53
golang https server
package main
import (
"net/http"
"fmt"
)
func handler(w http.ResponseWriter, r *http.Request) {
fmt.Println("Inside handler")
fmt.Fprintf(w, "Hello world from my Go program!")
@tnhu
tnhu / https_server.go
Created September 29, 2015 01:01 — forked from ericchiang/https_server.go
Golang HTTPS server
package main
import (
"net/http"
"strings"
)
/*
Generate cert.pem and key.pem with:
@tnhu
tnhu / Brackets-InteractiveLinter.json
Created July 27, 2015 21:40
Brackets Interactive Linter configuration
brackets.json
-------------
"language": {
"javascript": {
"linting.prefer": [
"JSHint"
],
"linting.usePreferredOnly": true
}
@tnhu
tnhu / property-changed.js
Last active August 29, 2015 14:21
[kanji, jsface] Intercept property changed
function makeSetter(name, fn) {
return function() {
console.log('setter: ', name , this);
return fn.apply(this, arguments);
}
}
Class.plugins.$interceptPropertyChanged = function invoke(clazz, parent, api)
{
for (var key in api) {
@tnhu
tnhu / EmberJS Training Notes.md
Last active August 29, 2015 14:17
EmberJS Training Notes

EmberJS version used: 2.0

Pod

Single unit for a component where resources are grouped in a folder under app/

application pod is specific pod for the application.

Route

@tnhu
tnhu / Declare A Block in Objective-C.md
Created March 20, 2015 20:00
Declare A Block in Objective-C

How Do I Declare A Block in Objective-C?

Source: http://fuckingblocksyntax.com

As a local variable:

returnType (^blockName)(parameterTypes) = ^returnType(parameters) {...};
/**
* Simple localStorage with Cookie Fallback
* v.1.0.0
*
* USAGE:
* ----------------------------------------
* Set New / Modify:
* store('my_key', 'some_value');
*
* Retrieve: