Skip to content

Instantly share code, notes, and snippets.

View xdesro's full-sized avatar
👨‍💻
Doing some coding for the 'Net.

Henry Desroches xdesro

👨‍💻
Doing some coding for the 'Net.
View GitHub Profile
@xdesro
xdesro / findFiles.js
Last active September 12, 2017 20:48
A node.js function to find all files in a directory by given filter.
const fs = require('fs');
const path = require('path');
function findFiles(startPath,filter,callback){
if (!fs.existsSync(startPath)){
console.log("Gosh, can't seem to find what you're looking for, my friend! Try a different startPath");
return;
}
const files=fs.readdirSync(startPath);
for (let currentFilePath of files) {
@xdesro
xdesro / codepen-posts.scss
Created June 5, 2019 16:02
CodePen posts custom styling to fit ~my brand~
@import url("https://rsms.me/inter/inter.css");
$color--primary: #030303;
$color--accent: #FF0080;
$color--background: #fefefe;
@mixin inter {
font-family: "Inter", sans-serif;
@supports (font-variation-settings: normal) {
font-family: "Inter var", sans-serif;
}
}
@xdesro
xdesro / FreeDarkMode.md
Last active October 23, 2020 17:08
Bookmarklet to quickly convert a site from light to dark mode.

Quick & Easy & Dirty Dark Mode Bookmarklet

Okay to be clear this won't always work and definitely won't always work well. But it's something. It's not the dark mode we deserve. But it's the one we need right now.

To Install:

  1. Create a new bookmark in whatever browser.
  2. Set the target or location of the bookmark to the following snippet.
javascript:(function(){document.documentElement.style.mixBlendMode = 'difference';document.documentElement.style.filter = 'hue-rotate(180deg)';})();
@xdesro
xdesro / pullparty.sh
Created July 28, 2019 21:08
It's a pull party, baby!
pullparty() {
echo "🍹 Pull party baby! 🏝👙"
CURRENT_BRANCH=$(git symbolic-ref --short -q HEAD);
git checkout develop;
git pull;
git checkout $CURRENT_BRANCH;
git merge develop;
}
@xdesro
xdesro / vanilla.js
Created August 15, 2019 15:43
In VSCode, you can add `// @ts-check` to the beginning of a vanilla JS file to enable type-checking on the file.
// @ts-check
/**
* @return {String}
*/
const someFunc = () => {
return 4; // err in VSCode: "Type '4' is not assignable to type 'String'
}
someFunc('test'); // err in VSCode: "Expected 0 args but got 1"
@xdesro
xdesro / example.md
Created August 20, 2019 20:17
A VSCode snippet for logging a variable out with its name prefixed.

📦 How To Install

  1. Bring up the Command Palette with ++P
  2. Type "Configure User Snippets".
  3. Select "New Global Snippets file".
  4. Name it whatever you want.
  5. Paste in the contents of the .code-snippets file in this gist.

📑 How To Use

  1. Bring up the Command Palette with ⌘+⇧+P
@xdesro
xdesro / staticgen-archive.json
Created August 20, 2019 22:25
STATICGEN.COM DATA ARCHIVE
This file has been truncated, but you can view the full file.
{"timestamp":1566339845792,"data":{"ace":[{"timestamp":1566339845792,"stars":36,"forks":6,"issues":0,"repo":"https://github.com/botanicus/ace","updated":"2019-08-13T14:37:58Z","data":{"id":1009145,"node_id":"MDEwOlJlcG9zaXRvcnkxMDA5MTQ1","name":"ace","full_name":"botanicus/ace","private":false,"owner":{"login":"botanicus","id":6171,"node_id":"MDQ6VXNlcjYxNzE=","avatar_url":"https://avatars2.githubusercontent.com/u/6171?v=4","gravatar_id":"","url":"https://api.github.com/users/botanicus","html_url":"https://github.com/botanicus","followers_url":"https://api.github.com/users/botanicus/followers","following_url":"https://api.github.com/users/botanicus/following{/other_user}","gists_url":"https://api.github.com/users/botanicus/gists{/gist_id}","starred_url":"https://api.github.com/users/botanicus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/botanicus/subscriptions","organizations_url":"https://api.github.com/users/botanicus/orgs","repos_url":"https://api.github.com/users/botanicus/rep
@xdesro
xdesro / _magic.css
Created September 19, 2019 17:56
The most useful line of CSS I've ever written.
*, *:before, *:after { box-sizing: border-box; }
@xdesro
xdesro / keybase.md
Created September 24, 2019 16:46
keybase.md

Keybase proof

I hereby claim:

  • I am xdesro on github.
  • I am xdesro (https://keybase.io/xdesro) on keybase.
  • I have a public key ASBtNEeMTTXWFG-Jxxok57XywdnhyaRX8NU8kajMBnk6eQo

To claim this, I am signing this object:

@xdesro
xdesro / component-sans-moment.js
Last active December 11, 2019 17:58
Converting moment.js to vanilla JavaScript with `.toLocaleDateString()`
// This is meant to be a Vue component, cause my site https://henry.codes is built with Nuxt.js. I put the .js extension on there for that fresh Gist syntax highlighting.
export default {
computed: {
postDate() {
return new Date(this.post.fields.publishDate).toLocaleDateString("en-US", { month: "short", year: "2-digit" });
}
}
};