Skip to content

Instantly share code, notes, and snippets.

Avatar
🦈
Building something cool

Corbin Crutchley crutchcorn

🦈
Building something cool
View GitHub Profile
View webpack.config
const path = require("path");
const CopyPlugin = require("copy-webpack-plugin");
const BundleAnalyzerPlugin =
require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
const root = path.resolve(__dirname, "./");
module.exports = {
name: "seaside-react",
entry: "./src/index.tsx",
externals: {
View promisify.js
const promisify = (fn) => {
return (...args) => {
return new Promise(resolve => {
fn(...args, (...data) => resolve(...data))
})
}
}
promisify((one, cb) => cb(one))(1).then(one => console.log(one))
View deep-pick-object.ts
// NaN also, but `typeof NaN` === number
type Falsy = false | null | undefined | 0 | -0 | 0n | "";
type AnyArray<T> = Array<T> | ReadonlyArray<T>
type DeepReplaceKeysPartialObj<Obj extends object, T> = {
[key in keyof Obj]:
Obj[key] extends AnyArray<infer Q> ?
DeepReplaceKeys<Q, T> :
Obj[key] extends object ?
@crutchcorn
crutchcorn / get_keypress.py
Last active Nov 26, 2021 — forked from gesquive/get_keypress.py
Get keypress for different platforms
View get_keypress.py
#!/usr/bin/env python3
# get_keypress.py
import sys
import os
def main():
try:
print("press ctrl+c to exit")
View arrayconstruct.js
str = 'a/b/c/d/e/f'
p = []
toCount = str.length;
for (let n = 0; n < toCount; n++) {
if (str[0] !== '/') {
p.push(str[0]);
}
str = str.slice(1, str.length);
}
View dynamoform.vue
<template>
<div>
<div
v-for="field of fields"
:key="field.id"
>
<input
v-if="field.value === 'input'"
:value="field.value"
:aria-label="field.label"
View example-lib.js
<script>
// Base.js
class OurBaseComponent extends HTMLElement {
connectedCallback() {
this.doRender();
}
createState(obj) {
return Object.keys(obj).reduce((prev, key) => {
// This introduces bugs
@crutchcorn
crutchcorn / proxy-assign-mem-share.js
Last active Oct 19, 2021
Demonstration of how Object.assign, object mutation, and proxy binding play together in JS
View proxy-assign-mem-share.js
const a = {
a: 100
}
const c = {
c: 300
}
function get_c_proxy(mainObj) {
return new Proxy(c, {
View cli-testing-library-example.ava.js
test("Should fail", async (t) => {
const { cleanup, getByText, fireEvent } = await render([""], {
cwd: resolve(__dirname, "../example"),
});
let outputStr;
outputStr = await waitFor(() => getByText("Please choose a generator"));
t.regex(outputStr, /Please choose a generator/);
cleanup();
View resolve-weirdness.js
// This basic premise is being used here:
// https://github.com/plopjs/plop/pull/287/files#diff-dc20b7684034e757bccdcb13b82e52fa46e618997d3fcc3e9fddd88bde362607R29-R73
let dataWaitPromises = [];
function waitForData() {
const promise = new Promise((resolve) => (localDataResolve = resolve));
dataWaitPromises.push({ promise, resolve: localDataResolve });
}