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 / 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 / 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 / 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 / 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 / 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 / only-show-remote.js
Last active September 4, 2019 14:27
Y 'Hackernews' - Filter List to only show remote positions
// https://news.ycombinator.com/item?id=20867123
// "Ask HN: Who is hiring? (September 2019)"
((context, skills=[]) => {
// findRemote, filter the list to only show remote positions
const findRemote = testText =>
testText.search(new RegExp(/remote/ig)) > -1
? true
: false;
@kylejeske
kylejeske / graph-theory-max-depth-binary-tree.md
Created September 3, 2019 20:31
Find the max depth of a binary tree

Graph Theory

Get the Height of a Binary Tree

Also described as ...

  1. Find the Maximum Depth of a Binary Tree

  2. Find the sum of all nodes of a Binary Tree


Concept

Obtain the height of the tree without iterating over each node.

@kylejeske
kylejeske / counting-sort-algorithm.js
Created August 30, 2019 15:12
Counting Sort Algorithm - Implemented in JavaScript
/**
* Using counting sort algorithm
*
* Take an Array from:
* [1, 4, 1, 2, 7, 5, 2]
* to
* [1, 1, 2, 2, 4, 5, 7]
*/
((Arr) => {
// Arr: Unsorted - Zero-based Indicies Array
@kylejeske
kylejeske / README.high-order-functions.md
Last active January 8, 2021 15:52
High Order Functions: Break down of Fold (Reduce) in JavaScript

Fold

About a high-order functions:

High-Order Function, as a structural transformation, the fold is a polymorphic function.

(The breakdown)

This just means, it takes on different forms (poly = multiple), and can take data from one element and transform it into another.

Specifically, this is speaking to the 'left fold'.

@kylejeske
kylejeske / singly-linked-list-cycle.js
Created August 21, 2019 18:53
Given a singly-linked-list, determine if there is a cycle.
/**
* Given a singly-linked-list, determine if there is a cycle.
*/
(() => {
// Predefine Global Structure & helper function
class LinkedListNode {
constructor(value) {
this.value = value;
this.next = null;