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 / commands.txt
Created June 20, 2019 14:30
Kubectl Commands
kubectl create ns kubeless
kubectl create -f https://github.com/kubeless/kubeless/releases/download/v1.0.3/kubeless-v1.0.3.yaml
kubectl get pods -n kubeless
kubeless function deploy computes --runtime python2.7 --handler computes.handler --from-file computes.py
kubeless function ls
kubectl get pods
@kylejeske
kylejeske / compare-swap.js
Created July 21, 2019 20:24
Flipping bits - RunTime: o(n), Space: o(n)
// Start with: ['a', 'b', 'c', 'd', 'e']
// End with: ['a', 'b', 'c', 'd', 'e']
// without using any additional variables, and within o(n) runtime.
// swapArr (reference Array, pointer 1, pointer 2)
// will take the reference to the position within the array
// and swap them without using a third variable
const swapArr = (arr, x,y) => {
// replace ASCII values with the character decimals
arr[x] = arr[x].charCodeAt(0);
@kylejeske
kylejeske / find-longest-sequence.js
Created July 22, 2019 05:16
Return the longest sequence of consecutive characters in string
// runner (s: string)
// return -- expects: Object { maxChar: numberOfOccurances }
const runner = (s="") => {
let stringLength = (s.length - 1);
let position = 0;
let currentChar = "";
let maxCount = 0;
let count = 0;
let maxChar = null;
@kylejeske
kylejeske / two-string-anagram.js
Created July 22, 2019 08:31
Given two strings, determine if they are anagrams
/**
* Given 2 strings, determine if they are anagrams.
* isAnagram(string s1, string s2) => Boolean
*
* @note Not a very efficient example
*/
const isAnagram = (s1="", s2="") => {
// case 1, s1 & s2 length are zero, so true
if (s1.length != s2.length) {
return false;
@kylejeske
kylejeske / reverse-words-in-place.js
Created July 22, 2019 09:01
Reverse words in place
/**
* Your team is scrambling to decipher a recent message, worried it's a plot to break into a major European National Cake Vault.
* The message has been mostly deciphered, but all the words are backward! Your colleagues have handed off the last step to you.
*
* Write a function reverseWords() that takes a message as a string and reverses the order of the words in place.
*
* string message = "cake pound steal";
* reverseWords(message);
* cout << message << endl;
* // prints: "steal pound cake"
@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;
@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 / 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 / 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 / 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;