Skip to content

Instantly share code, notes, and snippets.

@ebith
ebith / app.ini
Last active October 22, 2020 18:19
Keypirinha configuration
[main]
scan_desktop = no
scan_env_path = no
@ebith
ebith / Communication.c
Created January 13, 2018 20:01
Serial communication, USART, LUFA Library, AVR
#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 March 15, 2020 00:17
“Windows 10で時刻同期を完璧にする方法 お前らのやり方は間違っている - Windowsは好きですが何か” http://kfujieda.hatenablog.com/entry/2020/03/14/214544
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 October 1, 2019 11:20
7-Zip付属の7zG.exeで二重フォルダを防ぎ賢く展開するWSH JScript
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 August 4, 2019 10:58
mackerel plugin for UPS-Lite
#!/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()}')
@ebith
ebith / light.sh
Created April 20, 2019 15:17
暗いときは30秒だけ明かりをつけるOctoPrint用スクリプト
#!/bin/sh
hour=$(date +%H)
if [ "$hour" -lt 9 ]; then
exit
fi
mean=$(curl -s "http://localhost/webcam/?action=snapshot" | identify -format "%[mean]" jpg:- | cut -d . -f 1)
if [ "$mean" -lt 1000 ]; then
curl -s "http://192.168.0.82:42897/api/light/on"
@ebith
ebith / .env
Created April 5, 2019 11:23
OctoPrintとスマートプラグをオンオフするスクリプト
PLUG_HOST=192.168.0.30
OCTOPI_HOST=octopi.local
API_KEY=
@powershell -NoProfile -ExecutionPolicy Unrestricted "$s=[scriptblock]::create((gc \"%~f0\"|?{$_.readcount -gt 1})-join\"`n\");&$s" %*&goto:eof
$dest = $env:USERPROFILE + '\dropbox\'
$src = 'C:\Program Files (x86)\Steam\userdata\******\582010\remote\'
While ($true) {
$saveGame = Get-ChildItem $src -Recurse | Where-Object {$_.Name -eq 'SAVEDATA1000'}
$latestBackup = Get-ChildItem $dest | Sort-Object LastWriteTime -Descending | Select-Object -first 1
if ($saveGame.LastWriteTime -gt $latestBackup.LastWriteTime) {
Copy-Item $saveGame.FullName ($dest + (Get-Date -Format yyyy-MMdd-HHmmss) + '-SAVEDATA1000')
@ebith
ebith / skipPregameVideos.bat
Created April 4, 2018 12:45
The Elder Scrolls Online: No intro fix
@powershell -NoProfile -ExecutionPolicy Unrestricted "$s=[scriptblock]::create((gc \"%~f0\"|?{$_.readcount -gt 1})-join\"`n\");&$s" %*&goto:eof
$path = "$env:USERPROFILE\Documents\Elder Scrolls Online\live\UserSettings.txt"
(Get-Content $path) | foreach { $_ -creplace "SET SkipPregameVideos `"0`"", "SET SkipPregameVideos `"1`"" } | Set-Content $path
@ebith
ebith / limoo.js
Last active September 22, 2017 17:07
通知したり読み上げたりするIRC bot (node limoo.js --port 6667 --host irc.foobar.baz --password ****** --name qux --ssl --insecure)
const argv = require('minimist')(process.argv.slice(2));
const net = argv.ssl ? require('tls') : require('net');
const irc = require('slate-irc');
const dns = require('dns');
const exec = require('child_process').exec;
const growl = require('growly');
const growlIcon = Buffer.from('iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAAB0VBMVEUAAAD////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////P+BsGAAAAmnRSTlMAAQIDBAUGBwgJCgsMDRARExQVFhcYGhscHR4fICEiIyQlJicp