Skip to content

Instantly share code, notes, and snippets.

@tnhu
tnhu / web-servers.md
Last active March 23, 2020 20:33 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8181
@tnhu
tnhu / curl.md
Created August 30, 2018 00:13 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@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 / 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:
/**
* Simple localStorage with Cookie Fallback
* v.1.0.0
*
* USAGE:
* ----------------------------------------
* Set New / Modify:
* store('my_key', 'some_value');
*
* Retrieve:
@tnhu
tnhu / gist:939f9172befc8edf244a
Last active August 29, 2015 14:06 — forked from anonymous/gist:1406238
Scala's complexity
Originally:
https://gist.github.com/7565976a89d5da1511ce
Hi Donald (and Martin),
Thanks for pinging me; it's nice to know Typesafe is keeping tabs on this, and I
appreciate the tone. This is a Yegge-long response, but given that you and
Martin are the two people best-situated to do anything about this, I'd rather
err on the side of giving you too much to think about. I realize I'm being very
critical of something in which you've invested a great deal (both financially
@tnhu
tnhu / fnv32_hash.js
Last active December 29, 2023 22:48 — forked from vaiorabbit/fnv32a.js
Shortest JavaScript String Hash implementation
// 32 bit FNV-1a hash
// Ref.: http://isthe.com/chongo/tech/comp/fnv/
function fnv32a(str) {
var FNV1_32A_INIT = 0x811c9dc5,
hval = FNV1_32A_INIT,
i, len;
for (i = 0, len = str.length; i < len; i++) {
hval ^= str.charCodeAt(i);
hval += (hval << 1) + (hval << 4) + (hval << 7) + (hval << 8) + (hval << 24);
@tnhu
tnhu / minscalaactors.scala
Created April 13, 2012 07:25 — forked from viktorklang/minscalaactors.scala
Minimalist Scala Actors
©2012 Viktor Klang
object Actor {
import java.util.concurrent.{ConcurrentLinkedQueue, Executor}
import java.util.concurrent.atomic.{AtomicBoolean}
type Behavior = Any => Effect
sealed trait Effect { def getOrElse(old: Behavior): Behavior }
case object Stay extends Effect { def getOrElse(old: Behavior): Behavior = old }
case class Become(like: Behavior) extends Effect { def getOrElse(old: Behavior): Behavior = like }