Skip to content

Instantly share code, notes, and snippets.

View ashwanthkumar's full-sized avatar

Ashwanth Kumar ashwanthkumar

View GitHub Profile
@sato-cloudian
sato-cloudian / install_OpenBLAS.sh
Last active December 7, 2016 13:04
OpenBlas Installation on CentOS 6.5
#!/bin/bash
set -e
echo "checking out OpenBLAS..."
git clone https://github.com/xianyi/OpenBLAS.git
cd OpenBLAS
git checkout v0.2.15
echo "installing newer binutils..."

Trait with superaccessor

here's T.scala:

trait T1 {
  def x = 3
}
trait T2 extends T1 {
  override def x = super.x + 1

}

@kirked
kirked / JsonLens.scala
Last active June 8, 2022 07:48
A lens wrapper over spray-json
import scala.reflect.ClassTag
import scala.util.{Either, Left, Right}
import spray.json._
object JsonLens {
class Json(val value: Option[JsValue]) {
def /(name: String): Json = Json(value.flatMap(_.asJsObject.fields.get(name)))
def -(name: String): Json = Json(value.map(obj => JsObject(obj.asJsObject.fields - name)))
def apply(index: Int): Json = {
@numberoverzero
numberoverzero / boto3_retry.py
Created July 8, 2015 21:48
Exponential backoff retries
import botocore
import boto3
import functools
import time
DEFAULT_BACKOFF_COEFF = 50.0
DEFAULT_MAX_ATTEMPTS = 4
MAX_BATCH_SIZE = 25
RETRYABLE_ERRORS = [
@rschreijer
rschreijer / MetricRegistryJsonProtocol.scala
Last active September 17, 2019 23:53
spray-json protocol for the Metric lib. Serializes a MetricRegistry and/or single Metric objects from Spray. See https://dropwizard.github.io/metrics, https://github.com/spray/spray-json
package spray.json.examples
import java.util.concurrent.TimeUnit
import scala.collection.JavaConverters._
import scala.util.{Try, Success, Failure}
import com.codahale.metrics._
import spray.json._
@madevelopers
madevelopers / readzip.go
Created January 29, 2015 09:36
golang: Read zip file
package main
import (
"archive/zip"
"fmt"
"io/ioutil"
)
type myCloser interface {
Close() error
@acolyer
acolyer / service-checklist.md
Last active February 20, 2025 12:04
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?
@hyg
hyg / gist:9c4afcd91fe24316cbf0
Created June 19, 2014 09:36
open browser in golang
func openbrowser(url string) {
var err error
switch runtime.GOOS {
case "linux":
err = exec.Command("xdg-open", url).Start()
case "windows":
err = exec.Command("rundll32", "url.dll,FileProtocolHandler", url).Start()
case "darwin":
err = exec.Command("open", url).Start()
@quiiver
quiiver / ElasticsearchSource.scala
Created May 5, 2014 17:38
Scalding source for Elasticsearch
package com.twitter.scalding.sources
import cascading.tuple.Fields
import cascading.tap.Tap;
import org.elasticsearch.hadoop.cascading.EsTap
import com.twitter.scalding._
abstract class ElasticsearchSource extends Source {
@neerav1985
neerav1985 / Calculate_Implied_Vol.py
Last active December 6, 2022 15:11
Calculate Implied Volatility of an option price given its market price
from numpy import *
from scipy.stats import norm
from scipy.optimize import root, fsolve, newton
import logging
logging.basicConfig(format='%(asctime)s %(levelname)s %(message)s', level=logging.DEBUG)
def BlackScholesCall(S, K, T, sigma, r = 0., q = 0.):
#logging.debug("S=" + str(S) + ",K=" + str(K) + ",T=" + str(T) + ",sigma=" + str(sigma) + ",r=" + str(r) + ",q=" + str(q) )