Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / 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 / 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 / DumpStack.java
Created July 13, 2016 22:41
Dump Java stack trace without throwing an exception
import org.apache.commons.lang3.exception.ExceptionUtils;
import play.Logger;
String stackTrace = ExceptionUtils.getStackTrace(new Exception()));
// Log warning with stack trace for a deprecated method
Logger.warn("Method is deprecated: " + stackTrace);
@tnhu
tnhu / postgres-cheatsheet.md
Created December 16, 2016 02:19 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

If run with -E flag, it will describe the underlaying queries of the \ commands (cool for learning!).

Most \d commands support additional param of __schema__.name__ and accept wildcards like *.*

@tnhu
tnhu / gist:4569211a3f1c6758ba22e7281aa739b3
Created January 12, 2017 00:48
Sublime regular expression search & replace
Find what: (^.*): (.*$)
Replace with: "$1": "$2",
--
Before:
memberOf: CN=Realtime Systems,OU=DEPT,OU=Groups,DC=corp,DC=qc
department: Inventory & DMP
After:
@tnhu
tnhu / icons.css
Created October 19, 2017 18:16
icons.css
:root {
--icon-pending: url('data:image/svg+xml;utf8,<?xml version="1.0" encoding="utf-8"?><svg version="1.1" id="SUCCESS_1_" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 16 16" style="enable-background:new 0 0 16 16;" xml:space="preserve"><style type="text/css">.st0{fill-rule:evenodd;clip-rule:evenodd;fill:%23DBDCDD;} .st1{fill-rule:evenodd;clip-rule:evenodd;fill:%23FFFFFF;} </style> <g id="Ellipse_524"> <g> <circle class="st0" cx="8" cy="8" r="8"/> </g> </g> <g id="Ellipse_1551"> <g> <circle class="st1" cx="8" cy="8" r="6"/> </g> </g> </svg>');
--icon-queued: url('data:image/svg+xml;utf8,<?xml version="1.0" encoding="utf-8"?><svg version="1.1" id="QUE_1_copy_1_" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 16 16" style="enable-background:new 0 0 16 16;" xml:space="preserve"> <style type="text/css"> .st0{fill:#E1E4E5;} .st1{fill:#FFFFFF;} .st2{fill:#C3C8CA;} </style> <g id="Ellipse_