• 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
 
 

自分用メモ。
screenでは複数windowを開いていますが、最近なんとなく開く数が決まってきたので、最初から開いておくようにしました。瀧内さんは以前8つ開いてるって言ってたので(!)、私の6つなんか かわいいものなハズ。

windowの役割

現在のメインプロジェクトはブログなので、それをベースに以下の5つを開いています。

  • 0 emacs, エディタ
  • 1 shell
  • 2 tail -f log/development.log
  • 3 script/console
  • 4 同時進行のプロジェクト: folked prawn.git
  • 5 railsのdir ソースを読むのに使う

2008.10.03の.screenrc

他の人よりはショボショボなのですが、ご愛敬ということで。 emacsclientを使っているので、emacsはフルパスで書いています。

   1  escape ^tt
   2  
   3  hardstatus alwayslastline "[%02c] %`%-w%{=b bw}%n %t%{-}%+w"
   4  scrollback 4000
   5  vbell off
   6  #idle 1200
   7  #blankerprg /usr/local/bin/tss
   8  
   9  chdir "/home/hibi/blog.git" #メインのprojectに移動
  10  
  11  #screen -t emacs 0 /usr/bin/emacs #emacs 21.4
  12  screen -t emacs 0 /usr/local/bin/emacs
  13  screen -t bash 1
  14  stuff "ruby ./script/server -d" #開いたwindowにこのコマンドだけ入力しとく、実行してもいいのですが実行したくない時も多いので
  15  
  16  screen -t tail 2 tail -f log/development.log
  17  
  18  screen -t console 3 ruby ./script/console
  19  
  20  chdir "/home/hibi/my.prawn.git"
  21  screen -t prawn 4 #前の行でcdしてからwindowを開く
  22  
  23  chdir "/home/hibi/test/vendor/rails/actionpack/lib/action_controller"
  24  screen -t rails 5
  25  
  26  chdir "/home/hibi/blog.git" #以後開くすべてのwindowをblog.gitにするため
  27  select 1 #window1を選択

Refs

http://www.limy.org/program/screen_command.html:日本語リファレンス
http://www.pervasivecode.com/blog/2007/06/12/gnu-screen-and-my-screenrc/
http://technique.sonots.com/?UNIX/設定、設定ファイル/.screenrc

posted by Png satoko on Fri 3 Oct 2008 at 15:48

できた(というか切り出してきた)gemspec
http://github.com/satoko/prawn/tree/master/prawn.gemspec

forkしているprawnにはprawn.gemspecファイルがありません。
で、自分で適当にでっち上げようとしたのですが、どうやらgemspec(spec.files)の内容が正しくない様子で、動作するgemが作れません。いちいち使用するすべてのファイルを上げなければいけないのだけれど、どうしたら簡単にできるものか...と思ったら、project内のRakefileにgemspecがあった!というので、それを切りだしました。
そこに至るまでのポイントぽいものを挙げます。

gemspecで重要な属性

Important Attributes
name .. version .. platform .. summary .. require_paths .. files .. dependencies
http://docs.rubygems.org/read/chapter/20

spec.fileの便利な書き方:Dir.blog

(注意)githubの場合Dir.globはgem生成時にエラーになるようで(エラー通知メールが来てた)、irbでDir.blogして展開したものをgemspecにコピペするのが正解のようです。

   1  irb(main):001:0> Dir.glob("{examples,lib,spec,vendor,data}/**/**/*")

結果をspec.filesにコピペ。

   1  Gem::Specification.new do |spec|
   2    spec.name = "prawn"
   3    spec.files = ["copy & past the result of Dir.blog"]  +
   4                        ["Rakefile"]

gemspecでローカルで正しいgemが作れるかテストする

下記のコマンドで生成されたgemをインストールし、展開後のdirを見たりテストを実行したりして正しくgemが作られているかテストします。

   1  $ gem build prawn.gemspec

githubでgems.githum.comの一覧に入れてもらう手順

  1. prawn.gemspecというファイルを用意する
  2. コミット
       1  git push prawn.gemspec -m "add gemspec file"
    
  3. https://github.com/satoko/prawn/editRubyGemにチェックする
  4. gem searchで所望のgemが出てくるのを待つ(max 15分くらい?)
       1  $ gem search satoko-prawn -r
       2  *** REMOTE GEMS ***
       3  satoko-prawn (0.2.99.2)
    

(注意)一覧とはここです。

Refs

http://d.hatena.ne.jp/akm/20080621#1214036969
http://docs.rubygems.org/read/chapter/20
http://code.google.com/p/rubeus/source/browse/trunk/rubeus.gemspec#

posted by Png satoko on Thu 2 Oct 2008 at 10:09 with 1 comment
posted by Png satoko on Thu 25 Sep 2008 at 15:06

http://norainu.net/mt/archives/2006/08/emacsclient.html

emacsclient。twitterかなんかで見てつかおうとしたのだけれど、そもそもemacs22じゃないと動かない?ようなのでemacsをソースからインストールするところに戻って開始するというyak shaving

その道のりを思い出して書いておく自分用メモ。
(なので正確ではないです)

