Skip to content

Instantly share code, notes, and snippets.

View crutchcorn's full-sized avatar
📒
Writing like whoa

Corbin Crutchley crutchcorn

📒
Writing like whoa
View GitHub Profile
@crutchcorn
crutchcorn / major-ver-check.js
Last active December 1, 2021 19:46
I would usually break code like this out, but I was tinkering about and was trying to make a lot of it inline. Had fun writing it though!
// Setup npm packages w/o variables
(({ lstatSync, readdirSync }, { join }, check, chalk, { table }, ora) =>
// Create lambda and immediately call it later
((source, getPkgName, spinner) =>
// Wait for all Promises to finish running. Promise.all returns an array
void Promise.all(
readdirSync(source)
// Give me the fill paths of the items
.map(name => join(source, name))
// Only give me directories
ssh: {}
hotkeys:
shell: {}
new-tab:
- - Ctrl-T
- - Ctrl-Shift-T
next-tab:
- - Ctrl-Shift-ArrowRight
- - Ctrl-Tab
profile: {}

This is gonna seem like a fuckload of irrelevant CS shit but I swear it will all come together in the end Linux What is Linux? Technically speaking, a kernel CAN be built to only include an IPC (an IPC is what dictates what process to run in what order, and occationally [depending on the design] how memory is alliocated for that particular process).

Side note: A process is a single piece of running code. You can think of it like a thought. A single action (ala picking up something from the ground or deciding where to go to eat) CAN be one thought but is usually many processes that work together interlinked, but that's getting into userspace which I'll cover in a second But more often than not, a kernel includes a lot of other bits to understand what your hardware does (so basic backup graphics/x86 (x86 is a type of CPU that runs a specific set of instruction called x86) drivers, as well as stuff like file system drivers (so in linux one of the options is EXT3, but in Windows you get NTFS - this is HOW the 1s

const loopUntilAtLeastLength = (arr, wantedSize) => {
if (arr.length < wantedSize) {
return loopUntilAtLeastLength([...arr, ...arr], wantedSize);
} else {
return arr;
}
};
const getPeeps = () => Promise.resolve([{name: 'Corbin', addr: 1}, {name: 'Nic', addr: 0}])
const getAddr = (val) => Promise.resolve(val ? 'My home' : 'Their home')
// Pure promise solution
getPeeps() 
.then(people => {
const peoplePromiseArr = people.map(person => {
return getAddr(person.addr).then(addr => {
person.addr = addr;
return person;
@crutchcorn
crutchcorn / microsyntax.md
Last active December 28, 2019 09:27 — forked from mhevery/microsyntax.md
Angular microsyntax gramar

Microsyntax

Microsyntax in Angular allows you to write <div *ngFor="let item of items">{{item}}</div> instead of <ng-template ngFor [ngForOf]="items"><div>{{item}}</div></ng-template.

Constraints

The microsyntax must:

  • be know ahead of time so that IDEs can parse it without knowing what is the underlying semantics of the directive or what directives are present.
  • must translate to key-value attributes in the DOM.
@crutchcorn
crutchcorn / bind-fn-overwrite-playground.ts
Last active September 9, 2020 22:09
Trying to overwrite the `this` type for functions within an object in TS
/**
* Trying to overwrite the `this` in a function even when the initial `this` typing is not the same
*
* The end goal is to get this to occur recursively to be able to provide typings for:
* https://github.com/evelynhathaway/bind-deep
*
* No, they don't need to be this strict - yes I like a challenge
*/
type GenericFn = (this: any, ...args: any[] | never) => any;

Given an array of integers 0-9 inclusive, compute the max sum of k elements in the array. Where the length of the array > 0 and k is 0 < k <= length array Example: array ar is ar = [3, 2, 4, 5, 1, 0, 9, 8, 8, 7], and k is k = 3. Should return 25. finish this function (this is python, but you can use any language):

def compute_max_k(ar, k):
    return

Optional Chaining

\b([.a-zA-Z]+)\s+?&&\s+?\1\.

This should find instances such as:

test && test.thing

@crutchcorn
crutchcorn / DHCP.md
Last active July 30, 2022 22:50
Networking post WIP

DHCP {#dhcp}

DHCP stands for "dynamic host control protocol". It is the method for which machines on a local network automatically retrieve an IP address in order to identiy itself. It requires both a server and a client to work as-expected. This process includes 4 steps:

  1. A client that requires an IP address sends a UDP packet to the local network, asking if there are any DHCP servers on the network. This step is called DHCPDiscover

1a) This request is then ignored by anything that isn't a DHCP server

  1. The DHCP Server responds with an IP address suggestion. It doesn't know where to send it back to, since the requester does not have an IP address yet it will respond using UDP to every machine on the network. This step is called DHCPOffer