This file contains hidden or 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
| #include <Arduino.h> | |
| #include <SPI.h> | |
| #include <Wire.h> | |
| // ADXL345 Register Addresses | |
| #define BW_RATE 0x2C // Data rate and power mode control | |
| #define POWER_CTL 0x2D // Power Control Register | |
| #define DATA_FORMAT 0x31 // Data format control | |
| #define DATAX0 0x32 // X-Axis Data 0 |
This file contains hidden or 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
| <?php | |
| function replaceHostToIp(string $dsn): string | |
| { | |
| $url = parse_url($dsn); | |
| $recordList = dns_get_record($url['host'], DNS_A) ?: []; | |
| $ipAddr = array_reduce($recordList, static fn ($carry, $record) => $carry ?: $record['ip'] ?? null); | |
| if (null === $ipAddr) { | |
| return $dsn; |
This file contains hidden or 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
| # Power1 internal power supply | |
| # Power2 overall "virtual" pin for toggling | |
| # Power3-5 PWM chanlles | |
| def forward2all(value, trigger) | |
| for i: 3..6 | |
| tasmota.cmd("Power" + str(i) + " " + str(value)) | |
| end | |
| end |
This file contains hidden or 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
| #pragma clang diagnostic push | |
| #pragma ide diagnostic ignored "EndlessLoop" | |
| #define CONFIG_ESP32_APPTRACE_ENABLE true | |
| #include "secrets.h" | |
| #include <Arduino.h> | |
| #include <WiFi.h> | |
| #include <MQTTClient.h> | |
| #include "dto.h" |
This file contains hidden or 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
| use std::mem; | |
| fn main() { | |
| let mut num: Vec<isize> = vec![5, 12, 4, 15, 7, -1, 0, 6, 4, 3, -3, 16]; | |
| unsafe { | |
| qsort( | |
| num.as_mut_ptr() as *mut libc::c_void, | |
| num.len(), | |
| mem::size_of::<isize>(), |
This file contains hidden or 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
| <?php | |
| class ExportToArray | |
| { | |
| private const IDENT_SPACES = 4; | |
| public static function exportPhp(array $data, $depth = 1): string | |
| { | |
| $i = 0; | |
| $result = []; |
This file contains hidden or 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
| <?php | |
| function parseCSV(string $filePath, array $head) | |
| { | |
| $resource = fopen($filePath, 'rb'); | |
| if ($resource === false) { | |
| throw new \RuntimeException('Unable to read CSV file'); | |
| } |
This file contains hidden or 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
| <?php | |
| function generateUUIDv4(): string | |
| { | |
| $uuid = unpack('h8time_low/S3octet/h12node', random_bytes(16)); | |
| return sprintf( | |
| "%'08s-%'04x-%'04x-%'04x-%'012s", | |
| $uuid['time_low'], | |
| $uuid['octet1'], |