fa, Fa, ta, Ta: find next a in the line
d3w, d3aw: delete 3 words
df>, dF>: delete words to > mark
. : repeat previous command
mx->d`x: delete words from 'x' mark
mx->y`x: yank words from 'x' mark
!10Gsort: sort 10 lines
!!ls: insert ls output to current line
>>, <<: shift
=%: indent inner of {}
%: move between parentheses
>%, >i{: indent inner block
v->i{>: indent inner block at visual mode
abbreviate
map i{ea} word wrap with {}
fx ; ,: repeat forward or backword find x
s, S: xi, ddi
~: upper lower convert
*, #: word search forward or backword
regex: /\/ : find only 'for' word not include 'forword', 'information'
: \t \= : +, ?
: \a \d : a word a number
Saturday, September 04, 2010
iPhone Development
- iPhone用の画面設計
- jQTouchの利用
- クライアントサイド・ストレージの使用
- オフラインキャッシュの使用
- ネイティブ化
1.iPhone用の画面設計
- meta veiwport width=device-width, calabe=no
- link stylesheet media=screen
- meta apple-mobile-web-app-capable
- touchstart: document.addEventListener("touchstart", click, false)
- touchmove: document.addEventListener("touchmove", move, false) def move...
- イベントターゲットの調整
3.クライアントサイド・ストレージの使用
- localStrage
- SessionStrage
- DataBase
5.ネイティブ化
- PhoneGap
- Rhodes
vim commands
:registers show register text
"ayy : copy to 'a' register
i<C-r>a : yank from 'a' register
<C-w>r, x : rotate or switch windows
:wall, :qall, :wqall : write all opened files
v-mode:
$, aw, o : select to end, word, top-bottom toggle
gv : repeat last vmode ope
~, v, V : convert word
:set scrollbind, :syncbind
"ayy : copy to 'a' register
i<C-r>a : yank from 'a' register
<C-w>r, x : rotate or switch windows
:wall, :qall, :wqall : write all opened files
v-mode:
$, aw, o : select to end, word, top-bottom toggle
gv : repeat last vmode ope
~, v, V : convert word
:set scrollbind, :syncbind
Friday, September 03, 2010
Macbook Pro + iPod Touch
Macbook Pro + iPod Touch
(追記)英語キーボードヴァージョンはAppleでしか買えないことが、ヨドバシにて判明。
- アマゾンは5%OFF
- アマゾンで他業者のが更に500円安い
- 最安値は価格.comでアマゾンより1万円更に安い。でもちょっと不安
- ヨドバシ他は値引きナシポイント8%(現金)とか
(追記)英語キーボードヴァージョンはAppleでしか買えないことが、ヨドバシにて判明。
Thursday, September 02, 2010
iPhone開発まとめ
現在わかっていること
- 開発の方法として2種類ある
- 1つは、スタンダードな方法で、xcode上でObjective-Cを使ってコーディングし、コンパイル
- もう1つは、HTML+CSS+Javascriptを使ってコーディングし、PhoneGapでxcode上のコードに変換する
- HTML..を使う場合、jQTouchは必須。アニメーションはiProcessing.jsがある。
- HTML..を使う場合、AppStoreを通さないWebアプリであればPhoneGapは不要
- PhoneGapとiphone対応のxcodeはLeopard上でなければ動作しない
- AppStoreを通す場合は$99/年が必要
- 結局、AppStoreを通すiPhone開発にはLeopardは必須
iprocessingが動かない?
ipodでprocessingを動かすためにprocessing.jsを改良したiprocessing.jsというのがあって
これをためしてるんだけれども、うまくいかない。
現時点ではわからない
Michael Schieben // rockitbaby.de http://www.rockitbaby.de/experiments/processingjs-on-iphone#
これをためしてるんだけれども、うまくいかない。
- ipod独自のファンクションであるtouchmoveとかが普通のmousemoveになっていて効かない
- animationはちょっと重くて使えない
- 現在はhtml+javascriptをそのまま動かしている
- xcodeでobjective-cにコンパイルしてインストールすることができるけれどもTigerじゃできない
現時点ではわからない
Michael Schieben // rockitbaby.de http://www.rockitbaby.de/experiments/processingjs-on-iphone#
Wednesday, September 01, 2010
processing on iphone with sinatra
app.rb
index.haml
myjs.js
default.pjs
require "sinatra"
require "haml"
require "sass"
get '/' do
haml :index
end
get '/style.css' do
content_type 'text/css', :charset => 'utf-8'
sass :style
end
index.haml
!!!
%html
%head
%meta{:'http-equiv' => 'Content-type', :content => 'text/html', :charset => 'utf-8'}
%meta{:name => "viewport", :content => "user-scalable=no, width=device-width, minimum-scale=1.0, maximum-scale=1.0"} //iphoneで画面の幅を合わせる
%meta{:name => "apple-mobile-web-app-capable", :content => "yes"} //iphoneでフルスクリーンモードに
%meta{:name => "apple-mobile-web-app-status-bar-style", :content => "black"} //iphoneでステータスバーを黒に
%title Processing
%link{:rel => 'stylesheet', :href => '/style.css', :type => 'text/css', :media => "only screen and (max-width: 480px)"} //iphone用のCSS
%link{:rel => 'stylesheet', :href => '/style.css', :type => 'text/css', :media => "only screen and (min-width: 481px)"} //desktop用のCSS
%script{:type => 'text/javascript', :src => '/javascripts/jquery.js'}
%script{:type => 'text/javascript', :src => '/javascripts/processing.js'}
%script{:type => 'text/javascript', :src => '/javascripts/myjs.js'}
%body
%canvas.processing //processingの描画エリアの確保
myjs.js
$(document).ready(function(){
function move (e) {
e.preventDefault();
return false;
}
function click (e) {
alert(e);
return false;
}
//processingで外部ファイルの読み込み
var processing_init = function(obj, url) {
obj.each( function(){
var canvas = $(this)[0];
var p = Processing( canvas );
var code = $(this).text() || p.ajax( url );
Processing( canvas, code );
});
};
processing_init( $('.processing'), 'javascripts/head-animation.pjs' );
//document.addEventListener("touchstart", click, false);
//document.addEventListener("touchmove", move, false);
$(document).bind('touchmove', move);//iphoneで画面スクロールを禁止
$(document).bind('touchstart', click); //iphoneのtouchstartイベント
});
default.pjs
/*
PROCESSINGJS.COM - BASIC EXAMPLE
Delayed Mouse Tracking
MIT License - Hyper-Metrix.com/F1LT3R
Native Processing compatible
*/
// Global variables
float radius = 50.0;
int X, Y;
int nX, nY;
int delay = 16;
// Setup the Processing Canvas
void setup(){
size( 180, 100 );
strokeWeight( 10 );
frameRate( 15 );
X = width / 2;
Y = height / 2;
nX = X;
nY = Y;
}
// Main draw loop
void draw(){
radius = radius + sin( frameCount / 4 );
// Track circle to new destination
X+=(nX-X)/delay;
Y+=(nY-Y)/delay;
// Fill canvas grey
background( 100 );
// Set fill-color to blue
fill( 0, 121, 184 );
// Set stroke-color white
stroke(255);
// Draw circle
ellipse( X, Y, radius, radius );
}
// Set circle's next destination
void mouseMoved(){
nX = mouseX-200;
nY = mouseY-200;
}
Thursday, August 26, 2010
some vim command
fa, Fa, ta, Ta: find next a in the line
d3w, d3aw: delete 3 words
df>, dF>: delete words to > mark
. : repeat previous command
mx->d`x: delete words from 'x' mark
mx->y`x: yank words from 'x' mark
!10Gsort: sort 10 lines
!!ls: insert ls output to current line
>>, <<: shift
=%: indent inner of {}
%: move between parentheses
>%, >i{: indent inner block
v->i{>: indent inner block at visual mode
abbreviate
map i{ea} word wrap with {}
fx ; ,: repeat forward or backword find x
s, S: xi, ddi
~: upper lower convert
*, #: word search forward or backword
regex: /\/ : find only 'for' word not include 'forword', 'information'
: \t \= : +, ?
: \a \d : a word a number
d3w, d3aw: delete 3 words
df>, dF>: delete words to > mark
. : repeat previous command
mx->d`x: delete words from 'x' mark
mx->y`x: yank words from 'x' mark
!10Gsort: sort 10 lines
!!ls: insert ls output to current line
>>, <<: shift
=%: indent inner of {}
%: move between parentheses
>%, >i{: indent inner block
v->i{>: indent inner block at visual mode
abbreviate
map
fx ; ,: repeat forward or backword find x
s, S: xi, ddi
~: upper lower convert
*, #: word search forward or backword
regex: /\
: \t \= : +, ?
: \a \d : a word a number
Wednesday, August 18, 2010
Tuesday, August 17, 2010
pony_gmail
require 'pony'
require "openssl"
require "net/smtp"
Net::SMTP.class_eval do
private
def do_start(helodomain, user, secret, authtype)
raise IOError, 'SMTP session already started' if @started
check_auth_args user, secret, authtype if user or secret
sock = timeout(@open_timeout) { TCPSocket.open(@address, @port) }
@socket = Net::InternetMessageIO.new(sock)
@socket.read_timeout = 60 #@read_timeout
check_response(critical { recv_response() })
do_helo(helodomain)
if starttls
raise 'openssl library not installed' unless defined?(OpenSSL)
ssl = OpenSSL::SSL::SSLSocket.new(sock)
ssl.sync_close = true
ssl.connect
@socket = Net::InternetMessageIO.new(ssl)
@socket.read_timeout = 60 #@read_timeout
do_helo(helodomain)
end
authenticate user, secret, authtype if user
@started = true
ensure
unless @started
# authentication failed, cancel connection.
@socket.close if not @started and @socket and not @socket.closed?
@socket = nil
end
end
def do_helo(helodomain)
begin
if @esmtp
ehlo helodomain
else
helo helodomain
end
rescue Net::ProtocolError
if @esmtp
@esmtp = false
@error_occured = false
retry
end
raise
end
end
def starttls
getok('STARTTLS') rescue return false
return true
end
def quit
begin
getok('QUIT')
rescue EOFError
end
end
end
TellMeWhen(仮題)というメモ&タスク管理的なWebツールを起案
TellMeWhen(仮題)というメモ&タスク管理的なWebツールを起案・試作したんだけど
リマインド通知をGmailでしようと実装を検討していたところ
「それじゃ不便・うざいよ」とさち
まあたしかにね
で行き詰まったので
試しにRememberTheMilkという有名なタスク管理サービスがあるのでちょっと使ってみたところ
通知のタイミングを細かくしていできるのと
Adiumで通知できたりして
「これでたりなくね?」的な感じになってます
別のこと考えるか
リマインド通知をGmailでしようと実装を検討していたところ
「それじゃ不便・うざいよ」とさち
まあたしかにね
で行き詰まったので
試しにRememberTheMilkという有名なタスク管理サービスがあるのでちょっと使ってみたところ
通知のタイミングを細かくしていできるのと
Adiumで通知できたりして
「これでたりなくね?」的な感じになってます
別のこと考えるか
ruby: pony
簡単にメールを送信するためのponyというtmailのラッパーライブラリを発見
ただgmailのSMTPを使う場合はNet::smtpに修正がいるようで
それをした人のpony_gmail.rbを使う必要がある。
ただgmailのSMTPを使う場合はNet::smtpに修正がいるようで
それをした人のpony_gmail.rbを使う必要がある。
Saturday, August 14, 2010
clean
ブログでエアコンを掃除した人がいたので
すぐやる課発動で本日朝7時より大掃除をした
2台のエアコン、除湿器、洗濯機回り、洗面棚回り、玄関
エアコンの吹き出し口は黒カビと埃で真っ黒けの状態だった
これじゃ具合も悪くなる
完全にカビを取ることはできなかったけど7割くらいはいったか
これで鼻詰まりも治るかな
二人とも全力投球で現在ぐったり
でもクリーンになって気持ちはすっきり
あとは映画でも見て今日はまったり
だな
すぐやる課発動で本日朝7時より大掃除をした
2台のエアコン、除湿器、洗濯機回り、洗面棚回り、玄関
エアコンの吹き出し口は黒カビと埃で真っ黒けの状態だった
これじゃ具合も悪くなる
完全にカビを取ることはできなかったけど7割くらいはいったか
これで鼻詰まりも治るかな
二人とも全力投球で現在ぐったり
でもクリーンになって気持ちはすっきり
あとは映画でも見て今日はまったり
だな
Tuesday, August 10, 2010
Sunday, August 08, 2010
Tuesday, July 27, 2010
Posterous
Posterousというブログサービスを試してみる
投稿はメールですることが基本になっていて
最初の投稿はアカウントを取る前にできてしまう
ソーシャル的な要素が強くて
ブログとTwitterを合わせたような感じ
他者のブログをfollower登録みたいにそこで購読できる
投稿はメールですることが基本になっていて
最初の投稿はアカウントを取る前にできてしまう
ソーシャル的な要素が強くて
ブログとTwitterを合わせたような感じ
他者のブログをfollower登録みたいにそこで購読できる
Friday, July 23, 2010
conv.rb
to_s(base), to_i(base)を94まで対応
#!/usr/local/bin/ruby
# -*- encoding:utf-8 -*-
module Conv
TABLE = ('!'..'~').to_a
def to_s_conv(base, rs=[])
q, r = self.divmod base
rs.unshift TABLE[r]
q.to_s_conv(base, rs) if q > 0
rs.join
end
def to_i_conv(base)
self.split(//).reverse.map.with_index { |s, i| TABLE.index(s).to_i * base**i }.inject(:+)
end
end
class Fixnum
include Conv
alias to_s_orig to_s
def to_s(base=10)
base > 36 ? to_s_conv(base) : to_s_orig(base)
end
end
class Bignum
include Conv
alias to_s_orig to_s
def to_s(base=10)
base > 36 ? to_s_conv(base) : to_s_orig(base)
end
end
class String
include Conv
alias to_i_orig to_i
def to_i(base=10)
base > 36 ? to_i_conv(base) : to_i_orig(base)
end
end
x = 200_000_000_000
(2..94).each do |i|
s = x.to_s(i)
print "#{i} => #{s}:#{s.to_i(i)}\n"
end
Thursday, July 22, 2010
TinyURL with Ruby
Points
- urlをDBのidに置き換え、さらにInteger#to_i(36)を使って短縮する
- cssをw3cサイトから借用
- 環境変数envから参照元つまり自サイトのurlを取得
%w(rubygems sinatra dm-core dm-timestamps dm-migrations uri).each { |lib| require lib }
configure :development do
DataMapper.setup(:default, "sqlite3://#{Dir.pwd}/chop.db")
end
get '/' do
haml :index
end
post '/' do
uri = URI::parse(params[:original])
raise "Invalid URL" unless [URI::HTTP, URI::HTTPS].any? { |scm| uri.kind_of? scm }
@url = Url.first_or_create(:original => uri.to_s)
haml :index
end
get '/:chopped' do |chopped|
redirect Url.first(:id => chopped.to_i(36)).original
end
error do
'Sorry there was a nasty error - ' + env['sinatra.error'].name
end
class Url
include DataMapper::Resource
property :id, Serial
property :original, String, :length => 255
property :created_at, DateTime
def chopped
self.id.to_s(36)
end
end
__END__
@@ layout
!!! 1.1
%html
%head
%title Chop!
%link{:rel => 'stylesheet', :href => 'http://www.w3.org/StyleSheets/Core/Modernist', :type => 'text/css'}
%body
= yield
@@ index
%h1.title Chop!
- unless @url.nil?
%code= @url.original
chopped to
%a{:href => env['HTTP_REFERER'] + @url.chopped}
= env['HTTP_REFERER'] + @url.chopped
%form{:method => 'post', :action => '/'}
Chop this:
%input{:type => 'text', :name => 'original', :size => '50'}
%input{:type => 'submit', :value => 'chop!'}
%small copyright ©
Friday, July 09, 2010
Subscribe to:
Posts (Atom)