Skip to content

Instantly share code, notes, and snippets.

View rdeprey's full-sized avatar

Rebecca Deprey rdeprey

View GitHub Profile
@rdeprey
rdeprey / alternating-led-strands.ino
Last active December 28, 2021 23:10
Arduino Sketch for Blinking Strands of LEDs
// Set which pin each strand of lights is connected to
int lightStrand1 = A4;
int lightStrand2 = 3;
// Runs once
void setup() {
// Set strands as outputs
pinMode(lightStrand1, OUTPUT);
pinMode(lightStrand2, OUTPUT);
@rdeprey
rdeprey / machine.js
Last active January 19, 2021 14:48
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@rdeprey
rdeprey / user_neopixel.cpp
Created September 20, 2020 15:19
C++ Code to Set HalloWing M4 NeoPixel Colors
#if 1 // Change to 1 to enable this code (must enable ONE user*.cpp only!)
#include <Adafruit_NeoPixel.h> // Imports the NeoPixel library
#define LED_PIN 8 // The NeoPixels are on Port 8
#define LED_COUNT 4 // There are 4 NeoPixels on the board
Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
void user_setup(void) {
@rdeprey
rdeprey / package.json
Last active November 9, 2021 16:36
Automatic Plant Waterer
{
"name": "plant-waterer",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node ./bin/www"
},
"dependencies": {
"node-schedule": "^1.3.2",
"onoff": "^6.0.0",
@rdeprey
rdeprey / GetFilenames.ps
Created September 23, 2019 23:33
Powershell Script to Get Filenames for all Files in a Folder
Get-ChildItem -Path 'websites/plant-classifier/PlantClassifierWeb/plant-classifier-web/src/plant-disease-data/train' -Recurse -Name | Out-File -FilePath desktop\filenames.txt
@rdeprey
rdeprey / taco-object.fromEntries.js
Created April 2, 2019 00:41
Create an object from an array of key/value pairs using the Object.fromEntries() method
const taco = {
tortillaType: 'corn',
meat: 'chicken',
toppings: 'lettuce, cheese, tomatoes',
};
const tacoProperties = Object.entries(taco); // Array looks like [['tortillaType', 'corn'], ['meat', 'chicken'], ['toppings', 'lettuce, cheese, tomatoes']]
const updatedTacoArr = tacoProperties.map(property => {
@rdeprey
rdeprey / taco-object.entries.js
Created April 2, 2019 00:05
Get a two-dimensional array of an object's key/value pairs using the Object.entries() method
const taco = {
tortillaType: 'corn',
meat: 'chicken',
toppings: 'lettuce, cheese, tomatoes',
};
const tacoArr = Object.entries(taco);
console.log(tacoArr); // Expected output: [['tortillaType', 'corn'], ['meat', 'chicken'], ['toppings', 'lettuce, cheese, tomatoes']]
@rdeprey
rdeprey / taco-object.values.js
Created April 2, 2019 00:02
Get an array of an object's values using the Object.values() method
const taco = {
tortillaType: 'corn',
meat: 'chicken',
toppings: 'lettuce, cheese, tomatoes',
};
const tacoValues = Object.values(taco);
console.log(tacoValues); // Expected output: ['corn', 'chicken', 'lettuce, cheese tomatoes']
@rdeprey
rdeprey / taco-object.keys.js
Created April 1, 2019 23:59
Get an array of an object's properties using the Object.keys() method
const taco = {
tortillaType: 'corn',
meat: 'chicken',
toppings: 'lettuce, cheese, tomatoes',
};
const tacoProperties = Object.keys(taco);
console.log(tacoProperties); // Expected output: ['tortillaType', 'meat', 'toppings']
@rdeprey
rdeprey / taco-for-in-loop
Last active April 2, 2019 00:00
Converting an object to an array using a for... in loop
const taco = {
tortillaType: 'corn',
meat: 'chicken',
toppings: 'lettuce, cheese, tomatoes',
};
const tacoArr = [];
for (value in taco) {
tacoArr.push([value, taco[value]]);
}