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 / how to read unfamiliar codebase.md
Last active October 24, 2023 02:11
how to read unfamiliar codebase

Overview

These are in no particular order. I found them by researching what methods other developers use to understand codebases that they have not seen before.

Recommendations

  • If the codebase has tests, read the tests
  • Try to write tests for the part of codebase you are trying to understand. This helps in understanding the behavior and serve as documentation
  • Get overview of project. See the overall picture. How many modules it has? What are the name of the modules? Pick one module and do deep dive into it.
  • Writing documentation for source code. This is a good practice to understand the codebase. I tend to prefer writing tests over documentation since the source code and tests are truth, documentation decays over time, generally.
@hhimanshu
hhimanshu / intellij_community_uninstall_mac.sh
Created July 24, 2018 10:47
Remove the IntelliJ completely from your mac
# First remove the app from `/Applications`
rm -rf ~/Library/Caches/IdeaIC201*; rm -rf ~/Library/Preferences/IdeaIC201*;rm -rf ~/.ivy2/cache
@hhimanshu
hhimanshu / copyFileFromJar.scala
Last active January 9, 2023 17:45
Copy File inside Jar to External Location
import java.io.File
import java.net.URL
// Note: This has dependency on apache commons-io
import org.apache.commons.io.FileUtils
object LoadFile extends App {
override def main(args: Array[String]): Unit = {
val fileName = "myfileJarFile.json"
val path: URL = getClass.getClassLoader.getResource("v410.all/" + fileName)
@hhimanshu
hhimanshu / Scala.For.The.Impatient.md
Last active September 28, 2021 15:51
Scala for the Impatient Exercises

This gist will contain all the exercises from the book

@hhimanshu
hhimanshu / .Functional Programming in Scala Exercises
Last active September 19, 2021 16:58
Functional Programming in Scala Exercises
All exercises are attempted on https://coderpad.io
@hhimanshu
hhimanshu / InsertJson.scala
Created August 28, 2015 21:40
Insert JSON document into ElasticSearch using Elastic4s
// Dependency: elastic4s
import java.util.Calendar
import com.sksamuel.elastic4s.ElasticDsl._
import com.sksamuel.elastic4s.source.StringDocumentSource
import com.sksamuel.elastic4s.{ElasticClient, ElasticsearchClientUri}
import org.elasticsearch.action.index.IndexResponse
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future
@hhimanshu
hhimanshu / create-react-starter-npx.sh
Created June 30, 2021 22:54
Create NPX based React Starter App
#!/usr/bin/env node
const {execSync} = require('child_process');
const runCommand = command => {
try {
execSync(`${command}`, {stdio: 'inherit'});
} catch (e) {
console.error(`Failed to execute ${command}`, e);
return false;
@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`) {
@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 / 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