(1) ここからダウンロード。
http://www.raspberrypi.org/downloads
現在の最新は、2012-10-28-wheezy-raspbian.zip 。
(2) SDカードにコピー
今回はMac OS Xを利用。 http://www.mztn.org/rpi/rpi02.html
・SDカードをFATでフォーマット
・df -h でボリュームを確認
/dev/disk2s1 7.5Gi 988Ki 7.5Gi 1% 0 0 100% /Volumes/RASPBIAN
・SDカードをアンマウント
diskutil unmount /dev/disk2s1
・SDカードにコピー(rawでバイスである、/dev/rdisk2を利用)
sudo time dd bs=1m if=/Users/ora/Downloads/2012-10-28-wheezy-raspbian.img of=/dev/rdisk2
数十秒後、
Password:
1850+0 records in
1850+0 records out
1939865600 bytes transferred in 123.454810 secs (15713163 bytes/sec)
123.46 real 0.00 user 1.37 sys
・df -h でマウント状況を確認
/dev/disk2s1 56Mi 17Mi 39Mi 30% 512 0 100% /Volumes/Untitled
・アンマウント
diskutil unmount /dev/disk2s1
(3) Raspberry Piにさして起動
・設定画面でいろいろ設定。sudo raspi-config で、後でもできる。
・再起動
※デフォルトのユーザは、Username: pi Password: raspberry
※ root のパスワードはなし?
(4) アップデート
・sudo passwd root で、rootのパスワードを変更
・有線ネットワークを接続
・sudo dhclient -r で、dhcpアドレスを再取得
・sudo apt-get update
・sudo apt-get upgrade
・reboot でリブート
2012年11月1日木曜日
2012年10月12日金曜日
Windows, Ruby, Sinatra (3)
sinatra で MVC
sinatraとModel
Modelは好きなものを組み合わせる- ActiveRecord (railsとは独立して使える)
- Data Mapper (より抽象度が高い)
- Sequel (より抽象度が低くシンプル)
- sinatraのシンプルさと相性が良さそう
インストール
- gem install seque
ModelとRDB
Modelを格納するには、適切なRDBが必要- PostgreSQL
- MySQL
- SQLite3 → 今回は、シンプルなこれを使う
インストール
- ダウンロード、解凍
- http://www.sqlite.org/
- http://www.sqlite.org/sqlite-dll-win32-x86-3071401.zip
- dll, def → C:\Ruby193\bin に移動
rubyから使えるように
- gem install sqlite3
sinatraとView
Modelは好きなものを組み合わせる- Erb (rails とは独立して使える)
- Erubis (PHP, Java, JS, C, Perl, Schemaに対応)
- Builder (rubyのメソッドを使う)
- Haml (インデントでタグを表現。yaml的) → 今回はこれを使ってみる
インストール
- gem install haml
サンプル:gestbook.rb
require 'rubygems'require 'sinatra'
require 'sequel'
require 'haml'
Sequel::Model.plugin(:schema)
Sequel.connect('sqlite://guestbook.db')
class Comments < Sequel::Model
unless table_exists?
set_schema do
primary_key :id
string :name
string :comment
timestamp :created_at
end
create_table
end
end
get '/' do
@comments = Comments.order_by(:created_at.desc)
haml :index
end
post '/post_comment' do
Comments.create({
:name => request[:name],
:comment => request[:comment],
:created_at => Time.now,
})
redirect '/'
end
__END__
@@ index
%html
%title Guestbook
%body
%h2 Guestbook
%form{:name => 'post_comment', :action => '/post_comment', :method => 'post'}
%label{:for => 'name'} Name:
%input{:type => 'text', :name => 'name', :size => '20' }
%label{:for => 'comment'} Comment:
%input{:type => 'text', :name => 'comment', :size => '50'}
%input{:type => 'submit', :value => 'post' }
- @comments.each do |comment|
%div
%span&== [#{comment.name}]
%span&== (#{comment.created_at}):
%span&= comment.comment
Windows, Ruby, Sinatra (2)
RubyでWebアプリケーション : Web with Ruby
(1) CGI - IIS- 色々設定面倒
- httpd.confを修正
- 分かっていれば簡単。初めてだとちょっとはまる
- インストールは簡単。
- 機能豊富、仕掛けは大がかり、重たい。
sinatra on ruby
第4の選択肢: sinatra
シンプル、軽量なWebアプリケーションライブラリ- Rackという規格に従っている
- Model, Viewは好きなライブラリと組み合わせる
Installing sinatra
コマンドプロンプトから- set http_proxy=http://proxy:port ※proxy越えの場合
- gem install sinatra
最初のsinatra
hello.rb
require "rubygems"require "sinatra"
get '/' do
"Hello, sinatra world"
end
コマンドプロンプトから
- ruby hello.rb
- http://localhost:4567/
sinatraとパラメータ
hello.rb
require "rubygems"Require "sinatra"
get '/' do
“Hello, sinatra world”
end
get '/:name' do
"Hello, #{params[:name]}!"
end
コマンドプロンプトから
- ruby hello.rb
- http://localhost:4567/foo
sinatraとREST
REST APIと相性が良い
get '/target' do“取得の処理”
end
post '/target' do
“生成(登録)処理”
end
put '/target' do
“更新処理”
end
delete '/target' do
“削除処理”
end
Windows, Ruby, Sinatra (1)
Ruby on Windows
Rubyを使ってみよう
- その前にRubyをインストールしよう
- Linuxなら簡単: yum install ruby
- じゃあ、Windowsの場合は?
Windows 2000のころ
http://www.r-labs.org/projects/r-labs/wiki/WindowsにRuby_187をインストールするRubyのバイナリをダウンロード、解凍
ftp://ftp.ruby-lang.org/pub/ruby/binaries/mswin32/ruby-1.8.7-p330-i386-mswin32.zip
必要なライブラリ(DLL)群を自分でダウンロード、解凍
- gdbm.dll
- iconv.dll
- libeay32.dll
- libpq.dll
- pdcurses.dll
- readline.dll
- ssleay32.dll
- zlib.dll
ダウンロード後、 ruby setup.rb を実行
→ 結構面倒だった
Windows XP 以降
RubyInstaller で一発導入http://rubyinstaller.org
http://rubyforge.org/frs/download.php/76054/rubyinstaller-1.9.3-p194.exe
Ruby 1.9からは gem も内蔵
- gem: Ruby用のライブラリ管理ツール
- gem install ライブラリ名
※gemのproxy越え
set http_proxy=http://proxy:portgem install ライブラリ名
最初のruby
first.rb- puts “Hello, ruby world!”
- ruby first.rb
- Hello, ruby world!
2012年3月12日月曜日
2012年2月24日金曜日
3C and BASiCS

マーケティングの考え方に、BASiCSというものがあります。
これと3Cの考え方を、私の理解のもと一枚の図にしてみました。
はたして合っているでしょうか??
- Battle Field (戦場)
- Asset (独自資源)
- Strength (強み・差別化)
- Customer (顧客)
- Selling Message (売り文句)
これを3つの差別化軸に合わせて考え抜くのが重要と理解しています。
- Quality 商品軸
- Casual 手軽軸
- Custom 密着軸
2011年10月6日木曜日
登録:
投稿 (Atom)