Skip to content

Instantly share code, notes, and snippets.

@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
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
double a, b, c;
void test(int sig)
{
printf("%f\n", a * b + c);
}
@NeoCat
NeoCat / gist:1e8188c0d107b7af7ee69d96f19388c2
Created April 7, 2018 15:13
Bluetooth connection to USB Voltage/Current Monitor UM24C using Linux
$ bluetoothctl
[bluetooth]# scan on
Discovery started
[NEW] Device 00:BA:55:XX:XX;XX UM24C
[CHG] Device 00:BA:55:XX:XX;XX RSSI: -63
[bluetooth]# pair 00:BA:55:XX:XX;XX
Attempting to pair with 00:BA:55:XX:XX;XX
[CHG] Device 00:BA:55:XX:XX;XX Connected: yes
@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 / 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 / 16x32display.ino
Created October 15, 2017 15:30
16x32 RGB LED Matrix counter+cpu% display
#include <Adafruit_GFX.h> // Core graphics library
#include <RGBmatrixPanel.h> // Hardware-specific library
#include <Fonts/Arial4pt7b.h>
#include <Fonts/Arial7pt7b.h>
#define CLK 8 // MUST be on PORTB! (Use pin 11 on Mega)
#define LAT A3
#define OE 9
#define A A0
#define B A1
@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 / 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 / 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 / virt-addr
Last active November 23, 2016 19:36
#!/bin/bash
type=ipv4
function usage() {
echo "usage: $(basename "$0") [OPTIONS] domain"
echo " -6 get ipv6 address (default: ipv4)"
echo " -h show this help"
echo " -n show interface name"
echo " -p show prefix"
echo " -i interface specify interface (default: all)"