Skip to content

Instantly share code, notes, and snippets.

Avatar

Kohei MATSUSHITA ma2shita

View GitHub Profile
@ma2shita
ma2shita / i18n_ja_jp_filter.diff
Created Apr 9, 2014
PHP 3.0.18-ja-3 patch for modern linux
View i18n_ja_jp_filter.diff
--- 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 Dec 5, 2014
Reconnect to DB module using Sequel
View sequel_db_reconnector.rb
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 Aug 29, 2015
TI SensorTag (CC2541) SimpleKey(button) Service sample Program on node.js
View ti_sensortag_simplekey.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
Receive desire from AWS IoT and send command to real-device (Commander)
View awsiot_commander.rb
# 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
Patlite control ruby library
View patlite.rb
# 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
Report device status to AWS IoT (Reporter)
View awsiot_reporter.rb
# 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
Example code using patlite.rb
View patlite_example.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 Jun 21, 2017
Sensing temperature & humidity & UV using Grove and sending with LoRaWAN
View Grove_temp_humd_uv_LCD.ino
/* ** 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 Jul 15, 2017
1-wire temperture "DS18B20" + LoRaWAN Shield
View DS18B20_LoRaWAN.ino
/* ** 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 Aug 4, 2017
Wio Tracker LTE and SORACOM Harvest w/ Grove touch sensor
View WioLTE_MFT2017.ino
/* 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"
*/