Skip to content

Instantly share code, notes, and snippets.

View kra3's full-sized avatar
🤠
I may be slow to respond.

Arun Karunagath kra3

🤠
I may be slow to respond.
View GitHub Profile
@kra3
kra3 / async-await-loop.js
Last active April 12, 2018 09:08
How Async Await behaves in loops
// our cool promise of future; serialize promises
function future(val){
console.log("lala ", val);
return new Promise((resolve, reject) => {
setTimeout(resolve, 2000, val);
})
}
//1. await waits in this case
(async () => {
@kra3
kra3 / package_scripts.json
Created February 8, 2018 10:59
useful scripts section for package.json (npm/webpack/babel/storybook/esdoc/coverage/eslint)
{
"scripts": {
"---Dev": "---",
"storybook": "start-storybook -p 9001 -c .storybook",
"dev:start": "npm run storybook",
"start": "npm run dev:start",
"---Build": "---",
"clean": "echo 'Cleaning lib folder...\n' && rm -rf ./lib",
"build": "npm run clean && echo 'Building...\n' && babel src --out-dir lib --copy-files --ignore **/__tests__",
"watch": "babel src -w -s inline --out-dir lib --copy-files --ignore **/__tests__",
@kra3
kra3 / flatten_neo.js
Created October 29, 2017 22:30
flatten an arbitrarily nested array
const flatten = (arr) => {
const _helper = (arr) => arr.reduce(
(acc, itm) => Array.isArray(itm) ? [...acc, ..._helper(itm)] : [...acc, itm], []);
return _helper(arr);
}
// upgrade to old version https://gist.github.com/kra3/f802061437e3efe062ab2d4c047fe7c0
// still, I advocate to use underscore, lodash or ramda ;) they are more battle tested
@kra3
kra3 / wiki_helper.py
Last active October 29, 2017 01:01
A generic script for text processing originally written specific to some usecases around wiki text.
# -*- coding: utf-8 -*-
__author__ = 'Arun KR (kra3) <the1.arun@gmail.com>'
__license__ = 'Simplified BSD'
import sys
"""
wiki_helper.py rules.txt data.txt > result.txt
// no way to reset, at the moment
const get = (() =>{
let counter = 0;
return (url) => {
return new Promise((resolve, reject) => {
if(counter > 100) {
reject(false);
}
check :: String -> String -> Char -> (Bool, String)
check word display c
= (c `elem` word, [if x==c
then c
else y | (x,y) <- zip word display])
turn :: String -> String -> Int -> IO ()
turn word display n =
do if n==0
then putStrLn "You lose"

Keybase proof

I hereby claim:

  • I am kra3 on github.
  • I am kra3 (https://keybase.io/kra3) on keybase.
  • I have a public key ASDFa3YNbsbfrmC-8WfUOSMiBDUfYeRpU7-5-EDSFXrisgo

To claim this, I am signing this object:

@kra3
kra3 / The Technical Interview Cheat Sheet.md
Created February 17, 2017 18:57 — forked from tsiege/The Technical Interview Cheat Sheet.md
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

Studying for a Tech Interview Sucks, so Here's a Cheat Sheet to Help

This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.

Data Structure Basics

###Array ####Definition:

  • Stores data elements based on an sequential, most commonly 0 based, index.
  • Based on tuples from set theory.
{
"always_show_minimap_viewport": true,
"bold_folder_labels": false,
"caret_style": "phase",
"color_scheme": "Packages/User/Alpenglow (SublimePythonIDE).tmTheme",
"ensure_newline_at_eof_on_save": true,
"font_face": "Fira Code",
"font_size": 9,
"heighlight_line": true,
"heighlight_modified_tabs": true,
@kra3
kra3 / sublime_py_proj_with_venv.json
Created January 5, 2017 09:33
Sublime project settings - python project with virtualenv
{
"Python": {
"python": "~/.envs/<virtual_env_name>/bin/python",
"pythonExtraPaths": [
"~/.envs/<virtual_env_name>/lib/python3.5/site-packages/"
]
},
"folders": [
{
"path": "<relative_project_path_from_this_file>",