Skip to content

Instantly share code, notes, and snippets.

@sathish316
sathish316 / fpresources.md
Last active August 10, 2023 17:40
Functional Programming (FP) Resources
package com.algos.shuffle;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.Stream;
public class WeightedRandom {
private final double[] cdf;
private final double[] weights;
@sathish316
sathish316 / functional_programming_resources.md
Last active December 9, 2016 13:42
Functional programming resources

Books:

  1. Little Schemer - https://www.flipkart.com/little-schemer/p/itmczyygwrwdmyhz
  2. Structure and Interpretation of Computer Programs (SICP) - https://www.flipkart.com/structure-interpretation-computer-programs-2nd/p/itmegmt2qzfbnjqg
  3. Programming in Scala - Martin Odersky - http://www.artima.com/shop/programming_in_scala_3ed
  4. Haskell from first principles - Chris Allen & Julie - http://haskellbook.com/
  5. O'Reilly Java 8 Lambdas - https://www.flipkart.com/java-8-lambdas/p/itmdpr4h259kf2qy?pid=9781449370770

Courses:

@sathish316
sathish316 / DropwizardAsyncResource.java
Created February 9, 2016 09:19
Dropwizard AsyncResponse usage
package com.xyz.dw.resource;
import com.codahale.metrics.annotation.Timed;
import com.google.common.base.Optional;
import com.google.common.util.concurrent.SettableFuture;
import com.xyz.dw.model.Greeting;
import org.glassfish.jersey.server.ManagedAsync;
import rx.Observable;
import rx.schedulers.Schedulers;
#!/usr/bin/env ruby
require 'rubygems'
require 'sinatra'
require 'haml'
require 'fileutils'
set :port, 25000
$pwd = ENV['PWD']
@sathish316
sathish316 / oneplus.scala
Last active September 20, 2015 12:39
Generate email ids for oneplus registration based on an amazon review (http://www.amazon.in/review/REA7WFX7PV3KO)
object OnePlus {
def main(args: Array[String]) {
generate_aliases("typeyouremailhere@gmail.com").foreach(println)
}
def generate_aliases(email:String) = {
val email_pattern = """(\w+)@([\w\.]+)""".r
email match {
case email_pattern(address, domain) => {
interleave_all_with(address, '.').map {case address => s"$address@$domain"}
@sathish316
sathish316 / snakes_and_ladders.ex
Last active September 14, 2015 10:05
Snakes and Ladder - Elixir Game server
defmodule GameServer do
use GenServer
def start do
initial_state = {:players, [], :positions, Map.new, :snakes_and_ladders, [
{:ladder, 5, 15}, {:ladder, 10, 22}, {:ladder, 25, 45}, {:snake, 35, 15}, {:snake, 65, 55}]}
GenServer.start_link(__MODULE__, initial_state, name: __MODULE__)
end
def join(player), do: GenServer.cast(__MODULE__, {:join, player})
@sathish316
sathish316 / init-scala.sh
Created September 6, 2014 15:20
init-scala.sh
#!/bin/bash
PROJECT_NAME="$1"
SCALA_VERSION="2.10.3"
SCALATEST_VERSION="2.2.1"
MOCKITO_VERSION="1.8.5"
mkdir $PROJECT_NAME
cd $PROJECT_NAME
@sathish316
sathish316 / gist:5377340
Created April 13, 2013 06:38
Slate config
config defaultToCurrentScreen true
config nudgePercentOf screenSize
config resizePercentOf screenSize
# Resize Bindings - cmd+alt for resizing
bind right:alt;cmd resize +10% +0
bind left:alt;cmd resize -10% +0
bind up:alt;cmd resize +0 -10%
bind down:alt;cmd resize +0 +10%
@sathish316
sathish316 / rover_golf.rb
Created September 22, 2012 02:37
Rover golf
D,N,E,S,W,R,L,M=%w{NESW y+=1 x+=1 y-=1 x-=1 d+=1 d-=1 e.(D[d%4])}
r=->(x,y,d,s){e=->(a){eval eval(a)};s.scan(/./){|a|e.(a)};[x,y,D[d%4]]}
p r.(1,2,D.index('N'),"LMLMLMLMM")
p r.(3,3,D.index('E'),"MMRMMRMRRM")