Skip to content

Instantly share code, notes, and snippets.

Avatar
🦈
Building something cool

Corbin Crutchley crutchcorn

🦈
Building something cool
View GitHub Profile
View explain-lambda.js
function fn(arg) {
return arg("Hello, world");
}
const passThru = fn(arg => funct => funct(arg));
passThru(console.log);
@crutchcorn
crutchcorn / Awesome Windows Software.md
Last active Apr 20, 2017
Yes, I know it already exists. It also has nothing new on it
View Awesome Windows Software.md
  • Foxit Reader
  • RenameIt!
  • Paint.Net
  • SmartGit
  • AIMP (with YouTube and Soundcloud plugins)
  • MediaMonkey
  • Typora
  • AquaSnap
  • PicPick
  • OBS
@crutchcorn
crutchcorn / .bashrc
Last active Feb 1, 2019
WSL Setup File
View .bashrc
# Switch to ZSH shell
if test -t 1; then
exec zsh
fi
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
View recurse.js
recursive = (el) => el.children && el.children.length !== 0 ? Array.from(el.children).reduce((prev, child) => [...prev, ...recursive(child)], Array.from(el.children)) : [el];
$$('.js-hotel-result').forEach(hotelEl => {
const isBad = recursive(hotelEl).reduce((prev, el) => prev || !!(/^ ?[2-9][0-9](?:\.[0-9]+)? miles.*/).exec(el.innerText), false);
if (isBad) {
hotelEl.parentNode.removeChild(hotelEl);
}
});
View Explaination.md

c='children',l='reduce' - This creates two variables that I can reuse. Obviously, l is shorter than reduce, so I want to create aliases for the things we're gonna reuse. What these strings do will be explained later

r=e=> is creating a function called r that takes an argument e and returns what's after => (which I'm about to explain in a second)

e[c]&&e[c].length>0 - Remember that c = 'children'. We're checking that the argument supplied to function r (e) both has a property called children and that it contains more than 1 element in the list (the purpose of r (also called recurse https://gist.github.com/crutchcorn/e4a5f7e1d7c160d2a5d856ab66bfd657 for normal code version) is to be able to go down a tree of elements in a webpage and return a list of every child of any element)

[...e[c]] - We're taking the children of the argument and turning it into an array (previously, it was a list a lot LIKE an array, but it didn't have the reduce function we'll need to call in a second)

`

View object-helpers.ts
/**
* @callback objectMapCallback
* @param value - The value of the key that is currently being modified. Added as an attempt to duplicate Array.map `value`
* @param {string} key - The key that is currently being modified. Added as an attempt to duplicate Array.map `index`
* @param object - The original untouched object that the map function is being called on. Added as an attempt to duplicate Array.map `array`
*/
/**
* Map through all keys in an object and call a CB. Assign that CB's return value to the key in question
* @param object - The object to make this call on. This would otherwise be bound to `Object.prototype` but I don't like breaking the web
@crutchcorn
crutchcorn / scroll.js
Last active Dec 18, 2018
Ya ever want to scroll to the top of a page to take a screenshot on a 3rd party website? No? Oh. Okay.
View scroll.js
a = setInterval(() => window.scrollTo(0, document.body.scrollHeight), 100);
clearInterval(a)
View anxiety-tips.md
  • Force deep and very slow breaths even if it feels a tiny bit like you can't breath (don't do so to the point where you're sufficating, but a minor discomfort is perfect normal (for me, since the intended effect is to be able to bypass your want to retract and panic) and okay. The intended effect is to slow the heart-rate which tricks your brain to calm down)
    • Inhale thru the nose, out the mouth.
    • Breath out through your mouth slowly, feel free to breath in more quickly but don't do that too fast either
  • Take slow movements
  • Sit up straight, don't lock up your shoulders (this reminds your brain that you're alright instead of instinctually locking up and reinforcing the anxiety)
  • Exhale super deeply until you can't exhale anymore, as if you were squeezing out all the oxygen from a bottle. This will allow your
@crutchcorn
crutchcorn / typescript-generics.ts
Created Dec 4, 2018
Typescript generics rough intro
View typescript-generics.ts
// So, let's say you have a function that you want to accept any function type and return that type
// Don't worry about why right away, just
function returnSelf(a: any): any {
return a;
}
returnSelf(2);
returnSelf('t');
View compareFrontend.md

Before we can dive into how many front-end frameworks that you may have heard of work, we need to set a baseline of information. If you're already familiar with how the DOM represents a tree and how the browser takes that information and utilizes it, great! You're ready to read ahead! Otherwise, it's strongly suggested that you take a look at our post introducing the concepts required to understanding some of the baseline to this post

You may have heard about various frameworks and libraries that modern front-end developers utilize to build large-scale applications. Some of these frameworks you may have heard of are Angular, React, and Vue. While each of these libraries bring their own strengths and weaknesses, many of the core concepts are shared between them.

With this series of articles, we're going to be outlining core concepts that are shared between them and how you can implement them in code in all three of the frameworks. This should p