Skip to content

Instantly share code, notes, and snippets.

View kylejeske's full-sized avatar
🐛
(!(while(succeed=try())));

kyle kylejeske

🐛
(!(while(succeed=try())));
  • Distributed
View GitHub Profile
@kylejeske
kylejeske / return-first-child-in-array.js
Created September 11, 2019 15:24
Using Array Spread syntax and Object Destructing -- Return the first element of an array as a property of an object.
{
let elementA = {
name: 'xyz',
children: [
{ name: 'abc' }, // firstChild
{ name: 'bcd'} // secondChild
]
};
const getFirst = (d = []) => ([f, ...r] = d, f);
const firstChild = getFirst(elementA.children);
@kylejeske
kylejeske / double-numbers.js
Last active September 20, 2019 12:18
Double Numbers using Recursion in JS
/**
* double-numbers.js
*
* Translates an Array of Numbers to Double that using Recursion and some ES6 tricks.
* @some(techniques).included([expansion assignment, rest operator, spread operator, ternary operator, arrow functions])
*/
((numbers=[]) => {
const doubleNumbers = ( collection = [], [ head, ...tail ] = collection ) =>
(collection.length === 0)
@kylejeske
kylejeske / max-sum-from-sliding-window.js
Last active September 25, 2019 22:27
Find the max sum of the sub-array (sliding window)
/**
* @param {number[]} nums
* @param {number} k
* @return {number[]}
*/
const maxSlidingWindow = function(nums, k) {
if (k == 0) return Array(0);
const iterateNumbers = (nums, filterSize) => {
const len = nums.length;
const max = [];
@kylejeske
kylejeske / index.js
Last active September 27, 2019 14:43
NPX install URL path
#!/usr/bin/env node
console.log("I ranz from GitHub Gist.");
console.table(["01011001b 01000001b 01000001b 01000001b 01000001b 01011001b 01011001b 01011001b 01011001b 01011001b 01011001b 01011001b 01011001"]);
@kylejeske
kylejeske / split-path.md
Created September 29, 2019 19:40
Bash split path

Bash - Split Path

Easy tool to split the current $PATH of the system into individual lines.

#!/bin/bash
{

  for i in $(echo "$PATH" | sed 's/:/ /g'); do echo $i;  done;
@kylejeske
kylejeske / examples.md
Last active September 29, 2019 19:53
hello world using LLVM: clang

LLVM: Hello-World.c - Example

Assumes

  1. Clang & LLVM have been installed on $PATH.

Execution

clang hello-world.c
@kylejeske
kylejeske / population-on-earth.json
Created October 17, 2019 17:43
JSON file of Earth Population Figures
[["1990",[6,159,0.001,30,99,0.002,45,-109,0.000,42,115,0.007,4,-54,0.000,-16,-67,0.014,21,-103,0.006,-20,-64,0.004,-40,-69,0.001,32,64,0.001,28,67,0.006,8,22,0.000,-15,133,0.000,-16,20,0.000,55,42,0.006,32,-81,0.010,31,36,0.067,9,80,0.016,42,-91,0.006,19,54,0.001,21,111,0.163,-3,-51,0.001,33,119,0.150,65,21,0.002,46,49,0.015,43,77,0.043,45,130,0.018,4,119,0.006,22,59,0.002,9,-82,0.003,46,-60,0.002,-14,15,0.006,-15,-76,0.001,57,15,0.007,52,9,0.056,10,120,0.004,24,87,0.134,0,-51,0.005,-5,123,0.013,-24,-53,0.010,-28,-58,0.015,43,0,0.019,24,70,0.023,-9,33,0.012,20,73,0.037,13,104,0.034,43,41,0.012,23,78,0.095,20,-72,0.001,38,-4,0.006,0,-77,0.016,-9,-35,0.056,25,109,0.034,-13,34,0.013,61,18,0.001,58,40,0.002,34,50,0.027,49,88,0.000,48,-99,0.001,-42,176,0.002,20,86,0.156,-18,30,0.007,53,44,0.006,29,18,0.001,5,16,0.003,49,-74,0.000,48,131,0.006,14,121,0.210,63,19,0.001,40,54,0.001,36,57,0.005,16,52,0.000,50,128,0.010,39,30,0.021,54,12,0.006,16,-61,0.011,27,80,0.196,29,101,0.001,14,78,0.067,7,13,0.003,41,125,0.026,-1
@kylejeske
kylejeske / find-max-stock-buy-self-profit-es6.js
Created October 18, 2019 14:57
Using points within a subset to find max/min and profits from sale of a stock
/**
// using built-in functions
*/
function findMaxStockProfit(arr1) {
if (arr1.length < 2) {
return 0;
}
let arr1Min = Math.min(...arr1);
let subset = arr1.slice(arr1.indexOf(arr1Min));
@kylejeske
kylejeske / gist:742775c9e259469f09582c2834ea3f53
Created December 4, 2019 15:06 — forked from billsinc/gist:4665346
Find Largest Files/Directories on Linux System
# 10 Largest Files
find . -type f -print0 | xargs -0 du -s | sort -n | tail -10 | cut -f2 | xargs -I{} du -sh {}
@kylejeske
kylejeske / README.md
Last active June 23, 2023 15:09
Monad Composition to handle async ACL checks during a file upload

Monad Composition in JavaScript

Design Pattern: Inversion of control

References

  • Discrete Math
  • Decoupling Dependencies
  • Monad Transformers
  • Monad Functions
    • Closure operators on partially ordered sets