Skip to content

Instantly share code, notes, and snippets.

Avatar
🦈
Building something cool

Corbin Crutchley crutchcorn

🦈
Building something cool
View GitHub Profile
View ed-xml-to-md-table.js
const path = require('path');
const fs = require('fs');
const xml2js = require('xml2js');
async function walk(dir) {
const finalObj = {};
for await (const d of await fs.promises.opendir(dir)) {
const entry = path.join(dir, d.name);
if (d.isDirectory()) {
@crutchcorn
crutchcorn / index.rs
Created Mar 26, 2021
Demo Rust tool to test importing
View index.rs
use regex::Regex;
fn main() {
let phone_regex = Regex::new(r"\d{3}-(\d{3})-(\d{4})").unwrap();
let phone_matches = phone_regex.captures("555-555-5555");
return match phone_matches
.map(|caps| {
(
View JSDocDemo.js
/**
* @typedef {'github' | 'bitbucket' | 'gitlab'} ServiceType
*/
/**
* @param {string} path
* @param {number} depth
* @param {{username: string | null, token: string | null, service: ServiceType}} userData
* @returns {Promise<number>}
View windowsTermSettings.json
// To view the default settings, hold "alt" while clicking on the "Settings" button.
// For documentation on these settings, see: https://aka.ms/terminal-documentation
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"defaultProfile": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"profiles":
[
View shoelace-nextjs-setup.tsx
/**
* This is a demonstration Gist outlining how to define custom elements and access process environment variables.
* Both of which are required for setting up shoelace
* @see https://shoelace.style/
*
* Keep in mind that these components will not be present during the initial SSR paint, as the custom element definition
* occurs on the client only (due to limitations in NextJS)
*
* This method of custom element definition was most recently used in this repo:
* @see https://github.com/Ethan-Hill/Nexify
View RustNotes.md
View GoLangNotes.md
  • Does not support nested functions
    • Must use variable/lambda assignment:
func main() {
	test := func() {
		println("Hello")
	}

	test()
@crutchcorn
crutchcorn / vscode-settings.sh
Created May 16, 2020
My settings for VSCode
View vscode-settings.sh
# I use a community "Material Palenight" theme. I've found it has a color pallete I like a lot more for code:
# https://marketplace.visualstudio.com/items?itemName=whizkydee.material-palenight-theme
# I also use the "Material Design Icons Palenight"
# https://marketplace.visualstudio.com/items?itemName=Equinusocio.vsc-material-theme-icons
# I use a lot of extensions. Here's a list of all of them:
code --install-extension Angular.ng-template
code --install-extension attilabuti.vscode-mjml
code --install-extension auchenberg.vscode-browser-preview
code --install-extension christian-kohler.npm-intellisense
@crutchcorn
crutchcorn / promise.all.js
Last active Apr 9, 2020
An explanation of Promise.all that includes mention of mapping through them
View promise.all.js
// This is a simple promise that will return a promise that resolves after the num
const getPromiseTimeout = num => new Promise(resolve => {
setTimeout(() => resolve(num), num);
})
const timeouts = [getPromiseTimeout(100), getPromiseTimeout(300), getPromiseTimeout(200)];
// Promise.all will run these promises in whatever order it wants, but will resolve
// with the same order they were passed in on. They run in 'parallel'
// Will console.log(100, 300, 200) in the same order as the order above