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 / .eleventy.js
Created October 27, 2022 19:44
Hint VS Code for eleventyConfig autocompletion.
/**
* @param {import("@11ty/eleventy/src/UserConfig")} eleventyConfig
*/
module.exports = (eleventyConfig) => {
return {};
};
@xdesro
xdesro / killport.sh
Last active March 2, 2023 19:01
Kill processes at a given port.
function killport {
echo '🚨 Killing all processes at port' $1
lsof -ti tcp:$1 | xargs kill
}
@xdesro
xdesro / MarginTop.js
Created August 17, 2020 18:31
Godforsaken margin-top React component.
const MarginTop = (props) => (
<div>
{Array.from(Array(props.spacing)).map((br) => (
<br />
))}
{props.children}
</div>
);
ReactDOM.render(
@xdesro
xdesro / index.js
Created June 1, 2021 18:24
Check if the current device is using a mouse with both CSS and JavaScript.
if (matchMedia('(pointer:fine)').matches) {
// This browser has a mouse or other fine-control device as its primary input.
}
@xdesro
xdesro / optional-chaining.js
Created May 20, 2021 16:25
Using optional chaining operators instead of logical and operators.
// Before
const postsByAuthor = (posts) => {
return this.posts.filter(
(post) => post.author && post.author.fields.name == this.teamMember.name
);
},
// After
const postsByAuthor = (posts) => {
return this.posts.filter(
@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 / 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 / twitter-engagement-alignment.md
Created August 6, 2020 17:54
An alignment chart for analyzing the different styles of engagement on Twitter dot com.

Twitter Engagement Alignment Chart

😇 Good

Lawful Good

  • Like
  • Clean Retweet

Neutral Good

  • Like
@xdesro
xdesro / lexical-this-in-sass.scss
Created May 28, 2020 16:33
Caching specificity context using Sass' &.
.nav-item {
&__link {
color: red;
}
$this: &;
&:first-of-type {
&__link {
// this won't work 😞
color: blue;
}
[...document.querySelectorAll('a')].forEach(a => a.remove());
// ⚓️ anchors away