Skip to content

Instantly share code, notes, and snippets.

View Khalian's full-sized avatar

Arunav Sanyal Khalian

  • Vancouver, BC, Canada
View GitHub Profile
@Khalian
Khalian / mac_installations.sh
Last active September 15, 2020 23:54
Installations for new Mac
#!/bin/sh
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
# Brew installations
brew cask install alacritty
brew install git
brew install byobu
brew install mosh
brew install openssh
brew install python3
@Khalian
Khalian / .vimrc
Last active July 21, 2020 21:07
.vimrc
set runtimepath+=~/.vim_runtime
source ~/.vim_runtime/vimrcs/basic.vim
source ~/.vim_runtime/vimrcs/filetypes.vim
source ~/.vim_runtime/vimrcs/plugins_config.vim
source ~/.vim_runtime/vimrcs/extended.vim
try
source ~/.vim_runtime/my_configs.vim
catch
@Khalian
Khalian / typeclass.scala
Last active March 4, 2020 08:12
typeclass
// Inspiration : https://alvinalexander.com/scala/fp-book/type-classes-101-introduction
// Purpose : Adhoc polymorphsim
// Define some types
case class Dog(name: String, breed: String)
// Define the type class
trait Animal[A] {
def sound(a: A): Unit
}
@Khalian
Khalian / TypeHierarchy.scala
Last active February 21, 2020 01:45
TypeHierarchy.scala
// A classic definition of functor, applicative and monad.
trait Functor[T[_]] {
def apply[A](a: A): T[A]
def map[A, B](f: A => B)(a: T[A]): T[B]
}
trait Applicative[T[_]] extends Functor[T[_]] {
def pmap[A, B](f: T[A => B])(a : T[A]) : T[B]
}
@Khalian
Khalian / higher_kinded_types_graph_search_bfs_dfs.scala
Created February 1, 2020 09:31
higher_kinded_types_graph_search_bfs_dfs
import scala.annotation.tailrec
import scala.collection.immutable.{Queue, Stack}
sealed trait Tree[T] {
def value: T
}
case class Node[T](value: T, children: List[Tree[T]]) extends Tree[T]
case class Leaf[T](value: T) extends Tree[T]
@Khalian
Khalian / simpleWebServer
Last active January 4, 2019 19:16
Simple command line webserver
Simple server init : python -m SimpleHTTPServer 8000
Simple get request : echo -e "GET / HTTP/1.1" | nc localhost 8000
@Khalian
Khalian / nvimsymlinks
Last active October 21, 2018 21:58
nvim symlinks to vimrc
sealed trait Addable[T] {
def add(a: T, b: T): T
}
object AddableInstances {
implicit val intAddable = new Addable[Int] {
override def add(a: Int, b: Int): Int = a + b
}
}
@Khalian
Khalian / s3bucketRM.sh
Last active June 20, 2019 21:41
Remove s3 buckets bulk
#!/bin/sh
if [ $# -ne 1 ]
then
echo "Usage: ./s3bucketRM.sh bucketNameSubstring"
exit 1
fi
for bucket in $(aws s3 ls | awk '{print $3}'| grep $1); do aws s3 rb "s3://${bucket}" --force ; done
@Khalian
Khalian / install.sh
Created August 8, 2018 00:19
Arunav's pimped up installation of rad stuff
# This is to be used in environments without proper yum usage.
# Mosh
sudo yum -y install autoconf automake gcc gcc-c++ make boost-devel
sudo yum -y install zlib-devel ncurses-devel protobuf-devel openssl-devel
wget https://mosh.org/mosh-1.3.0.tar.gz
tar xf mosh-1.3.0.tar.gz -C /tmp/
cd /tmp/mosh-1.3.0
./configure
make -j7