Skip to content

Instantly share code, notes, and snippets.

View ma2shita's full-sized avatar

Kohei MATSUSHITA ma2shita

View GitHub Profile
@ma2shita
ma2shita / i18n_ja_jp_filter.diff
Created April 9, 2014 07:11
PHP 3.0.18-ja-3 patch for modern linux
--- i18n_ja_jp_filter.c.orig 2000-04-04 09:18:32.000000000 +0900
+++ i18n_ja_jp_filter.c 2014-04-08 18:07:28.723051000 +0900
@@ -97,5392 +97,7 @@
/* unicode support by */
#define UNDEFCHAR_JIS 0x2126
#define UNDEFCHAR_UNICODE 0x30FB
-extern const unsigned short u2jtable[];
-extern const unsigned short j2utable[];
-extern const int u2jtable_size;
-extern const int j2utable_size;
@ma2shita
ma2shita / sequel_db_reconnector.rb
Created December 5, 2014 01:09
Reconnect to DB module using Sequel
require "singleton"
require "sequel"
=begin
Overview:
Reconnect to DB module using Sequel
When `ping` success, `connection` return same connection.
In case of fail, reload `config/database.yml` and try new connect.
Require:
`../config/database.yml` (Deploy in `lib/` (or other dir) this file.)
@ma2shita
ma2shita / ti_sensortag_simplekey.js
Last active August 29, 2015 14:11
TI SensorTag (CC2541) SimpleKey(button) Service sample Program on node.js
/* $ npm install sensortag (require `libbluetooth-dev`) */
var SensorTag = require('sensortag');
var net = require('net');
var myUUID = process.env["TI_UUID"] || "YOUR_TI_sensor_tag_UUID";
console.log("start");
console.log("waiting for connect from " + myUUID);
SensorTag.discover(function(sensorTag) {
console.log(">> STOP: Ctrl+C or SensorTag power off");
@ma2shita
ma2shita / awsiot_commander.rb
Created May 7, 2016 14:38
Receive desire from AWS IoT and send command to real-device (Commander)
# Receive desire from AWS IoT and send command to real-device (Commander)
#
# POINT:
# * Listen on /update/delta
# <when Received a delta...>
# 1. Parse the delta
# 2. Execute command according to content
# 3. Erase on 'desired'
# => Should be removed "desired" ASAP after parsing delta
# Remains "desired" is cause of trouble (e.g. Out of sync)
@ma2shita
ma2shita / patlite.rb
Last active May 7, 2016 14:38
Patlite control ruby library
# Usage;
#
# Patlite.host = "192.168.254.209"
# red = Patlite.new(:red)
# p red.state?
# #=> :off / :on
# if red.off?
# red.on
# end
@ma2shita
ma2shita / awsiot_reporter.rb
Created May 7, 2016 14:39
Report device status to AWS IoT (Reporter)
# Report device status to AWS IoT (Reporter)
#
# POINT:
# 1. Delete exist shadow(status) for initialize [optional]
# 2. Fetch state of real-device
# 3. Formatting for submit to AWS IoT
# 4. Report to AWS IoT
# 2~4 <endless-loop>
require "timers" # NOTE: https://github.com/celluloid/timers
@ma2shita
ma2shita / patlite_example.rb
Created May 7, 2016 14:42
Example code using patlite.rb
require "./patlite"
Patlite.host = "192.168.254.209"
patlite = []
[:red, :yellow, :green].each do |i|
patlite << Patlite.new(i)
end
loop do
a = patlite.sample
@ma2shita
ma2shita / Grove_temp_humd_uv_LCD.ino
Last active June 21, 2017 00:48
Sensing temperature & humidity & UV using Grove and sending with LoRaWAN
/* ** Hardware setup **
* Arduino UNO R3 + LoRaWAN Shield + Grove Shield
* LCD => I2C
* Temp&Humd => I2C
* UV => A0
* Button => D2 (optional) => Not use LoRaWAN when pushed button in bootup (default is used LoRaWAN)
*/
/* ** Software setup **
* Grove Temper&Humd : https://github.com/Seeed-Studio/Grove_Temper_Humidity_TH02
* Grove LCD : https://github.com/Seeed-Studio/Grove_LCD_RGB_Backlight
@ma2shita
ma2shita / DS18B20_LoRaWAN.ino
Last active July 15, 2017 07:02
1-wire temperture "DS18B20" + LoRaWAN Shield
/* ** Hardware setup **
* Arduino UNO R3 + LoRaWAN Shield + DS18B20
*
* VCC(red) ------+---- 5V
* |
* DS18B20 10K Arduino
* |
* BUS(yellow) ---+---- 6
* GND(black) --------- GND
*/
@ma2shita
ma2shita / WioLTE_MFT2017.ino
Created August 4, 2017 01:20
Wio Tracker LTE and SORACOM Harvest w/ Grove touch sensor
/* LED status
* bootup = Purple
* connect sucessful = Green
* Sensor Open = White
* Sensor Close = Blue
*/
/*
* D38: "Grove Touch sensor" or "Magnetic door Switch w/ Grove connector made in max"
*/