lennyのemacs22パッケージをインストールしようとして挫折

emacs22パッケージはlennyにあるというのがわかったので、瀧内さんの記事(補助的にunstableパッケージを使えるようにする )を参考に/etc/apt/sources.listにlennyを追加。

インストール開始。だけれども、kernel-headers libc?を更新しないといけないなどとメッセージでてきたので頓挫。他のパッケージが動作しなくなる可能性が高いのでNG。

emacs22ソースからインストール

http://packages.debian.org/ja/lenny/emacs22
http://ftp.de.debian.org/debian/pool/main/e/emacs22/emacs22_22.2+2.orig.tar.gz
ソースをダウンロードして解凍。./configureする。

でもうまくいかないので、下記の順番にしてみる。

   1  cd /usr/local/src/emacs-22.2
   2  automake #=> Makefile.inを作る
   3  autoconf #=> configureを作る
   4  ./configue

でもまだうまくいかない。エラーを見返しlispintroが足りないといっているので

   1  cp lisp lispintro
   2  ./configure
lisprefも上と同様の作業をしてなんとかconfigureを終わらせる。
でmakeすると、make bootstrapしろと言ってくるのでそうする。
   1  make bootstrap #時間がかかる
   2  make
   3  sudo make install

でインストール完了!ちゃんと起動もできました。M-x emacs-versionで22.2.2であることを確認。

emacsclient

でemacsclientの作業。.screenrcにあるパスを下記のように書き換えて完了。

   1  #.screenrc
   2  screen -t emacs 0 /usr/local/bin/emacs

posted by Png satoko on Thu 25 Sep 2008 at 07:03
12th Fri

Ubiquityメモ

自分用メモ。
Ubiquityコマンドを作る時や、ビルトインコマンドを見るときに便利なのでまとめてリンクをはっておきます。

about:ubiquity
chrome://ubiquity/content/editor.html
chrome://ubiquity/content/builtincmds.js
chrome://ubiquity/content/cmdutils.js
http://ubiquity.s21g.com/

posted by Png satoko on Fri 12 Sep 2008 at 05:51

以前書いたprawnの記事ですが、その時のgemは0.1.2でした。で色々ggってソースを読んでいくうちにどうやら最新だと:wrap => :characterオプションがあることがわかりました。というわけでgithubからインストールした時のメモです。

gems.githubにない

http://gems.github.com/list.html
を見てもprawnはありません。ということでcloneしてインストールすることにしました。

cloneしてgemを生成, インストール

   1  $git clone git://github.com/raggi/prawn.git prawn.git
   2  $ cd prawn.git
   3  $ rake gem
   4  $ ls pkg/prawn-0.1.99.gem
   5  pkg/prawn-0.1.99.gem
   6  $sudo gem install pkg/prawn-0.1.99.gem
   7  $gem search prawn
   8  
   9  *** LOCAL GEMS ***
  10  prawn (0.1.99, 0.1.2)

gemのバージョンについて

prawnのバージョンが0.1.99とでていますが、あくまでもpre-0.2としての位置づけだそうで(作者のsandalさんに教えてもらった)、バグ報告などの場合は、git logで表示されるcommitの後のSHA1をバージョンとして用いるそうです。

   1  $git log
   2  commit c92a03685cd013af8767e7327b3a5def74a0a2ff
   3  Date:   Wed Aug 20 17:45:18 2008 -0400
   4  
   5      Minimal changes to support character based wrapping

posted by Png satoko on Tue 9 Sep 2008 at 11:13

メモ:今git addしたファイルをコミットやめと思ったときに。

   1  git add vendor/gems/prawn-0.1.99.gem
   2  git rm --cached vendor/gems/prawn-0.1.99.gem

ちなみに -f をつけるとリポジトリから削除されると同時にファイルも削除されます:

   1  git rm -f vendor/gems/prawn-0.1.99.gem

posted by Png satoko on Tue 9 Sep 2008 at 10:55 with 2 comments

prawnto(プラウント?)使ってみました。まだ課題があるのですが、現時点でのメモです。

http://cracklabs.com/prawnto
http://cracklabs.com/prawnto/demos:デモ一覧
http://github.com/thorny-sun/prawnto/tree/master
git://github.com/thorny-sun/prawnto.git

生成したPDF

以前の記事をPDFにしてみました。
生成されたPDF:test.pdf

pluginのインストール

prawnライブラリを使っているので、ますprawnをインストール。その後prawnto pluginインストール。

   1  sudo gem install prawn
   2  ./script/plugin install    git://github.com/thorny-sun/prawnto.git

(日本語表示用に)IPAフォントをダウンロード

下記からダウンロードして解凍、ttfファイルをアクセス可能なところにコピーします。
http://ossipedia.ipa.go.jp/ipafont/

配置するとしたら下記でしょうか。

  • #{RAILS_ROOT}/vendor/fonts
  • #{RAILS_ROOT}/vendor/font_ttf
  • /usr/share/fonts/
  • /usr/local/share/fonts/)

Rails controller, view

