Skip to content

Instantly share code, notes, and snippets.

Avatar
👷‍♂️
Making

Cody Gagnon codycodes

👷‍♂️
Making
View GitHub Profile
@codycodes
codycodes / hue-remote-dimmer-december-2021.yaml
Last active Jan 6, 2022
Blueprint to create Home Assistant automations based on Hue Remote Dimmer Button Press/Holds (created using the RWL020 dimmer)
View hue-remote-dimmer-december-2021.yaml
blueprint:
name: Hue Dimmer Remote
description: |
(Dec 2021 Update) Using a Hue bridge with which a dimmer remote is paired, allows you to configure actions based on said Hue Dimmer Remote
NOTE: tested with RWL020 but may also work with RWL021
domain: automation
source_url: https://gist.github.com/codycodes/f051781c35cfdfee15162ff680c9cbd8
input:
dimmer_device:
name: Dimmer Remote Device
View upstairs_den_bedroom_bed.yaml
esphome:
name: upstairs_den_bedroom_bed
platform: ESP32
board: esp32doit-devkit-v1
sensor:
# Bed
- platform: adc
id: bedside_sensor
pin: GPIO32
@codycodes
codycodes / steno_keys_memorizer.py
Last active Mar 11, 2021
Stenography Layout Memorizer
View steno_keys_memorizer.py
keys = "#STKPWHRAO*EUFRPBLGTSDZ".lower()
i = 0
while i < len(keys):
currentLetter = input(f'What is the {i} key for the steno order?: ').lower()
if currentLetter == keys[i]:
i += 1
else:
print(f"Sorry, that's incorrect! Currently we have: {keys[:i].upper()}")
@codycodes
codycodes / steno_number_keys_memorizer.py
Last active Mar 11, 2021
Stenography Number Keys Memorizer
View steno_number_keys_memorizer.py
keys = "OSTPHAFPLT".lower()
i = 0
while i < len(keys):
currentLetter = input(f'What is the {i} key for the steno number order?: ').lower()
if currentLetter == keys[i]:
i += 1
else:
print(f"Sorry, that's incorrect! Currently we have: {keys[:i].upper()}")
@codycodes
codycodes / get_stored_airport_wifi_passwords.js
Last active Nov 24, 2020
Two commands to get your current WiFi password or any WiFi password stored in your macOS keychain!
View get_stored_airport_wifi_passwords.js
#!/bin/bash
get_current_wifi_password() {
# this command from http://bit.ly/2zWtUhQ
current_wifi=`/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I | \
awk '/ SSID/ {print substr($0, index($0, $2))}'`
security find-generic-password -a "$current_wifi" -g | tail -0
}
get_wifi_password() {
@codycodes
codycodes / macOS Automator Universal Find + Replace.md
Last active Sep 24, 2020
Automator Service which allows you to easily find/replace all occurrences of selected text via Python
View macOS Automator Universal Find + Replace.md

Steps to setup:

  1. Download the file " universal_find_replace.zip" and unzip it (you can do unzip universal_find_replace.zip in the Terminal or right-click and decompress from the GUI.
  2. Click the Universal Find + Replace. and install it
  3. Set a keyboard shortcut to invoke it, or use the Services dropdown by right-clicking after selecting some text (see image below for the preference pane).

NOTE: Safari 14 broke the functionality to "Output replaces selected text"; therefore this script uses a workaround of copying the output to the clipboard. As of today, you'll then need to paste this back in on Safari 14; it will automatically replace the text in other apps. See this link for more info.

@codycodes
codycodes / Some Trello Keyboard Shortcuts
Last active Jan 15, 2020
Allows you to use the keyboard shorcuts in the comments to manipulate hiding/showing the calendar and going to its today view as well as starting/stopping pomodone if you use it
View Some Trello Keyboard Shortcuts
// ==UserScript==
// @name Some Trello Keyboard Shortcuts
// @namespace https://cody.codes
// @version 0.1
// @description Allows you to use the keyboard shorcuts in the comments to manipulate hiding/showing the calendar and going to its today view as well as starting/stopping pomodone if you use it
// @author You
// @match https://trello.com/b/*
// @grant none
// ==/UserScript==
View bulb.js
//bulb.js
input.onGesture(Gesture.Shake, function () {
// This IF is satisfied only after connecting and
// disconnecting the bulb from the base, then shaking
// the bulb. This results in the bulb only going back
// to white after it's been connected to the base, as
// it's not a value inside "shake colors"
if (shake_after_connect == 1) {
light.setAll(0xffffff)
shake_after_connect = 0
View base.js
// base.js
let item = 0
let must_reset = 0
let reset_photon = 0
pins.A3.setPull(PinPullMode.PullUp)
let brightness = 120
light.setAll(0xffffff)
forever(function () {
// I love this software hack! When using the Photon
// module (which is a Turtle which can draw lights on
@codycodes
codycodes / usb_switch.ino
Last active Jul 19, 2019
USB switch hacking!
View usb_switch.ino
int relayPin = 5; // red
int usbDetectPin = 6; // green
int button = 7; // purple -> blue/white
void setup() {
// put your setup code here, to run once:
pinMode(relayPin, INPUT);
pinMode(usbDetectPin, INPUT); //
// pinMode(button, OUTPUT); // TODO: we may want this button to be an input
// if we want to read its data for debugging