Skip to content

Instantly share code, notes, and snippets.

@prasincs
prasincs / gorilla_auth.go
Created March 20, 2017 00:17 — forked from jbuchbinder/gorilla_auth.go
Gorilla mux + basic authentication from htpasswd file
package main
import (
auth "github.com/abbot/go-http-auth"
"github.com/gorilla/mux"
"log"
"net/http"
"time"
)
@prasincs
prasincs / cluster_lines.py
Created March 18, 2017 08:30 — forked from amix/cluster_lines.py
Groups (clusters) similar lines together from a text file using k-means clustering algorithm.
"""
Groups (clusters) similar lines together from a text file
using k-means clustering algorithm.
Also does some simple cleaning (such as removing white space and replacing numbers with (N)).
Example:
python cluster_lines.py --clusters 20 invalid_dates.txt
@prasincs
prasincs / gh.sh
Created December 29, 2016 08:27
gh
#!/bin/sh
#
# Opens the github page for a repo/branch in your browser.
#
# gh [remote] [branch] [file]
git rev-parse 2>/dev/null
if [[ $? != 0 ]]
then
@prasincs
prasincs / service-checklist.md
Created September 12, 2016 07:12 — forked from acolyer/service-checklist.md
Internet Scale Services Checklist

Internet Scale Services Checklist

A checklist for designing and developing internet scale services, inspired by James Hamilton's 2007 paper "On Desgining and Deploying Internet-Scale Services."

Basic tenets

  • Does the design expect failures to happen regularly and handle them gracefully?
  • Have we kept things as simple as possible?
@prasincs
prasincs / riemann-ack.config
Created January 5, 2016 17:16
Riemann-ack hack
;; -*- mode: Clojure; -*-
;(load-from-resource "/Users/pgautam/Projects/riemann-acknowledgement/target/riemann-acknowledgement-0.1.3.jar")
(include "../include")
(load-plugins)
(instrumentation {:interval 5
:enabled? false})
(let [host "0.0.0.0"]
import csv,sys
if len(sys.argv) < 3:
print "Need input and output filenames"
sys.exit(0)
inFile = open(sys.argv[1], "rU")
reader = csv.DictReader(inFile)
destFieldNames = reader.fieldnames
@prasincs
prasincs / json_marshalling.go
Last active December 20, 2015 01:29
Golang hacks/experiments
package main
import (
"encoding/json"
"time"
"fmt"
"strconv"
)
type jsonTime time.Time
@prasincs
prasincs / balanced_smileys.py
Created January 27, 2013 17:00
Facebook Hacker Cup 2013 qualification solutions
import sys
from collections import Counter
import string,re
input_stream = sys.stdin
cases = int(input_stream.readline())
def is_understandable(input_str):
_string = input_str.replace(':)', '').replace(':(', '')
stack = []
for char in _string:
@prasincs
prasincs / disable-win-key.reg
Created January 24, 2013 20:58
disables Windows key capture in Windows -- was bugging me with XMonad.
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer]
"NoWinKeys"=dword:00000001
@prasincs
prasincs / prime_days.clj
Last active November 18, 2015 08:29
Primes and Palidromes
(ns prime-days
(:require [clj-time.core :as t]
[clj-time.format :as f]
[clojure.pprint :refer [pprint]]))
(defn prime? [n]
(.isProbablePrime (BigInteger/valueOf n) 1))
(defn formatted-date [n]
(f/unparse