Skip to content

Instantly share code, notes, and snippets.

@koki-h
koki-h / yaml_format.rb
Created February 25, 2009 13:19
YAMLファイルを読み込んでERBで整形するだけ
#!/usr/bin/ruby
#YAMLファイルを読み込んでERBで整形するだけ
#YAMLファイルとテンプレートファイルを引数にとり、整形したのを標準出力に書き出す
require 'yaml'
require 'erb'
require 'kconv'
yaml = ""
#一個目のファイルはYAMLデータとみなす
@koki-h
koki-h / uxu_vimp.js
Created March 5, 2009 05:21
UxUのダイアログを:dia[log]コマンドで開けるようにします。
/**
* ==VimperatorPlugin==
* @name uxu_vimp
* @description Be able to open UxU interface from :dia[log].
* @description-ja UxUのダイアログを:dia[log]コマンドで開けるようにします。
* @author koki-h
* @version 0.1
* ==/VimperatorPlugin==
*/
//This script is based on http://vimperator.g.hatena.ne.jp/hogelog/20081213/1229199895
#!/bin/sh
#
# 引数に指定されたディレクトリとカレントディレクトリのファイルからタグファイルを生成する
#
remort_src=$1
find ../$remort_src/ | ctags -L -
ctags -a -R
@koki-h
koki-h / wave_profile.rb
Created April 30, 2009 16:01
WAVEファイルを解析する
#WAVEファイルを解析する
#dumpした結果を折れ線グラフなどにすれば波形を見ることが出来る
require 'pp'
include Math
class String
def to_long
self.unpack("L*")[0]
end
#Slideshareの埋め込みコードをはてなに埋め込みやすいように変更する
#変更されたコードは自動的にクリップボードに入る
#コマンドプロンプトから実行してみたがうまく動かない。"<"などが邪魔をする?
#エラーメッセージ↓
# C:\Users\koki\Documents\scripts>ruby slideshare.rb 'aaaaa'
# c:/ruby-1.8/lib/ruby/gems/1.8/gems/win32-clipboard-0.5.1/lib/win32/clipboard.rb:
# 71:in `<<': can't modify frozen string (TypeError)
# from c:/ruby-1.8/lib/ruby/gems/1.8/gems/win32-clipboard-0.5.1/lib/win32/
# clipboard.rb:71:in `set_data'
# from slideshare.rb:20
// ==UserScript==
// @name twitter_page
// @namespace koki-h
// @description http://twitter.com/ にアクセスしたときにlocationに自動で"?page=1"を付加する。
// @include http://twitter.com/
// ==/UserScript==
//
//vimperatorを使っていれば"Ctrl+a"で次のページ、"Ctrl+x"で前のページに移動できる
document.location += "?page=1"
#Twitterの過去ログを取ってきてタブ区切りで1ページずつ書き出す
require 'rubygems'
require 'nokogiri'
require 'open-uri'
require 'date'
MIN_PAGE = ARGV[0]
MAX_PAGE = ARGV[1]
#MAX_PAGE = 2
# Get a Nokogiri::HTML:Document for the page we’re interested in...
MIN_PAGE.upto MAX_PAGE do |i|
//9個のLEDを1個づつ光らせていく
//http://www.youtube.com/watch?v=7TdfvWGedBA
#define LED_PIN_MIN 2
#define LED_PIN_MAX 10
void setup() // run once, when the sketch starts
{
for (int i = LED_PIN_MIN; i <= LED_PIN_MAX; i++){
pinMode(i, OUTPUT); // sets the digital pin as output
}
//点滅速度を早くし、往復するようにした(ナイトライダー)
#define LED_PIN_MIN 2
#define LED_PIN_MAX 10
void setup() // run once, when the sketch starts
{
for (int i = LED_PIN_MIN; i <= LED_PIN_MAX; i++){
pinMode(i, OUTPUT); // sets the digital pin as output
}
}
//にせもののanalogWriteを作ろうと思ったけど失敗。
//ちゃんとanalogWriteするためには各ピンに連続的にON/OFFを送り続けないとダメ
#define LED_PIN_MIN 2
#define LED_PIN_MAX 10
#define MICROSECONDS_PER_BLINK 2040 //PWMの周波数約490Hzより
#define NUMBER_OF_LEVEL 4 //PWMの段階
#define UNIT_OF_LEVEL MICROSECONDS_PER_BLINK / NUMBER_OF_LEVEL
void setup() // run once, when the sketch starts
{