Skip to content

Instantly share code, notes, and snippets.

View purukaushik's full-sized avatar

Purush Swaminathan purukaushik

  • Austin, TX
View GitHub Profile
@purukaushik
purukaushik / fn-prog.scala
Created February 11, 2017 08:13
Functional building blocks- map, filter, reduce etc ab initio in scala
object AbInitio {
def map[T,U](f : T => U, xs: List[T]): List[U] ={
def helper(acc: List[U], xs1: List[T]):List[U] = {
if(xs1.isEmpty) acc
else helper(acc :+ f(xs1.head), xs1.tail)
}
helper(List[U](), xs)
}
def filter[T](f: T => Boolean, xs: List[T]):List[T] = {
def helper(acc: List[T], xs1: List[T]): List[T] = {
@purukaushik
purukaushik / fn-prog.clj
Last active February 11, 2017 07:54
Basic Functional building blocks- map, filter, reduce, etc ab initio in clojure
(defn map
"(map f coll) takes a function f and applies it to each element in coll and returns a collection"
([f coll] (map f coll []))
([f coll acc]
(if (empty? coll)
acc
(map f (rest coll) (cons (f (first coll)) acc)))))
(defn filter
"(filter f coll) takes a function f that computes a predicate condition on each element in coll and filtered collection is returned"
@purukaushik
purukaushik / keybase.md
Created February 8, 2017 20:41
Keybase.io

Keybase proof

I hereby claim:

  • I am purukaushik on github.
  • I am purush (https://keybase.io/purush) on keybase.
  • I have a public key whose fingerprint is B732 7660 14DD EBD6 D44E 0712 008E C779 98DA BE90

To claim this, I am signing this object:

@purukaushik
purukaushik / prime.clj
Created February 6, 2017 03:20
A non-working prime number generator
(ns clojure-noob.prime
(:require [clojure.string :as string])
(:gen-class))
(defn N-stream []
(defn from
[n]
(cons n (lazy-seq (from (inc n)))))
(from 1))
(take 1000 (N-stream))
@purukaushik
purukaushik / OpenSource.md
Last active December 9, 2016 18:25
Open Source spots to find projects
@purukaushik
purukaushik / Competitive.java
Created December 7, 2016 07:35
Competitive Programming template
package io.purush.hadoop.giscup.script;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
public class Main {
private static int totalchars = 0, offset = 0;
private static InputStream stream;
@purukaushik
purukaushik / devprodct.md
Created December 5, 2016 03:12
Developer productivity : little things

Little things that annoy developers

  1. Bash completions --> start using oh my zsh
  2. Don't name folders in your source code with same prefixes
  3. Avoiding variables that start with Capital letters --> annoys as caps require pinky to be on shift
  4. Managing small shell scripts, .`*rc files to enable quick migration from one laptop to another, working on new VMs etc
@purukaushik
purukaushik / spark-hadoop-setup.md
Last active September 22, 2016 02:00
Hadoop-Spark setup on standalone ubuntu
  1. Download Hadoop and install.

  2. Setup $HADOOP_HOME

  3. Install openssh-server and run

    sudo /etc/init.d/ssh restart
    

    Check if ssh is running on port 22 by:

netstat -tupln | grep 22

@purukaushik
purukaushik / docker_swarm.md
Last active September 20, 2016 00:05
Docker Swarm

Steps to setup a local docker swarm cluster with Docker Machine, swarm.

1. docker-machine create -d virtualbox local
2. eval "$(docker-machine env local)"
3. docker run swarm create
@purukaushik
purukaushik / ipyth_spark.md
Last active September 1, 2016 08:14
iPython pyspark notebook settings

install findspark ( pip install -e . after cloning https://github.com/minrk/findspark, and cd findspark)

fire a notebook (jupyter notebook)

enter the following:

import findspark
import os
findspark.init()