Skip to content

Instantly share code, notes, and snippets.

@kamalbanga
kamalbanga / 0_reuse_code.js
Last active August 29, 2015 14:10
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@kamalbanga
kamalbanga / Useful.md
Last active August 29, 2015 14:09
Useful Commands

SBT

echo "deb http://dl.bintray.com/sbt/debian /" | sudo tee -a /etc/apt/sources.list.d/sbt.list

sudo apt-get update

sudo apt-get install sbt

Java

" http://vimdoc.sourceforge.net/htmldoc/starting.html#vimrc
set nocompatible " use vim defaults
set scrolloff=3 " keep 3 lines when scrolling
set ai " set auto-indenting on for programming
set showcmd " display incomplete commands
set nobackup " do not keep a backup file
set number " show line numbers
set ruler " show the current row and column

Extract: jar xf <jar-file>

View contents: jar tf <jar-file>

Create:

  • All files in current folder: jar cf <new-file-name> .
  • Custom: jar cf [input file(s)]

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@kamalbanga
kamalbanga / git.md
Created July 24, 2014 13:43
Git commands

INITIALISING

$ git init [project-name] Creates a new local repository with the specified name

$ git clone https://github.com/[organization]/[repository].git Clones the repo into a new filder named ‘repository’

$ git status

@kamalbanga
kamalbanga / copyMul.py
Last active August 29, 2015 14:03
Copy a file into multiple files in Python.
import os, sys, shutil
DUP = 10
file = sys.argv[1]
path, fileName = os.path.split(file)
file_name, file_extension = os.path.splitext(fileName)
for i in range(1, DUP+1):
shutil.copyfile(file,path+'/'+file_name+'_'+str(i)+file_extension)

The introduction to Reactive Programming you've been missing

(by @andrestaltz)

So you're curious in learning this new thing called (Functional) Reactive Programming (FRP).

Learning it is hard, even harder by the lack of good material. When I started, I tried looking for tutorials. I found only a handful of practical guides, but they just scratched the surface and never tackled the challenge of building the whole architecture around it. Library documentations often don't help when you're trying to understand some function. I mean, honestly, look at this:

Rx.Observable.prototype.flatMapLatest(selector, [thisArg])

Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.

import random
import math
import numpy as np
seed = 1
boost = 20
maxIter = 50
numCities = 15
mu, sigma = 500, 200
demand = np.random.normal(mu,sigma,numCities)
@kamalbanga
kamalbanga / glift.cpp
Created April 8, 2014 19:48
GLIFT Simulation
#include <iostream>
#include <vector>
#include <stdlib.h>
#include <string.h>
#include <fstream>
#include <queue>
#include <ctime>
#include <algorithm>
using namespace std;