Skip to content

Instantly share code, notes, and snippets.

View montanaflynn's full-sized avatar

Montana Flynn montanaflynn

View GitHub Profile
@montanaflynn
montanaflynn / strings.go
Created November 16, 2014 09:07
Go strings
package main
import "fmt"
func main() {
// Create a string
str := "Hello"
// Split it into unicode characters
@montanaflynn
montanaflynn / temp.md
Last active August 29, 2015 14:10
doc.md
# Project // pull from package.json

description // pull from package.json

# Install 

installation // pull from examples.md

# Usage
@montanaflynn
montanaflynn / 2014
Created November 20, 2014 11:57
My MIT Licenses
The MIT License
Copyright 2014 Montana Flynn (http://anonfunction.com)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
@montanaflynn
montanaflynn / status-codes.md
Last active August 29, 2015 14:10
HTTP Response Status Codes

HTTP Response Status Codes

100 Continue - RFC7231#6.2.1

indicates that the initial part of a request has been received and has not yet been rejected by the server.

101 Switching Protocols - RFC7231#6.2.2

indicates that the server understands and is willing to comply with the client's request, via the Upgrade header field, for a change in the application protocol being used on this connection.

@montanaflynn
montanaflynn / main.go
Last active August 29, 2015 14:10
Decoding JSON in Golang
package main
import (
"fmt"
"encoding/json"
)
type User struct {
User UserData `json:"User"`
}
@montanaflynn
montanaflynn / promises.js
Created November 24, 2014 13:18
Native node promise
var promise = new Promise(function(resolve, reject) {
if (true) {
resolve("wow")
}
else {
reject(Error("nope"))
}
})
promise.then(function(res) {
@montanaflynn
montanaflynn / colors.md
Last active December 10, 2016 21:21
ANSI color escape codes

Foreground

  • FgBlack = "\033[30m"
  • FgRed = "\033[31m"
  • FgGreen = "\033[32m"
  • FgYellow = "\033[33m"
  • FgBlue = "\033[34m"
  • FgMagenta = "\033[35m"
  • FgCyan = "\033[36m"
  • FgWhite = "\033[37m"
@montanaflynn
montanaflynn / counter.js
Last active August 29, 2015 14:10
Examples of using ES6 generators
function* counter() {
var n = 0;
while (true) {
yield n++;
}
}
for (var number of counter()) {
console.log('counter is at', number);
}
@montanaflynn
montanaflynn / proxy.go
Last active June 10, 2025 01:42
Golang reverse proxy
package main
import (
"log"
"net/http"
"net/http/httputil"
)
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
@montanaflynn
montanaflynn / streamer.js
Created January 27, 2015 19:38
Streaming a response with Express.js
var express = require('express')
var app = express()
app.listen(1337)
app.all('/stream/:chunks', function (req, res, next) {
res.writeHead(200, {
'Content-Type': 'text/plain',