This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BaseTest { | |
// assuming fileName is the full name of a file in /test/resources | |
protected fun readFile(fileName:String) : String { | |
javaClass.classLoader?.getResourceAsStream(fileName)?.let { | |
val result = ByteArrayOutputStream() | |
val buffer = ByteArray(1024) | |
var length = it.read(buffer) | |
while (length != -1) { | |
result.write(buffer, 0, length) | |
length = it.read(buffer) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
turnLightOn = "/bin/sh -c \"curl -H 'Connection: close' -i -X POST 'https://maker.ifttt.com/trigger/record_lamp_on/with/key/your_key_here'\""; | |
turnLightOff = "/bin/sh -c \"curl -H 'Connection: close' -i -X POST 'https://maker.ifttt.com/trigger/record_lamp_off/with/key/your_key_here'\""; | |
lastState = 0; | |
function main() | |
( | |
currentState = GetPlayState() & 4; | |
lastState != currentState ? ( | |
command = currentState > 0 ? turnLightOn : turnLightOff; | |
ExecProcess(#result, command, 0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* | |
* ESP-32 code to accompany freezer door alarm project: | |
* https://hackaday.io/project/175862-quick-n-dirty-freezer-door-alarm | |
* by Guy Dupont - @dupontgu (GitHub) | |
* | |
* tl;dr | |
* Periodically check switch. If open for two consecutive checks, connect to Wi-Fi and make web request. | |
* | |
**/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Tested on a Raspbery Pi Pico W running CircuitPyton 8 | |
import socketpool | |
import wifi | |
import board | |
import array | |
import time | |
import usb_hid | |
import digitalio |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import board | |
import time | |
from analogio import AnalogIn | |
analog_in = AnalogIn(board.A0) | |
pot_v_9bit = analog_in.value >> 7 | |
pot_v_7bit = pot_v_9bit >> 2 | |
while True: | |
# take a few readings and average them for a tiny bit of filtering |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ -z "$1" ]; then | |
echo "Usage: $0 <input_video>" | |
exit 1 | |
fi | |
input_file="$1" | |
if [ -z "$2" ]; then |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# demo: https://www.youtube.com/shorts/o_DwJB-wUqo | |
# This assumes you are using the Adafruit PropMaker Feather RP2040!! | |
import board | |
import digitalio | |
import audiobusio | |
import audiocore | |
import time | |
import alarm | |
from audiomp3 import MP3Decoder |