Skip to content

Instantly share code, notes, and snippets.

View gorakhargosh's full-sized avatar

Yesudeep Mangalapilly gorakhargosh

View GitHub Profile
#!/usr/bin/env python
# -*- coding: utf-8; indent-tabs-mode: nil; tab-width: 4; -*-
import argparse
import fnmatch
import glob
import os
import pprint
import shutil
import sys
@gorakhargosh
gorakhargosh / experience.py
Created November 14, 2014 04:55
Work experience calculator.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import datetime
def experience(start, end):
months = (end.year - start.year)*12 + end.month - start.month
return divmod(months, 12)
@gorakhargosh
gorakhargosh / bhojo-install-go.sh
Created November 30, 2014 20:51
bhojo-install-go.sh
#!/bin/bash
#
# Separate because this is a major script on its own.
# ------------------------------------------------------------------------------
# Go lang compiler and runtime.
# ------------------------------------------------------------------------------
GO_VERSION=1.3.3
_GO_INSTALLED_VERSION=`go version 2>&1 | awk -Fgo '{ print $3 }' | awk '{ print $1 }'`
@gorakhargosh
gorakhargosh / pdnsd.plist
Created January 2, 2015 16:38
/Library/LaunchDaemons/pdnsd.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>pdnsd</string>
<key>OnDemand</key>
<false/>
<key>Program</key>
<string>/usr/local/sbin/pdnsd</string>
@gorakhargosh
gorakhargosh / resignation.go
Created July 29, 2015 06:38
How to Resign
package main
import (
"fmt"
"math/rand"
"time"
)
const (
Day time.Duration = time.Hour * 24
/**
* Fisher-Yates in-place shuffle.
*
* @see: http://bost.ocks.org/mike/algorithms/#shuffling
* @param {!Array} array An array of items.
*/
var fisherYatesShuffle = function(array) {
var n = array.length
var t;
var i;
@gorakhargosh
gorakhargosh / rob.go
Last active August 29, 2015 14:27 — forked from Jxck/rob.go
gocon 2014
type errWriter struct {
w io.Writer
err error
}
func (e *errWriter) Write(p []byte) {
if e.err != nil {
return
}
_, e.err = e.w.Write(p)
@gorakhargosh
gorakhargosh / semaphore.go
Created September 18, 2015 16:23
interface and internal (blackbox) implementation.
// Package semaphore contains implementations of counting semaphores using both
// buffered channels and condition variables.
package semaphore
import "errors"
// Semaphore defines the protocol for any counting semaphore.
type Semaphore interface {
// Acquire blocks until a slot can be acquired in the counting semaphore.
Acquire()
package main
import (
"fmt"
"log"
"math/big"
)
// readInt reads an integer from standard input.
func readInt() (int, error) {