Skip to content

Instantly share code, notes, and snippets.

View cms's full-sized avatar

Christian C. Salvadó cms

View GitHub Profile
@jameshulse
jameshulse / how.sh
Created January 12, 2024 22:16
Bash script to determine how a binary was installed
how() {
YELLOW='\033[1;33m'
NC='\033[0m'
if [[ "$1" == "" || "$1" == "-h" || "$1" == "--help" ]]; then
echo "Usage: $0 <binary name>"
echo ""
echo "This will search for the binary in a few different places and try and determine how it was installed."
return 1
fi
@cms
cms / array-chunks.js
Created March 22, 2019 18:59
array chunks
// Using Array.prototype.reduce:
const getChunks = (array, size) => {
return array.reduce((acc, curr, i) => {
const pos = Math.floor(i/size);
acc[pos] = [...(acc[pos]||[]), curr];
return acc
}, [])
}
// Using Array.from:
@Rich-Harris
Rich-Harris / footgun.md
Last active April 19, 2024 07:47
Top-level `await` is a footgun

Edit — February 2019

This gist had a far larger impact than I imagined it would, and apparently people are still finding it, so a quick update:

  • TC39 is currently moving forward with a slightly different version of TLA, referred to as 'variant B', in which a module with TLA doesn't block sibling execution. This vastly reduces the danger of parallelizable work happening in serial and thereby delaying startup, which was the concern that motivated me to write this gist
  • In the wild, we're seeing (async main(){...}()) as a substitute for TLA. This completely eliminates the blocking problem (yay!) but it's less powerful, and harder to statically analyse (boo). In other words the lack of TLA is causing real problems
  • Therefore, a version of TLA that solves the original issue is a valuable addition to the language, and I'm in full support of the current proposal, which you can read here.

I'll leave the rest of this document unedited, for archaeological

Just some notes and references for myself.

  • In bash, you can access your C:\ drive via /mnt/c/
  • ~ = C:\Users\MLM\AppData\Local\lxss\home\mlm and is different from your Windows user directory C:\Users\MLM

How to google things

@bcicen
bcicen / somacli.sh
Last active March 8, 2019 18:01
somacli
#!/bin/bash
baseurl="http://somafm.com"
tmpdir="/tmp/"
boldtext=`tput bold`
normaltext=`tput sgr0`
WGET="/usr/bin/wget"
MPLAYER="/usr/bin/mplayer"
stationnames=("Christmas Rocks!" "Christmas Lounge" "Xmas in Frisko (holiday)" "Groove Salad (ambient/electronica)" "Lush (electronica)" "Earwaves (experimental)" "Deep Space One (ambient)" "Drone Zone (ambient)" "PopTron (alternative)" "DEF CON Radio (specials)" "Dub Step Beyond (electronica)" "Space Station Soma (electronica)" "Mission Control (ambient/electronica)" "Indie Pop Rocks! (alternative)" "Folk Forward (folk/alternative)" "BAGeL Radio (alternative)" "Digitalis (electronica/alternative)" "Sonic Universe (jazz)" "Secret Agent (lounge)" "Suburbs of Goa (world)" "Boot Liquor (americana)" "Illinois Street Lounge (lounge)" "The Trip (electronica)" "cliqhop idm (electronica)" "Iceland Airwaves (alternative)" "Covers (eclectic)" "Underground 80s (alternative/electronica)" "Beat Blender (electronica)" "Doomed (ambient/industrial)" "Black Rock FM (eclectic)" "SF

Download the inspect-registers.vim file from this gist. Open the file in Vim, launching with no vimrc:

vim -Nu NONE inspect-registers.vim

Source the file:

:source %

Insert text on line one:

@blueyed
blueyed / _tmux_pane_words.zsh
Last active May 26, 2023 07:39
ZSH configuration to complete words from tmux pane(s)
# Complete words from tmux pane(s) {{{1
# Source: http://blog.plenz.com/2012-01/zsh-complete-words-from-tmux-pane.html
# Gist: https://gist.github.com/blueyed/6856354
_tmux_pane_words() {
local expl
local -a w
if [[ -z "$TMUX_PANE" ]]; then
_message "not running inside tmux!"
return 1
fi
@alexyoung
alexyoung / tmux.conf
Created July 19, 2013 16:12
tmux cheap powerline
#!/usr/bin/env sh
ioreg -l | grep -i capacity | tr '\n' ' | ' | awk '{printf("%.2f%%\n", $10/$5 * 100)}'
@gak
gak / fish-prompt.sh
Last active February 4, 2022 18:34
My custom fish prompt code explained at http://geraldkaszuba.com/tweaking-fish-shell/
function _common_section
printf $c1
printf $argv[1]
printf $c0
printf ":"
printf $c2
printf $argv[2]
printf $argv[3]
printf $c0
printf ", "
@mszczepanczyk
mszczepanczyk / grab.c
Created May 27, 2013 09:30
ugly hack
// gcc grab.c -o grab -lX11
// ugly hack to catch windows key before application and change i3 workspace if windows+[0-9] is pressed
// usage: grab winid_1 winid_2 ...
// example:
// grab `xwininfo -root -tree -int |grep " - Oracle VM VirtualBox" | awk '{print $1}'`
#include <X11/X.h>
#include <X11/Xlib.h>