まずはController
page_layoutは:portrailt(縦)か:landscape(横)のどちらかです。

   1  #controller
   2      respond_to do |format|
   3        format.html { render :action => 'show' }
   4        format.pdf {
   5          prawnto :prawn => {
   6            :page_layout => :portrait, #
   7            :page_size => "A4",
   8            :left_margin => 36,
   9            :right_margin => 24,
  10            :top_margin => 24,
  11            :bottom_margin => 24},
  12          :inline => true
  13        }
  14      end

そしてview(show.pdf.prawnという形式のファイル)

   1  #show.pdf.prawn
   2  pdf.font "#{RAILS_ROOT}/public/ipag.ttf"
   3  pdf.text @article.title, :size => 36
   4  pdf.text @article.body
   5  pdf.text "This page has very wide left and right margins, causing a squeeze. " * 10
   6  pdf.text "これはテストです。" * 20
   7  pdf.font "Times-Roman"
   8  pdf.text "abcdefghijklmnopqrstu"* 20, :wrap => :character
   9  pdf.text "http://thebogles.com/blog/2007/10/how-to-add-google-adsense-for-mobile-to-your-ruby-on-rails-site/"

現時点での課題

  • URLや日本語の文章など空白がない文字列?だと折り返されない
    => demoで紹介されている:wrap => :characterオプションが0.1.2だとなさそう?
  • レイアウト枠のpdfを重ねたりする機能はない?(発見できず)
posted by Png satoko on Wed 3 Sep 2008 at 23:28 with 2 comments

http://thebogles.com/blog/2007/10/how-to-add-google-adsense-for-mobile-to-your-ruby-on-rails-site/
http://thebogles.com/_adsense.rhtml

手順

  1. 自分のアドセンスIDpub-123456789を取得
  2. モバイル コンテンツ向け AdSenseを開始しておく
  3. 下記のページを自分のRailsのviewsサブディレクトリにコピー
    http://thebogles.com/_adsense.rhtml
  4. 手順3でコピーしたページの8行目にあるcliend_idを手順1で取得した自分のアドセンスIDと置き換える
  5. アドセンスを載せたい場所に下記を挿入
       1  <%= render :partial => "adsense" %>
    
  6. おしまい

PS PCから表示確認を行うと <!-- google_afm -->というコメントが出るだけなので、携帯から確認を行ってください。

posted by Png satoko on Mon 1 Sep 2008 at 16:53

以前git-svnについて記事を書いたのですが、最近s21gでもGitでリポジトリができたので、pure gitにしてみることにしました。

よく使うコマンド達

   1  #リモートやブランチを確認・追加
   2  git remote #リモート一覧
   3  git branch #ブランチ一覧
   4  git remote add origin ssh://git.s21g.com/mnt/git/muji.git
   5  git config --get remote.origin.url #リモートoriginのURLを表示
   6  
   7  #変更を確認してマージ
   8  git fetch origin
   9  git log -p master..origin/master # -pをつけるとdiff状態を見せてくれる
  10  git merge origin/master
  11  
  12  #コミット
  13  git push origin master

  • 以前に書いたgit stash, git stash apply, git checkout -- filenameなどももちろん使っています。

git-pullは二つの動作をまとめてやってくれる

"pull" コマンドは次の2つの操作を実行します:
(1) リモートブランチから変更を取得。= fetch
(2) それらを現在のブランチにマージ。= merge
http://www8.atwiki.jp/git_jp/pub/Documentation.ja/tutorial.html

git-logはややこしい

   1  git log test..master  # master から到達可能だが、test からは到達可でないコミット
   2  git log master..test  # test から到達可能だが、master からは到達可能でないコミット
   3  git log master...test # test または master から到達可能だが、両方からは到達可能でない...
http://www8.atwiki.jp/git_jp/pub/Documentation.ja/user-manual.html#browsing-revisions

posted by Png satoko on Sat 30 Aug 2008 at 01:53
Contents
my .screenrc: chdir(cd)したり、stuffしたり
gemspecファイルの書き方
iPhone AppStoreのRSSたち
emacsclientとDebian emacs22ソースからインストール
Ubiquityメモ
prawn: GitHubからcloneしてgemを生成、インストールする
git addしたファイルをやめる:git rm --cached filename
Rails:prawn & prawntoで日本語のPDF生成
Railsで携帯版Google Adsenseを掲載する
git-svnから(pure)gitに移行しました:よく使うコマンド
Comments
KingofSmack: Here also good reads for this mobile applicatio... '14-5
satoko: stackoverflowでも同じエラーを挙げている人がいたので、1.3でアップロードしたよっ... '10-12
ujihisa: :%s/blog/glob/g '10-7
satoko: しゅが〜様 返事が遅くなって申し訳ありません。また、投稿百景ご購入ありがとうございます。 ... '09-10
しゅが~: こんにちは。投稿百景を発売日翌日から利用しています。本当にいいAppを作っていただきました。罫... '09-10
Services from s21g
twpro(ツイプロ)
Twitterプロフィールを快適検索
地価2009
土地の値段を調べてみよう
MyRestaurant
自分だけのレストラン手帳
Formula
ブログに数式を埋め込める数式コミュニティ