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 / convert-postman-to-insomnia.js
Created October 22, 2021 05:32 — forked from wesleyegberto/convert-postman-to-insomnia.js
Script to convert a Postman backupt to Insomnia
/**
* Script to parse a Postman backupt to Insomnia keeping the same structure.
*
* It parses:
* - Folders
* - Requests
* - Environments
*
* Notes: Insomnia doesn't accept vars with dots, if you are using you must replace yours URLs manually (see ENVIRONMENTS_EXPORTS).
*/
@kra3
kra3 / tutorial.md
Created July 17, 2018 11:49 — forked from swalkinshaw/tutorial.md
Designing a GraphQL API

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.

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 09:27
remove false values from nested objects recursively
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;
@kra3
kra3 / gis.md
Last active May 3, 2018 11:30
GIS
@kra3
kra3 / Jenkins.md
Last active May 3, 2018 11:31
CI through GitHub

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 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
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"