Skip to content

Instantly share code, notes, and snippets.

@NeoCat
NeoCat / QiPacketAnalyzer.ino
Created September 24, 2017 20:16
Qi packet analyzer
const int input_pin = 9;
void setup() {
Serial.begin(115200);
Serial.println("START");
pinMode(input_pin, INPUT);
}
int count = 0;
int last = 0;
@NeoCat
NeoCat / switch-tty.sh
Last active March 28, 2018 05:06
Script to switch console attached to a command (for Linux)
#!/bin/bash
# For example: switch-tty.sh `pidof vi` `tty`
target=$1
dest=$2
if [ -z "$target" -o -z "$dest" ]; then
echo "usage: $0 pid target"
exit 1
fi
@NeoCat
NeoCat / monitor_ios_battery.rb
Last active December 31, 2016 13:49
Monitor iOS battery level and stop charging when the level >= 80% (restart when the level < 80%)
#!/usr/bin/ruby
require 'timeout'
THRESH = 80 # %
SPEED = 60 # sec / %
$IDEVICEINFO_CMD = '/usr/local/bin/ideviceinfo'
$POWER_ON_CMD = 'curl -s -m 5 192.168.x.x/on'
$POWER_OFF_CMD = 'curl -s -m 5 192.168.x.x/off'
$state = nil
$caffe_pid = nil
@NeoCat
NeoCat / 0001-Adds-NAPT-and-port-mapping-functionality-to-esp8266-.patch
Last active March 8, 2019 15:33
Patch to add NAPT and port mapping functionality to esp8266
From 1dfbeab6f4ca7287e27c31a9f90ddec3343a18d5 Mon Sep 17 00:00:00 2001
From: NeoCat <neocat@neocat.jp>
Date: Thu, 13 Oct 2016 22:19:22 +0900
Subject: [PATCH] Adds NAPT and port mapping functionality to esp8266 lwip
esp8266 can handle 2 network interfaces (Wifi client and softAP)
simultaneously in the WIFI_AP_STA mode.
Currently IP_FORWARD is implemented in lwip to forward packets
between 2 interfaces, but static routing must be setup manually.
This patch adds IP_NAPT config option to enable esp8266 to use
@NeoCat
NeoCat / config.py
Created September 23, 2016 15:41
keyhacを使ってNICOLA配列(ローマ字入力設定用)にするためのconfig例
import sys
import os
import datetime
import subprocess
import re
import time
from keyhac import *
class NICOLA:
@NeoCat
NeoCat / power.html
Last active May 16, 2018 07:05
スマートメーターからの電力をBP35A1を使って取得・Webブラウザ上でリアルタイムにグラフ描画 (詳細: http://d.hatena.ne.jp/NeoCat/20160117/1453021993 )
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Power</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-2.2.0.min.js"></script>
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/highcharts-more.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<style type="text/css">
@NeoCat
NeoCat / SmartMeter.ino
Last active May 26, 2020 18:21
スマートメーターから瞬時電力を取得して7セグに表示するArduino用スケッチ
#include <SoftwareSerial.h>
// Detail: http://d.hatena.ne.jp/NeoCat/20160110/1452407542
//-----------------------------------------------------------
// Configurations
//-----------------------------------------------------------
// B-route ID and Password (PANA authentication)
#define ID "0000XXXXXXXXXXXXXXXXXXXXXXXXXXXX"
@NeoCat
NeoCat / test-pib-iser.sh
Created April 1, 2015 19:40
Test tgtd iSER connection via pib (tested in Fedora 21)
#!/bin/sh
IB_ADDR=172.24.100.1
TARGET_IQN=iqn.2015-05.com.example:test
if [ $EUID -ne 0 ]; then
sudo "$0" "$@"
exit $?
fi
@NeoCat
NeoCat / gist:a6189f245347581d608c
Created January 20, 2015 22:50
twicli CSS - Don't enlarge thumbnails on hover & enlarge thumbnails when selected
/* twicliの設定→ユーザスタイルシートに下記をペーストして保存 */
/* サムネールをマウスオーバーで拡大しない */
.thumbnail-image:hover { max-width: 32px; width: 32px\9; }
/* tweetをクリックで選択した時にサムネールを拡大 */
div.selected img.thumbnail-image { width: auto; max-width: 300px; }
@NeoCat
NeoCat / tweet-ingress-damage.rb
Last active August 29, 2015 14:05
Monitor your GMail mail box and tweet the damage report.
#!/usr/bin/ruby
require 'net/imap'
require 'nokogiri'
require 'twitter'
require 'cgi'
require 'open-uri'
mail_user = '***@gmail.com'
mail_password = '***'
mail_label = 'Ingress'