Skip to content

Instantly share code, notes, and snippets.

@shivakar
shivakar / self-signed-tls-server.go
Last active January 21, 2022 07:24
Self Signed TLS Server
package main
import (
"crypto/rand"
"crypto/rsa"
"crypto/x509"
"crypto/x509/pkix"
"encoding/pem"
"log"
"math/big"
@shivakar
shivakar / tls-server-in-memory-cert.go
Created December 12, 2015 17:16
TLS server with in-memory self-signed certificate
package main
import (
"crypto/rand"
"crypto/rsa"
"crypto/tls"
"crypto/x509"
"crypto/x509/pkix"
"errors"
"log"
@shivakar
shivakar / binary-conversion.go
Created December 30, 2015 13:55
Union Trick - Dynamic value interpretation
package main
import (
"bytes"
"encoding/binary"
"fmt"
"math"
)
func main() {
@shivakar
shivakar / summarize.py
Created March 16, 2016 14:04 — forked from rodricios/summarize.py
Flipboard's summarization algorithm, sort of
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
pip install networkx distance pattern
In Flipboard's article[1], they kindly divulge their interpretation
of the summarization technique called LexRank[2].
@shivakar
shivakar / rfcreader.go
Last active March 25, 2017 02:47
MVP for a command line RFC reader
package main
import (
"bufio"
"fmt"
"io/ioutil"
"log"
"net/http"
"os"
"strings"
@shivakar
shivakar / update-using-old-values.go
Created April 10, 2017 23:54
Updating variables using older values of the variables
import "fmt"
func printVariables(message string, a, b, c int64) {
fmt.Println(message)
fmt.Println("a = ", a)
fmt.Println("b = ", b)
fmt.Println("c = ", c)
fmt.Println("")
}
@shivakar
shivakar / create_gif
Created May 24, 2017 02:54
Create GIF from a video using ffmpeg and gifsicle
#!/usr/bin/env bash
if [ $# -ne 2 ]; then
echo "$0 - Creates a GIF from a video using ffmpeg and gifsicle"
echo "Usage: $0 <input-filename> <output-filename>"
exit
fi
infile="${1}"
outfile="${2}"
@shivakar
shivakar / RangeHTTPServer.py
Created May 24, 2017 05:11
Python's SimpleHTTPServer extended to handle HTTP/1.1 Range requests
import os
import SimpleHTTPServer
from SimpleHTTPServer import SimpleHTTPRequestHandler
class RangeHTTPRequestHandler(SimpleHTTPRequestHandler):
"""RangeHTTPRequestHandler is a SimpleHTTPRequestHandler
with HTTP 'Range' support"""
def send_head(self):
"""Common code for GET and HEAD commands.
@shivakar
shivakar / mjpeg-streamer.go
Created March 3, 2018 18:44
Webcam streaming over HTTP
package main
import (
"flag"
"fmt"
"image"
"image/color"
"log"
"net/http"
"time"