Skip to content

Instantly share code, notes, and snippets.

View BrianMehrman's full-sized avatar
🏠
Working from home

Brian Mehrman BrianMehrman

🏠
Working from home
View GitHub Profile
@mikowl
mikowl / oneliners.js
Last active June 29, 2024 17:39
👑 Awesome one-liners you might find useful while coding.
// Inspired by https://twitter.com/coderitual/status/1112297299307384833 and https://tapajyoti-bose.medium.com/7-killer-one-liners-in-javascript-33db6798f5bf
// Remove any duplicates from an array of primitives.
const unique = [...new Set(arr)]
// Sleep in async functions. Use: await sleep(2000).
const sleep = (ms) => (new Promise(resolve => setTimeout(resolve, ms)));
// or
const sleep = util.promisify(setTimeout);
@hfreire
hfreire / qemu_osx_rpi_raspbian_jessie.sh
Last active March 24, 2024 14:35
How to emulate a Raspberry Pi (Raspbian Jessie) on Mac OSX (El Capitan)
# Install QEMU OSX port with ARM support
sudo port install qemu +target_arm
export QEMU=$(which qemu-system-arm)
# Dowload kernel and export location
curl -OL \
https://github.com/dhruvvyas90/qemu-rpi-kernel/blob/master/kernel-qemu-4.1.7-jessie
export RPI_KERNEL=./kernel-qemu-4.1.7-jessie
# Download filesystem and export location
@ddrscott
ddrscott / letters.rb
Created April 15, 2014 05:18
My son wanted to see colorful letters. This is what I came up with. He actually stayed awake as I type it. It was originally a one liner done in IRB.
az=("A".."z").to_a.map {|m|
"\033[38;5;#{rand(180)+16}m#{m}\033[0m" # wrap char in random color
}
loop {
puts [az*" "] * 25 # fill some of the screen
az<<(az.shift) # rotate chars
sleep(0.3) # slow down
puts "\e[26F" # cursor up 26 lines
}
@gcatlin
gcatlin / gist:1847248
Created February 16, 2012 19:43
Install specific version of Homebrew formula
brew update
brew versions FORMULA
cd `brew --prefix`
git checkout HASH Library/Formula/FORMULA.rb # use output of "brew versions"
brew install FORMULA
brew switch FORMULA VERSION
git checkout -- Library/Formula/FORMULA.rb # reset formula
## Example: Using Subversion 1.6.17
#