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 / P05.scala
Created June 7, 2015 20:55
P05 (*) Reverse a list.
package com.learner.s99
/**
* P05 (*) Reverse a list.
* Example:
* scala> reverse(List(1, 1, 2, 3, 5, 8))
* res0: List[Int] = List(8, 5, 3, 2, 1, 1)
*/
object P05 {
def reverse[T](l:List[T]): Option[List[T]] = reverse(l, Nil)
@hhimanshu
hhimanshu / P06.scala
Created June 7, 2015 21:28
P06 (*) Find out whether a list is a palindrome.
package com.learner.s99
/**
* P06 (*) Find out whether a list is a palindrome.
* Example:
* scala> isPalindrome(List(1, 2, 3, 2, 1))
* res0: Boolean = true
*/
object P06 {
def isPalindrome[T](l:List[T]):Boolean = l == l.reverse
@hhimanshu
hhimanshu / README.md
Created August 11, 2015 18:17
Vim Tmux Setup
@hhimanshu
hhimanshu / Trie.java
Created January 29, 2016 15:35
R-Way Tries (Leetcode)
import java.io.*;
import java.util.*;
/*
* To execute Java, please define "static void main" on a class
* named Solution.
*
* If you need more classes, simply define them inline.
*/
@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 / 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
import * as admin from "firebase-admin";
export const getFirebaseApp = (credentialsJsonFile, appName) => {
let fbAdmin = admin.initializeApp({
credential: admin.credential.cert(credentialsJsonFile)
}, appName);
return fbAdmin.firestore();
};
@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 / 1.Iterations.md
Last active September 5, 2019 17:27
Web Development Phase 01 Code Samples (for Mentoring Sessions)

for loop

let numUsers = 0;
for(let num = 0; num < 22; num++){
  numUsers = numUsers+1;
}
console.log('Number of users are: '+ numUsers); //implicit coercison from number to string
@hhimanshu
hhimanshu / ReactPlyr.tsx
Created November 11, 2020 13:42
Plyr w/ TypeScript
export const VideoPlayer = ({youtubeId}: VideoPlayerProps) => {
useEffect(() => {
const options = {
noCookie: false,
rel: 0,
showinfo: 1,
iv_load_policy: 3,
modestbranding: 1
}
if (typeof document !== `undefined`) {