Skip to content

Instantly share code, notes, and snippets.

//
// ordinal indicator sample
// see also... http://en.wikipedia.org/wiki/Ordinal_indicator#English
//
String getOrdinalIndicatorStr(int num) {
String result;
int d1 = num % 10;
int d2 = num % 100;

久しぶりにRubyを使って'I'のASCIIコードを調べるメモ

$ irb
irb(main):001:0> RUBY_VERSION
=> "1.9.3"

irb(main):002:0> "I"[0]
=> "I" ← あれ?1.8の時はこれで文字コード取得できなかったっけ?
@yoggy
yoggy / weather_json_sample.pde
Created August 15, 2014 08:16
天気予報を表示するスケッチ例
//
// weather_json_sample.pde - 天気予報を表示するスケッチ例
//
// 天気予報JSONデータについては下記参照
// http://weather.livedoor.com/weather_hacks/webservice
//
String url = "http://weather.livedoor.com/forecast/webservice/json/v1?city=130010";
JSONObject json;
Serial.println(buf);
//
// dht11_dht22_cds_pir_test.ino - a sample sketch that outputs the sensor data in JSON..
//
// This program uses the following libraries.//
// https://github.com/adafruit/DHT-sensor-library
//
#include "DHT.h"
#define CDS_PIN 0
//
// dht11_dht22_cds_test.ino - a sample sketch that outputs the sensor data in JSON..
//
// This program uses the following libraries.//
// https://github.com/adafruit/DHT-sensor-library
//
#include "DHT.h"
DHT dht11(2, DHT11);
DHT dht22(3, DHT22);
#!/usr/bin/ruby
# -*- encoding: utf-8 -*-
#
# mqtt_sensor_pub.rb - Sample script to publish the sensor data using the MQTT
#
# $ sudo gem install serialport
# $ sudo gem install mqtt
#
require 'rubygems'
require 'serialport'
@yoggy
yoggy / sensor_gruff.rb
Last active August 29, 2015 14:02
InfluxDBから温度・湿度を取得してグラフ画像を生成&画像をGyazoにアップするサンプル
#!/usr/bin/ruby
# -*- encoding: utf-8 -*-
#
# sensor_gruff.rb - create line charts & upload images to gyazo
#
# $ sudo apt-get install rmagic libmagickcore-dev libmagickwand-dev
# $ sudo gem install gruff
# $ gem install gyazo
#
require 'rubygems'
@yoggy
yoggy / sensor_bot.coffee
Created June 10, 2014 07:52
Hubotのスクリプトを作ってみたテスト
spawn = require('child_process').spawn
module.exports = (robot) ->
robot.respond /nike$/i, (msg) ->
msg.send 'https://farm8.staticflickr.com/7118/7446163748_fd8ace754f_m.jpg'
robot.respond /sensor$/i, (msg) ->
output = ''
ls = spawn('./sensor.rb')
ls.stdout.on 'data', (data) ->
import fisica.*;
FWorld world;
void setup() {
size(400, 400);
smooth();
Fisica.init(this);
//
// mqtt_pub_dht11.ino - mqtt publish sample for Arduino Ethernet
//
// This program uses the following libraries.
// https://github.com/knolleary/pubsubclient
// https://github.com/virtuabotix/DHT11LIB
//
#include <SPI.h>
#include <Ethernet.h>
#include <PubSubClient.h>