Skip to content

Instantly share code, notes, and snippets.

View hhimanshu's full-sized avatar
🚀
Building meaningful products

Harit Himanshu hhimanshu

🚀
Building meaningful products
View GitHub Profile
@hhimanshu
hhimanshu / process.erl
Created December 17, 2014 21:19
Create 2 process and send M messages back and forth between them
% http://www.erlang.org/course/exercises.html#conc
-module(process).
-export([loop/0]).
loop() ->
receive
{From, Message} -> io:format("received [~p] from [~p]~n", [Message, From]),
loop()
end.
@hhimanshu
hhimanshu / recursive.erl
Last active May 29, 2017 11:21
Erlang: Find Minimum and Maximum in list
-module(recursive).
-export([minimum/1, maximum/1]).
minimum([]) -> io:format("can not find minimum of empty list~n");
minimum([H|T]) ->
minimum(H, T).
minimum(Min, [H|T]) ->
case Min < H of
@hhimanshu
hhimanshu / mathStuff.erl
Created December 16, 2014 21:54
Erlang: Find Perimeter
-module(mathStuff).
-export([perimeter/1]).
perimeter({circle, Radius}) -> 2 * math:pi() * Radius;
perimeter({square, Side}) -> 4 * Side;
perimeter({triangle, A, B, C}) -> A + B + C.
@hhimanshu
hhimanshu / temp.erl
Created December 16, 2014 20:33
Erlang: Temperature Conversion
% http://www.erlang.org/course/exercises.html
% Write functions temp:f2c(F) and temp:c2f(C) which convert between centigrade and Fahrenheit scales. (hint 5(F-32) = 9C)
-module(temp).
-export([c2f/1, f2c/1, convert/1]).
c2f(C) -> (C *9/5) + 32.
f2c(F) -> (F - 32) * 5/9.
convert({From, What}) ->
case {From, What} of
@hhimanshu
hhimanshu / Calculator.scala
Created October 22, 2014 20:55
Scala Calculator
import scala.collection.mutable
object Calculator {
def main(args: Array[String]): Unit =
if (args.length != 1) {
throw new IllegalArgumentException("usage: Calculator <expression>")
} else {
val expression = args(0)
val tokens = expression.split(" ")
@hhimanshu
hhimanshu / Hello.java
Last active August 29, 2015 14:04
Hello Tumblr!
System.out.println("Hello World!");
@hhimanshu
hhimanshu / codereview.md
Created May 31, 2014 21:21
Code Review Guideline

Code Review Guidelines

In spirit of keeping our home (read codebase) clean and organized, we must have same protocol to talk.

Every pull request opened on the project needs to be scruitinzed on mutiple aspects. For example,

  • How code is designed
  • How code is formatted.
  • How code structure is created