Skip to content

Instantly share code, notes, and snippets.

View kbravh's full-sized avatar
🦈

Karey Higuera kbravh

🦈
View GitHub Profile
@kbravh
kbravh / wordleGuess.js
Last active January 17, 2022 13:55
Displays the Wordle-style line of emojis for a given guess and solution. Cassidoo newsletter #231
const wordleGuess = (guess, solution) =>
[...guess].map((letter, i) =>
solution[i] === letter ? '🟩'
: solution.includes(letter) &&
guess.slice(0, i + 1).split(letter).length -1 <= solution.split(letter).length - 1 ? '🟨'
: '⬛').join('')
const solutionWord = 'fudge'
console.log(wordleGuess('reads', solutionWord)) // ⬛🟨⬛🟨⬛
@kbravh
kbravh / README.md
Last active April 22, 2024 08:19
Switch audio output devices on Linux

Audio Output Switcher

This script will cycle to the next available audio output device. It can be tied to a hotkey to easily be triggered. This is handy, for example, for swapping between speakers and headphones.

This script will work on systems running PulseAudio or Pipewire services.

Install

  1. Download the audio-device-switch.sh script and place it in /usr/local/bin.
  2. Make the script executable: sudo chmod 755 /usr/local/bin/audio-device-switch.sh.
  3. Open the Keyboard Shortcuts settings page, add a new shortcut, tell it to execute audio-device-switch.sh, and set up your shortcut!
  4. Install the notify-send library if you want to see a popup notification when the audio device switches: sudo apt install libnotify-bin.
@kbravh
kbravh / adjust-cron-for-dst.py
Last active March 26, 2023 17:14
Adjust cron events for DST (Daylight Savings Time) automatically with a Python function to be run on AWS Lambda.
from datetime import datetime
import pytz
import boto3
# define our CloudEvents client
client = boto3.client('events')
# Let's grab our current time in GMT and convert it to local time (US Central)
utc_time = datetime.utcnow().replace(tzinfo=pytz.utc)
# Set your timezone here! See timezones here: https://gist.github.com/heyalexej/8bf688fd67d7199be4a1682b3eec7568