Skip to content

Instantly share code, notes, and snippets.

@andrewcchen
andrewcchen / tuya_ir_encode.js
Created August 13, 2023 19:44
Encode an NEC IR command into code for Tuya ZS06/ZS08/TS1201
/*
Encode an NEC IR command into code for Tuya ZS06/ZS08/TS1201
Usage: encode_nec("<four bytes in hex, two bytes of address followed by two bytes of command>")
If your address and/or command is just one byte (8 bits), append the complement of the byte after it to make it two bytes.
Example:
encode_nec("04fb08f7") // encodes nec address 0x04 and command 0x08
See:
diff --git a/tmk_core/common/action.c b/tmk_core/common/action.c
index 3a3c401..35ffc7d 100644
--- a/tmk_core/common/action.c
+++ b/tmk_core/common/action.c
@@ -66,6 +66,12 @@ void process_action(keyrecord_t *record)
if (IS_NOEVENT(event)) { return; }
action_t action = layer_switch_get_action(event.key);
+ static action_t action_on_press[MATRIX_ROWS][MATRIX_COLS];
+ if (event.pressed) {
@andrewcchen
andrewcchen / Satan.md
Created October 15, 2016 05:14
Satan

This is a quick guide to changing the keymap on the GH60 "Satan" or RevCHN. Note that the Satan is NOT a true GH60, and using the GH60 with the normal TMK would not work.

Note that installing dependencies or compiling TMK is not a part of the scope of this document. If you have problems with this part, seek help elsewhere. Note also that these instructions are written for Linux and Mac. If you're using windows, just use the Command Prompt for the git commands, and Windows Explorer to move and delete files. Thirdly, I don't do backlighting or lighting. Whenever I tried to compile this software with support for pwm or any of that stuff, it failed, so I removed those functions. So if you like the lights, you have some debugging to do. Feel free to fork this gist and send me a PR if you can fix it :)

  1. Dependencies.
  2. Download and install GIT: https://git-scm.com/downloads
  3. Download and install the dependencies for compiling TMK: https://github.com/tmk/tmk_keyboard/blob/core/doc/build.md (Point 1 only)
@andrewcchen
andrewcchen / launch.sh
Last active August 29, 2015 14:18
A Multi-Configuration Launcher for Eclipse
#!/bin/bash
# A Multi-Configuration Launcher for Eclipse
array_contains () {
local array="$1[@]"
local seeking=$2
local in=1
@andrewcchen
andrewcchen / gist:52c987c29ebb884234c8
Last active January 9, 2016 20:54
Solution to NZIC 2015 Round 1 Problem 4 (The Greatest Stew)

Abridged problem statement

Given a total cooking time of T and a list of ingredients with properties: t[i], a[i], b[i].
The value of each ingredient put in is (a[i] + (brew time) * b[i]) where brew time = T - (time the ingredient was put in).
Each ingredient put in has to cook for t[i] time before another ingredient can be put in.
Each ingredient can only be used once.
Our task is to output the maximum value that can be obtained.

Algorithm

@andrewcchen
andrewcchen / graph_triangles.cpp
Last active August 29, 2015 14:15
Naive C++ code to count triangles in a undirected graph
#include <ctime>
#include <cassert>
#include <string>
#include <fstream>
#include <sstream>
#include <memory>