Skip to content

Instantly share code, notes, and snippets.

@ebith
ebith / injectUserCss.js
Last active May 24, 2021
Inject CSS into a Discord client.
View injectUserCss.js
/*
* Usage
*
* copy core.asar from Discord app
* Win: %APPDATA%/discord/0.0.xxx/modules/discord_desktop_core/core.asar
* Mac: ~/Library/Application\ Support/discord/0.0.xxx/modules/discord_desktop_core/core.asar
* yarn add asar
* asar e core.asar core
* CSS_PATH=C:/dropbox/discordUser.css node injectUserCss.js
* asar p core core.asar
@ebith
ebith / main.cpp
Last active Jan 4, 2021
M5 ATOM(ESP32)でインターホンが押されたらDiscordに通知を飛ばすやつ
View main.cpp
#define FASTLED_INTERNAL
#include <Arduino.h>
#include <WiFi.h>
#include <HttpClient.h>
#include <FastLED.h>
#include <ArduinoJson.h>
const int NUM_LEDS = 1;
const int LED_PIN = 27;
@ebith
ebith / main.cpp
Created Jan 1, 2021
M5 ATOM(ESP32)で温度・湿度・気圧(BME280)をInfluxDBに投げるやつ
View main.cpp
#define FASTLED_INTERNAL
#include <Arduino.h>
#include <WiFi.h>
#include <FastLED.h>
#include <Adafruit_BME280.h>
#include <InfluxDbClient.h>
const int NUM_LEDS = 1;
const int LED_PIN = 27;
@ebith
ebith / main.cpp
Last active Dec 31, 2020
M5 ATOM(ESP32)でWiFiに常時接続してHTTP POSTするやつ
View main.cpp
#define FASTLED_INTERNAL
#include <Arduino.h>
#include <WiFi.h>
#include <HttpClient.h>
#include <FastLED.h>
#include <ArduinoJson.h>
const int NUM_LEDS = 1;
const int LED_PIN = 27;
@ebith
ebith / main.cpp
Created Nov 30, 2020
ATOM Liteで作るPCの電源スイッチ
View main.cpp
#include <Arduino.h>
#include <WiFi.h>
#include <FastLED.h>
#include <WebServer.h>
#include <ESPmDNS.h>
const int NUM_LEDS = 1;
const int LED_PIN = 27;
static CRGB leds[NUM_LEDS];
@ebith
ebith / app.ini
Last active Oct 22, 2020
Keypirinha configuration
View app.ini
[main]
scan_desktop = no
scan_env_path = no
@ebith
ebith / Communication.c
Created Jan 13, 2018
Serial communication, USART, LUFA Library, AVR
View Communication.c
#include <stdio.h>
#include <avr/interrupt.h>
#include <LUFA/Drivers/Peripheral/Serial.h>
#define MAX_BUFFER 32
char b[MAX_BUFFER];
uint8_t l = 0;
ISR(USART1_RX_vect) {
char c = fgetc(stdin);
printf("%c", c);
@ebith
ebith / ntp.bat
Created Mar 15, 2020
“Windows 10で時刻同期を完璧にする方法 お前らのやり方は間違っている - Windowsは好きですが何か” http://kfujieda.hatenablog.com/entry/2020/03/14/214544
View ntp.bat
sc triggerinfo w32time start/networkon stop/networkoff
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Parameters" /v NtpServer /d ntp.nict.jp,0x8 /f
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Config" /v UpdateInterval /t REG_DWORD /d 100 /f
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Config" /v PhaseCorrectRate /t REG_DWORD /d 7 /f
pause
@ebith
ebith / extractArchive.js
Last active Oct 1, 2019
7-Zip付属の7zG.exeで二重フォルダを防ぎ賢く展開するWSH JScript
View extractArchive.js
var wshell = new ActiveXObject('WScript.Shell');
var fso = new ActiveXObject( 'Scripting.FileSystemObject');
var archivePath = WScript.arguments(0);
var dirPath = wshell.currentDirectory + '/' + fso.getBaseName(archivePath);
var process = wshell.Exec('"C:/Program Files/7-zip/7zG.exe" x "' + archivePath + '" -aou -spe -o"' + dirPath + '"');
while (process.status !== 1) {
WScript.sleep(10);
}
@ebith
ebith / batteryCapacity.py
Last active Aug 4, 2019
mackerel plugin for UPS-Lite
View batteryCapacity.py
#!/usr/bin/env python3
import time
import smbus
i2c = smbus.SMBus(1)
addr=0x36
data = i2c.read_i2c_block_data(addr, 0x04, 2)
capacity = int((data[0] << 8 | data[1]) / 256)
print(f'battery.capacity\t{capacity}\t{time.time()}')