Skip to content

Instantly share code, notes, and snippets.

Avatar
🤠
I may be slow to respond.

Arun Karunagath kra3

🤠
I may be slow to respond.
View GitHub Profile
@kra3
kra3 / tutorial.md
Created Jul 17, 2018 — forked from swalkinshaw/tutorial.md
Designing a GraphQL API
View tutorial.md

Tutorial: Designing a GraphQL API

This tutorial was created by Shopify for internal purposes. We've created a public version of it since we think it's useful to anyone creating a GraphQL API.

It's based on lessons learned from creating and evolving production schemas at Shopify over almost 3 years. The tutorial has evolved and will continue to change in the future so nothing is set in stone.

View mean-median-mode-range-std.txt
Mean -> Sum of all elements divided by number of elements. Arithmetic mean = average.
Median -> middle element after sorting all elements. If there are even number of elements, then get the mean of middle elements.
Mod -> Most repeated element (if there is one).
Range -> biggest element minus smallest element.
Standard deviation (sigma) -> how spread out the numbers are. Square root of variance.
Mean diviation - How far, on average, all values are from the middle. square root of absolute variance.
Variance (mu) -> average of squared differences from mean. That is (element - mean) squared for each element and find the mean of it.
@kra3
kra3 / removeFalseValuesRecurse.js
Created May 18, 2018
remove false values from nested objects recursively
View removeFalseValuesRecurse.js
import _isObjectLike from 'lodash/isObjectLike';
import _size from 'lodash/size';
function removeEmptyValuesRecursively(obj) {
return removeEmptyValues(obj);
function isFalsy(val) {
// return true, if val is empty [], empty {} or null
return !_isObjectLike(val) ? val === null : _size(val) <= 0;
View gis.md
@kra3
kra3 / Jenkins.md
Last active May 3, 2018
CI through GitHub
View Jenkins.md

Jenkins PR

https://plugins.jenkins.io/ghprb

  • "ok to test" to accept this pull request for testing
  • "test this please" for a one time test run
  • "add to whitelist" to add the author to the whitelist
  • "retest this please" to start a new build
@kra3
kra3 / async-await-loop.js
Last active Apr 12, 2018
How Async Await behaves in loops
View async-await-loop.js
// 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 Feb 8, 2018
useful scripts section for package.json (npm/webpack/babel/storybook/esdoc/coverage/eslint)
View package_scripts.json
{
"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 Oct 29, 2017
flatten an arbitrarily nested array
View flatten_neo.js
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
View hangman.hs
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"
View get-unique-strings-from-api.js
// no way to reset, at the moment
const get = (() =>{
let counter = 0;
return (url) => {
return new Promise((resolve, reject) => {
if(counter > 100) {
reject(false);
}
You can’t perform that action at this time.