Skip to content

Instantly share code, notes, and snippets.

var http = require('http');
var server = http.createServer();
server.on('request', function(req,res){
res.writeHead(200, {});
res.write('Hello World');
res.end('bye');
});
@ekanna
ekanna / map2json.go
Created July 17, 2013 17:02
Generating arbitrary JSON data using map in golang
// Generating arbitrary JSON data using map
package main
import "fmt"
import "encoding/json"
func main() {
keys := []string{"Segment", "Jan", "Feb", "Apr"}
values := []interface{}{"ME",1000,2000,3000}
@ekanna
ekanna / sse.go
Created November 24, 2016 11:21 — forked from schmohlio/sse.go
Example SSE server in Golang
// v2 of the great example of SSE in go by @ismasan.
// includes fixes:
// * infinite loop ending in panic
// * closing a client twice
// * potentially blocked listen() from closing a connection during multiplex step.
package main
import (
"fmt"
"log"
@ekanna
ekanna / tmux-cheatsheet.markdown
Created February 22, 2017 18:56 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@ekanna
ekanna / sse.go
Created June 23, 2017 14:32 — forked from fiorix/sse.go
Go and Server Sent Events for HTTP/1.1 and HTTP/2.0
// Go and Server Sent Events for HTTP/1.1 and HTTP/2.0
//go:generate go run $GOROOT/src/crypto/tls/generate_cert.go -host localhost
package main
import (
"fmt"
"io"
"log"
"net/http"
@ekanna
ekanna / min-char-rnn.py
Created November 13, 2017 19:08 — forked from karpathy/min-char-rnn.py
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)
@ekanna
ekanna / shadow-dom.md
Created November 25, 2017 01:34 — forked from praveenpuglia/shadow-dom.md
Everything you need to know about Shadow DOM

Shadow DOM

Heads Up! It's all about the V1 Spec.

In a nutshell, Shadow DOM enables local scoping for HTML & CSS.

Shadow DOM fixes CSS and DOM. It introduces scoped styles to the web platform. Without tools or naming conventions, you can bundle CSS with markup, hide implementation details, and author self-contained components in vanilla JavaScript. - https://developers.google.com/web/fundamentals/getting-started/primers/shadowdom

It's like it's own little world which hardly affects or gets affected by the outside world.

@ekanna
ekanna / main.go
Created January 8, 2018 06:27 — forked from enricofoltran/main.go
A simple golang web server with basic logging, tracing, health check, graceful shutdown and zero dependencies
package main
import (
"context"
"flag"
"fmt"
"log"
"net/http"
"os"
"os/signal"
<script type="text/javascript">
// ref: http://stackoverflow.com/a/1293163/2343
// This will parse a delimited string into an array of
// arrays. The default delimiter is the comma, but this
// can be overriden in the second argument.
function CSVToArray( strData, strDelimiter ){
// Check to see if the delimiter is defined. If not,
// then default to comma.
strDelimiter = (strDelimiter || ",");