Skip to content

Instantly share code, notes, and snippets.

View junosuarez's full-sized avatar
💭
hi hello

juno suárez junosuarez

💭
hi hello
View GitHub Profile
@junosuarez
junosuarez / gist:c5a60a6bad213615ca2d4f2b1dc53f9a
Created April 24, 2024 16:38
Recover a docker run command from a running docker container
docker inspect \
--format "$(curl -s https://gist.githubusercontent.com/efrecon/8ce9c75d518b6eb863f667442d7bc679/raw/run.tpl)" \
name_or_id_of_your_running_container
# via https://stackoverflow.com/a/38077377
@junosuarez
junosuarez / find-selection-vars.js
Last active April 17, 2023 21:21
A workaround for "broken" text selection on some sites in Chrome
// Find all css vars used in ::selection styles - use this snippet in dev tools
new Set(
Array.from(document.styleSheets)
.flatMap(s => { try { return Array.from(s.rules) } catch (e) { return [] } })
.filter(rule => rule.selectorText?.includes('::selection'))
.flatMap(rule => Array.from(rule.cssText.matchAll(RE_CSS_VAR))
.map(match => match.groups.varName)
)
)
@junosuarez
junosuarez / setup.md
Last active December 19, 2022 17:17
how to setup mastodon forwarding from your custom domain using webfinger and github pages

how to setup mastodon forwarding from your custom domain using webfinger and github pages

by @[email protected]

tldr

say you have your own domain, cool.example, and you'd rather use [email protected] as your identity instead of [email protected]. you can!

prerequisites

I'll assume you already have a repo setup with github pages turned on (or some other static site hosting), and that you already have a mastodon account somewhere.

theory

@junosuarez
junosuarez / gitstatus-prompt.zsh
Created October 28, 2022 07:46
starship + gitstatusd
#!/bin/zsh
# include this file in your shell config
autoload -Uz add-zsh-hook
# this file comes from installing https://github.com/romkatv/gitstatus
SOURCE "${HOMEBREW_PREFIX:-/usr/local}/opt/gitstatus/gitstatus.plugin.zsh" || return
gitstatusd_instance='GSD'
# the following are a mystery - why do they define the fn names with $1?
@junosuarez
junosuarez / π.js
Created January 9, 2020 06:11
Approximating π by simulation
/*
Approximating π by simulation
see live on runkit at https://runkit.com/junosuarez/5e16c3e9ccfea2001ae2c8f5
In 1733 the French naturalist Georges Louis Leclerc, Comte de Buffon, posed and
solved the following problem in geometric probability: when a needle of length L is
dropped onto a wooden floor constructed from boards of width D (where D ≥ L),
what is the probability that it will lie across a seam between two boards?
Buffon determined that the probability is 2L/Dπ.
via https://www.maa.org/sites/default/files/s1000042.pdf
@junosuarez
junosuarez / jq.sh
Created January 31, 2019 20:40
export repos
cat repos.json | jq '.repos | sort_by(.nameWithOwner) | .[].nameWithOwner | "https://github.com/\(.)"'
{
"Set Local Environment Vars" : true,
"Working Directory" : "\/Users\/jdenizac",
"Prompt Before Closing 2" : 0,
"Selected Text Color" : {
"Green Component" : 0,
"Red Component" : 0,
"Blue Component" : 0
},
"Rows" : 25,
\e[38;5;82mHello \e[38;5;198mWorld
\e[38;5;82mHello \e[38;5;198mWorld
\e[38;5;82mHello \e[38;5;198mWorld
@junosuarez
junosuarez / index.js
Last active June 21, 2019 01:32
async cli app boilerplate
#!/usr/bin/env node
if (process.mainModule === module) setImmediate(() => main(process.argv).catch(e => console.log(e.stack) && process.exit(1)))
async function main(argv) {
console.log(argv.slice(2))
}
@junosuarez
junosuarez / index.js
Created June 27, 2017 22:03
non-matched shebang
#! /usr/bin/env node
console.log((new Date().getHours()) < 12 ? 'buenos!' : 'buenas!')