Skip to content

Instantly share code, notes, and snippets.

View yuiseki's full-sized avatar
🍻
I want to drink

yuiseki yuiseki

🍻
I want to drink
View GitHub Profile
@yuiseki
yuiseki / gist:45416
Created January 10, 2009 08:37 — forked from nagayama/gist:2108
(^o^)/owata
@yuiseki
yuiseki / gist:114866
Created May 20, 2009 15:17
rubyでArduinoのシリアルポートを叩く
require 'rubygems'
require 'serialport'
sp = SerialPort.new("COM6", 9600, 8, 1, SerialPort::NONE)
command = ["0D"]
sp.write(command.pack("H*"))
sp.read
sp.read
loop {
@yuiseki
yuiseki / gist:114868
Created May 20, 2009 15:18
Arduinoをシリアルデバイスにする。Analog0に光センサーを接続
int analogValue = 0;
void setup() {
Serial.begin(9600);
}
void loop() {
analogValue = analogRead(0)/4;
Serial.println(analogValue, DEC);
delay(100);
}
#define R 5
#define G 6
#define B 7
#define S 2
#define WAIT 500
int inByte = 0;
int inSwitch;
bool r, g, b, blink, off;
require "rubygems"
gem "activeresource"
require "active_resource"
require "serialport"
class State < ActiveResource::Base
self.site = 'http://cyberia.yuiseki.net/'
end
#5秒おきにRailsに問い合わせて出力する
   _,,....,,_  _人人人人人人人人人人人人人人人_
-''":::::::::::::`''>  ゆっくりした結果がこれかよ!!! <
ヽ::::::::::::::::::::: ̄^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^ ̄
 |::::::;ノ´ ̄\:::::::::::\_,. -‐ァ     __   _____   ______
 |::::ノ   ヽ、ヽr-r'"´  (.__    ,´ _,, '-´ ̄ ̄`-ゝ 、_ イ、
_,.!イ_  _,.ヘーァ'二ハ二ヽ、へ,_7   'r ´          ヽ、ン、
::::::rー''7コ-‐'"´    ;  ', `ヽ/`7 ,'==─-      -─==', i
r-'ァ'"´/  /! ハ  ハ  !  iヾ_ノ i イ iゝ、イ人レ/_ルヽイ i |
!イ´ ,' | /__,.!/ V 、!__ハ  ,' ,ゝ レリイi (ヒ_]     ヒ_ン ).| .|、i .||
`!  !/レi' (ヒ_]     ヒ_ン レ'i ノ   !Y!""  ,___,   "" 「 !ノ i |
@yuiseki
yuiseki / school.rb
Created November 26, 2009 19:12 — forked from oquno/school.rb
#!/usr/local/bin/ruby -Ks
# _*_ coding: utf-8 _*_
require 'rubygems'
require 'mechanize'
require 'time'
MAIL = 'mixi_login_mail_address'
PASS = 'mixi_login_pass'
DIRECTORY = 'log_directory_path'
require 'rubygems'
require 'sinatra'
require 'tokyotyrant'
include TokyoTyrant
helpers do
def get_recents()
rdb = RDBTBL::new
rdb.open('localhost', 1978)
qry = RDBQRY::new(rdb)
1.text 型で :data というカラムを持った Async というモデルを作る。
2.アプリケーションから非同期になにかやりたい時は {:method => 処理の名称, :args => 引数} みたいな感じのハッシュを JSON 化して Async のインスタンスを create する
3.Async の中身を見て、何かあったら :method の処理に :args の引数を渡して走らせ、終ったら対象を destroy するというメソッドをどっかに作って cron で ./script/runner 経由で回す
# とりあえずsocial streamの埋め込みページからスクレイピングで検索条件を特定する
from BeautifulSoup import BeautifulSoup
stream = "http://www.ustream.tv/socialstream/%s" % channel_id
html = urllib.urlopen(stream)
soup = BeautifulSoup(html.read())
scripts = soup.findAll('script')
# scriptタグのUstream.Vars.messageSuffix=" (#akibaust live at http:\/\/ustre.am\/kpMv )"というあたりの文字列
suffix = scripts[2].string.split(';')[8]
# #akibaust というあたりの文字列