Skip to content

Instantly share code, notes, and snippets.

View toshsan's full-sized avatar
🌴
On vacation

Santosh Sahoo toshsan

🌴
On vacation
  • CircleHD
  • San francisco
  • X @huhyroceq
View GitHub Profile
@toshsan
toshsan / gist:7faf3f67e6768196b7ad
Last active August 29, 2015 14:01 — forked from adamgreig/gist:6233882
TOPT Code generator, for use with Google Authenticator
import time
import hmac
import struct
import base64
import hashlib
def code(secret):
key = base64.b32decode(secret)
message = struct.pack(">Q", int(time.time()) / 30)
h = hmac.new(key, message, hashlib.sha1).digest()
@toshsan
toshsan / gist:ec7afd3c72445c40f2d5
Last active August 29, 2015 14:02 — forked from econchick/gist:4666413
Python implementation of Dijkstra's Algorithm
class Graph:
def __init__(self):
self.nodes = set()
self.edges = defaultdict(list)
self.distances = {}
def add_node(self, value):
self.nodes.add(value)
def add_edge(self, from_node, to_node, distance):
@toshsan
toshsan / cache.py
Last active August 29, 2015 14:13 — forked from craig552uk/cache.py
# -*- coding: utf-8 -*-
#
# A simple memory cache library
# Author: Craig Russell <[email protected]>
#
import time
class Cache(object):
/*
This code is public domain.
The MurmurHash3 algorithm was created by Austin Appleby and put into the public domain. See http://code.google.com/p/smhasher/
This C# variant was authored by
Elliott B. Edwards and was placed into the public domain as a gist
Status...Working on verification (Test Suite)
Set up to run as a LinqPad (linqpad.net) script (thus the ".Dump()" call)
*/
@toshsan
toshsan / nginx-s3-proxy
Last active October 6, 2017 19:27 — forked from mikhailov/gist:9639593
Nginx proxy to S3 with cache
# The Nginx configuration based on https://coderwall.com/p/rlguog
http {
ssl_certificate server.crt;
ssl_certificate_key server.key;
ssl_session_timeout 15m;
ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
#!/bin/sh
# Alot of these configs have been taken from the various places
# on the web, most from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Set the colours you can use
black='\033[0;30m'
white='\033[0;37m'
red='\033[0;31m'
# The Nginx configuration based on https://coderwall.com/p/rlguog
http {
ssl_certificate server.crt;
ssl_certificate_key server.key;
ssl_session_timeout 15m;
ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
@toshsan
toshsan / kafka.md
Last active August 29, 2015 14:24 — forked from ashrithr/kafka.md

Introduction to Kafka

Kafka acts as a kind of write-ahead log (WAL) that records messages to a persistent store (disk) and allows subscribers to read and apply these changes to their own stores in a system appropriate time-frame.

Terminology:

  • Producers send messages to brokers
  • Consumers read messages from brokers
  • Messages are sent to a topic
@toshsan
toshsan / livestream
Last active August 29, 2015 14:25 — forked from deandob/livestream
Node.JS function to remux mp4/h.264 video from an IP camera to a HTML5 video tag using FFMPEG
// Live video stream management for HTML5 video. Uses FFMPEG to connect to H.264 camera stream,
// Camera stream is remuxed to a MP4 stream for HTML5 video compatibility and segments are recorded for later playback
var liveStream = function (req, resp) { // handle each client request by instantiating a new FFMPEG instance
// For live streaming, create a fragmented MP4 file with empty moov (no seeking possible).
var reqUrl = url.parse(req.url, true)
var cameraName = typeof reqUrl.pathname === "string" ? reqUrl.pathname.substring(1) : undefined;
if (cameraName) {
try {
cameraName = decodeURIComponent(cameraName);
@toshsan
toshsan / default.conf
Last active August 29, 2015 14:27
nginx config - dynamic virtual hosts
server {
index index.php;
set $basepath "/var/www";
set $domain $host;
# check one name domain for simple application
if ($domain ~ "^(.[^.]*)\.dev$") {
set $domain $1;
set $rootpath "${domain}";