Skip to content

Instantly share code, notes, and snippets.

View KushalP's full-sized avatar

Kushal Pisavadia KushalP

View GitHub Profile
@KushalP
KushalP / Builder.scala
Created July 18, 2014 11:59 — forked from flashingpumpkin/Builder.scala
My take on @flashingpumpkin's PizzaBuilder
case class Pizza(dough: String, sauce: String, topping: String) {
override def toString: String = {
"Dough:" + dough + " Topping:" + topping + " Sauce:" + sauce
}
}
abstract class PizzaBuilder {
def withDough(dough: String): PizzaBuilder
def withSauce(sauce: String): PizzaBuilder
def withTopping(topping: String): PizzaBuilder
@KushalP
KushalP / git-push.sh
Created July 3, 2014 10:34
Example function for @Rem from his tweet here: https://twitter.com/rem/status/484645092217860097
#!/bin/sh
function gp {
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
$(git push origin $CURRENT_BRANCH)
}
@KushalP
KushalP / NOTES.md
Last active August 29, 2015 14:01
This is a minimal reproducible test case to show that between go 1.1.2 and go 1.2 the error behaviour for HTTP requests with an incorrect Content-Length changed in a backwards-incompatible way.

Regression in net/http between Go 1.1.2 and Go 1.2

Between Go 1.1.2 and Go 1.2 the net/http package changed behaviour in how it handled bad Content-Length values in requests.

Link to issue: https://code.google.com/p/go/issues/detail?id=8003

Versions

Tested using go version go1.2.1 linux/amd64 and go version go1.1.2 linux/amd64. Also tested using go version devel +f8b50ad4cac4 Mon Apr 21 17:00:27 2014 -0700 + darwin/amd64.

@KushalP
KushalP / bookmarklet.js
Last active August 29, 2015 13:56
Bookmarklet that replaces uses of IL0...IL9 with random colours of the rainbow.
// Paste the below into your address bar where the "Impact Level" acronym is used.
javascript:function replaceILUse(){function randomRainbowColour(){return ["Red","Orange","Yellow","Green","Blue","Indigo","Violet"].sort(function(){return 0.5-Math.random()})[0]}function rainbowMatcher(match,p1,offset,string){return randomRainbowColour()}var original=document.body.innerHTML;document.body.innerHTML=original.replace(/IL[0-9]/ig,rainbowMatcher)}replaceILUse();
{
"title": "Tax Platform",
"services": {
"query": {
"idQueue": [
1,
2,
3,
4
import scala.util.Random
object Suit extends Enumeration {
type Suit = Value
val Diamonds, Spades, Hearts, Clubs = Value
}
object Rank extends Enumeration {
type Rank = Value
val Ace, Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten, Jack, Queen, King = Value
@KushalP
KushalP / cards.clj
Created February 16, 2014 19:29
Example implementation of card shuffling in Clojure
(def suits [:clubs :hearts :spades :diamonds])
(def ranks [2 3 4 5 6 7 8 9 10 :jack :queen :king :ace])
(def deck (for [s suits, r ranks] [s r]))
(println "Shuffled deck:" (shuffle deck))
@KushalP
KushalP / cards.hs
Last active October 29, 2016 08:32
Playing around with Haskell to see how easy it is to use the type system to create a deck of cards
import System.Random
import System.Random.Shuffle
data Suit = Club
| Diamond
| Heart
| Spade
deriving (Enum, Eq, Show)
data Rank = Ace | Two | Three | Four | Five
@KushalP
KushalP / DeckOfCards.fs
Created February 13, 2014 22:18
Playing around with F# to see how easy it is to use the type system to create a deck of cards
type Suit =
| Club
| Diamond
| Heart
| Spade
type Rank =
| Ace
| King
| Queen
{
title: "Logstash Search",
services: {
query: {
list: {
0: {
query: "{{ARGS.query || '*'}}",
alias: "",
color: "#7EB26D",
id: 0,