Skip to content

Instantly share code, notes, and snippets.

View nucliweb's full-sized avatar

Joan León nucliweb

View GitHub Profile
@nucliweb
nucliweb / Switch-Node-Version.sh
Last active October 6, 2023 15:42
Zsh script to switch to Node defined in the .nvmrc file.
# place this after nvm initialization!
autoload -U add-zsh-hook
load-nvmrc() {
local nvmrc_path
nvmrc_path="$(nvm_find_nvmrc)"
if [ -n "$nvmrc_path" ]; then
local nvmrc_node_version
nvmrc_node_version=$(nvm version "$(cat "${nvmrc_path}")")
@nucliweb
nucliweb / function.sh
Created September 15, 2023 21:49
List and select npm scripts
## Requisites
## fzf https://github.com/junegunn/fzf
## jq https://jqlang.github.io/jq/
_nr () {
local cmd
local TASK=$(npm run | egrep '^\s' | awk '{gsub(/ /,""); print}' | awk 'NR%2==1' | fzf --preview 'jq .scripts package.json' | awk '{gsub(/ /,""); print}')
if [ -n "$TASK" ]; then
cmd="npm run \"$TASK\""
eval "$cmd" &
@nucliweb
nucliweb / rust-command-line-utilities.markdown
Created September 6, 2023 19:20 — forked from sts10/rust-command-line-utilities.markdown
A curated list of command-line utilities written in Rust

A curated list of command-line utilities written in Rust

Note: I have moved this list to a proper repository. I'll leave this gist up, but it won't be updated. To submit an idea, open a PR on the repo.

Note that I have not tried all of these personally, and cannot and do not vouch for all of the tools listed here. In most cases, the descriptions here are copied directly from their code repos. Some may have been abandoned. Investigate before installing/using.

The ones I use regularly include: bat, dust, fd, fend, hyperfine, miniserve, ripgrep, just, cargo-audit and cargo-wipe.

  • atuin: "Magical shell history"
  • bandwhich: Terminal bandwidth utilization tool
@nucliweb
nucliweb / ffmpeg-mp4-to-animated-webp.md
Created August 10, 2023 05:24 — forked from witmin/ffmpeg-mp4-to-animated-webp.md
Convert MP4 file to animated WebP in ffmpeg

Convert MP4 file to animated WEBP file in ffmpeg CLI

1. Install ffmpeg CLI through homebrew

In terminal.app, install ffmpeg through homebrew

brew install ffmpeg

Validate the installation:

@nucliweb
nucliweb / CumulativeLayoutShiftBookmarklet.js
Last active February 13, 2023 07:53 — forked from anniesullie/CumulativeLayoutShiftBookmarklet.js
Bookmarklet for showing Cumulative Layout Shift
/**
* A bookmarklet for viewing shifted elements while debugging
* Cumulative Layout Shift (web.dev/cls). Works in Chrome 84+
* Shows the previous position of shifted elements in yellow,
* and the new position in red.
*
* To install:
* 1. Copy the code starting from the line beginning `javascript:`
* 2. Add a new bookmark in Chrome, and paste the code in as the URL.
**/
@nucliweb
nucliweb / download_all_branches.sh
Created September 18, 2022 17:47 — forked from doulmi/download_all_branches.sh
Download All branches
#!/bin/bash
set -x #echo on
remote_url=$(git config --get remote.origin.url)
for branch in $(git branch --all | grep '^\s*remotes' | egrep --invert-match '(:?HEAD|master)$'); do
branch_name=$(echo $branch| cut -d'/' -f 3)
git clone -b $branch_name $remote_url $branch_name
done
@nucliweb
nucliweb / Install-OpenCV-Mac-M1.md
Last active March 6, 2024 10:18
OpenCV C++ Mac M1 Installation Steps
const puppeteer = require("puppeteer");
// const crawlPage = require("./crawl-urls");
const PAGE_URL = process.argv[2] || "https://pptr.dev";
const bytesToSize = (bytes, decimals = 2) => {
if (bytes === 0) return "0 Bytes";
const k = 1024;
const dm = decimals < 0 ? 0 : decimals;
@nucliweb
nucliweb / WebPerfMetrics.md
Last active May 6, 2022 06:53
Web Performance Metrics
@nucliweb
nucliweb / LCP.js
Created March 19, 2022 09:23
Get LCP Metrics
/**
* PerformanceObserver
*/
const po = new PerformanceObserver(list => {
let entries = list.getEntries();
entries = dedupe(entries, "startTime");
/**
* Print all entries of LCP