<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>blog::2310</title>
	<atom:link href="http://blog.2310.net/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.2310.net</link>
	<description>2310</description>
	<lastBuildDate>Sat, 14 Aug 2010 15:17:27 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>和暦(元号)変換クラス</title>
		<link>http://blog.2310.net/archives/706</link>
		<comments>http://blog.2310.net/archives/706#comments</comments>
		<pubDate>Thu, 13 May 2010 14:45:43 +0000</pubDate>
		<dc:creator>2310</dc:creator>
				<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://blog.2310.net/?p=706</guid>
		<description><![CDATA[rubyを勉強しています。練習で作成したものです。



#!/usr/bin/ruby -w
require 'date'

class WaDate &#60; Date
  GENGOU= {
    1868 =&#62; {:full =&#62; '明治', :short =&#62; '明', :alpha =&#62; 'M'},
    1912 =&#62; {:full =&#62; '大正', :short =&#62; '大', :alpha =&#62; 'T'},
    1926 =&#62; {:full =&#62; '昭和', :short =&#62; '昭', :alpha =&#62; 'S'},
    1989 [...]]]></description>
			<content:encoded><![CDATA[<p>rubyを勉強しています。練習で作成したものです。</p>

<p><span id="more-706"></span></p>

<pre><code>#!/usr/bin/ruby -w
require 'date'

class WaDate &lt; Date
  GENGOU= {
    1868 =&gt; {:full =&gt; '明治', :short =&gt; '明', :alpha =&gt; 'M'},
    1912 =&gt; {:full =&gt; '大正', :short =&gt; '大', :alpha =&gt; 'T'},
    1926 =&gt; {:full =&gt; '昭和', :short =&gt; '昭', :alpha =&gt; 'S'},
    1989 =&gt; {:full =&gt; '平成', :short =&gt; '平', :alpha =&gt; 'H'}
  }

  def initialize(ajd=0, of=0, sg=ITALY)
    super
    @current_gengou = nil
  end

  def current_gengou
    return @current_gengou if @current_gengou &amp;&amp; @current_gengou[:year] == year
    gengou_start_year = GENGOU.keys.sort.reverse.find do |start_year|
      year &gt; start_year
    end
    @current_gengou = {
      :year =&gt; year,
      :gengou_year =&gt; year - gengou_start_year + 1
    }.merge(GENGOU[gengou_start_year])
  end

  def wa_year(style = nil)
    style &amp;&amp; gengou(style) + current_gengou[:gengou_year].to_s || current_gengou[:gengou_year]
  end

  def gengou(style)
    current_gengou[style] || raise
  end

end



date = WaDate.today # 2010-05-13
puts date.wa_year :full # '平成22'
puts date.gengou :alpha # 'H'
puts date.wa_year + 1 #=&gt; 23
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.2310.net/archives/706/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>vimの貼り付け</title>
		<link>http://blog.2310.net/archives/695</link>
		<comments>http://blog.2310.net/archives/695#comments</comments>
		<pubDate>Wed, 05 May 2010 05:17:35 +0000</pubDate>
		<dc:creator>2310</dc:creator>
				<category><![CDATA[uncategorized]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://blog.2310.net/?p=695</guid>
		<description><![CDATA[普段はエディタはemacsを使用していますが、サーバのちょっとした設定やsshでのログイン作業にはvimを使用することもあります。
vimを使用していて毎度毎度頭が混乱するのが貼り付け時の挙動なのでメモします。




 
   
     コマンド
     貼付時
     実行後カーソル位置
     実行後カーソル位置(with g)
   
 
 
  
    p(小文字)
    append(追加)処理。行単位ならカーソルの次行から、文字単位ならカーソルの次の位置から追加する
    行単位なら追加した行の行頭へ、文字単位なら追加した文字列の最後の文字へ
    行単位なら追加した行の最後へ、文字単位なら追加した文字列の最後の文字へ(gが無い場合と同じ？)
  
  
   [...]]]></description>
			<content:encoded><![CDATA[<p>普段はエディタは<a href="http://www.gnu.org/software/emacs/emacs.html">emacs</a>を使用していますが、サーバのちょっとした設定やsshでのログイン作業には<a href="http://www.vim.org">vim</a>を使用することもあります。
<a href="http://www.vim.org">vim</a>を使用していて毎度毎度頭が混乱するのが貼り付け時の挙動なのでメモします。</p>

<p><span id="more-695"></span></p>

<table class="standard_table">
 <thead>
   <tr>
     <th>コマンド</th>
     <th>貼付時</th>
     <th>実行後カーソル位置</th>
     <th>実行後カーソル位置(with g)</th>
   </tr>
 </thead>
 <tbody>
  <tr>
    <th>p(小文字)</th>
    <td>append(追加)処理。行単位ならカーソルの次行から、文字単位ならカーソルの次の位置から追加する</td>
    <td>行単位なら追加した行の行頭へ、文字単位なら追加した文字列の最後の文字へ</td>
    <td>行単位なら追加した行の最後へ、文字単位なら追加した文字列の最後の文字へ(gが無い場合と同じ？)</td>
  </tr>
  <tr>
    <th>P(大文字)</th>
    <td>insert(挿入)処理。行単位ならカーソルの行から、文字単位ならカーソルの位置から追加する</td>
    <td>行単位なら追加した行の行頭へ、文字単位なら追加した文字列の最後の文字へ</td>
    <td>行単位なら追加した行の最後へ(小文字pの場合と同様)、文字単位なら追加した文字列の最後の文字の後ろへ</td>
  </tr>
 </tbody>
</table>

<p>gP がWindowsやEmacsのヤンクに近い挙動かもしれません。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.2310.net/archives/695/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ボタン</title>
		<link>http://blog.2310.net/archives/682</link>
		<comments>http://blog.2310.net/archives/682#comments</comments>
		<pubDate>Sun, 25 Apr 2010 03:05:28 +0000</pubDate>
		<dc:creator>2310</dc:creator>
				<category><![CDATA[inkscape]]></category>

		<guid isPermaLink="false">http://blog.2310.net/?p=682</guid>
		<description><![CDATA[Inkscapeで練習として。

それぞれの画像をクリックするとsvgファイルがダウンロードできます(フォントはIPAゴシックを使用)。







ポイント


Fillは4段階のグラデーション。上を明るくします。HSVで何となく調整します。
下部分の影は一番上に持ってきています。
文字列のコピーをとって黒くしblurをかけてからオリジナル文字列の左上に配置するとへこんでいるように見えます。

]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.forest.impress.co.jp/lib/pic/piccam/paint/inkscape.html">Inkscape</a>で練習として。</p>

<p>それぞれの画像をクリックするとsvgファイルがダウンロードできます(フォントはIPAゴシックを使用)。</p>

<div style="margin-left:auto;margin-right:auto;margin-top:1em;"><a href="http://blog.2310.net/my-store/download/20100425_button01.svg"><img src="http://blog.2310.net/my-store/images/20100425_button01.png" alt="サンプルボタンその1" style="border: none;" /></a></div>

<div style="margin-left:auto;margin-right:auto;"><a href="http://blog.2310.net/my-store/download/20100425_button02.svg"><img src="http://blog.2310.net/my-store/images/20100425_button02.png" alt="サンプルボタンその1" style="border: none;" /></a></div>

<p><span id="more-682"></span></p>

<h4>ポイント</h4>

<ul>
<li>Fillは4段階のグラデーション。上を明るくします。HSVで何となく調整します。</li>
<li>下部分の影は一番上に持ってきています。</li>
<li>文字列のコピーをとって黒くしblurをかけてからオリジナル文字列の左上に配置するとへこんでいるように見えます。</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.2310.net/archives/682/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XREAの環境を整える</title>
		<link>http://blog.2310.net/archives/666</link>
		<comments>http://blog.2310.net/archives/666#comments</comments>
		<pubDate>Sat, 26 Sep 2009 05:13:13 +0000</pubDate>
		<dc:creator>2310</dc:creator>
				<category><![CDATA[uncategorized]]></category>

		<guid isPermaLink="false">http://blog.2310.net/?p=666</guid>
		<description><![CDATA[XREAはsshでログインすることができます。コマンドで使用するためのメモをまとめます。



Mercurialについて

インストール

xrea/mercurialにある通り実行します。

ダウンロード後 make&#38;&#38;install

$ wget mercurial-XXX; cd mercurial-XXX
$ HOME=$HOME/local make install-home
-- test
$ export PYTHONPATH=$HOME/local/lib/python
$ export PATH=$PATH:$HOME/local/bin
$ hg debuginstall


.bashrcに以下の内容を書き込みます。

export PATH=$PATH:$HOME/local/bin
export PYTHONPATH=$HOME/local/lib/python


MySQLについて

バックアップ

圧縮ダンプします

mysqldump  &#60;databas-name&#62;  -u &#60;user_name&#62; -p &#124; bzip -c &#62;  path/to/file.bz2

]]></description>
			<content:encoded><![CDATA[<p>XREAはsshでログインすることができます。コマンドで使用するためのメモをまとめます。</p>

<p><span id="more-666"></span></p>

<h4>Mercurialについて</h4>

<h5>インストール</h5>

<p><a href="http://w.nikori.tk/index.php?xrea%2Fmercurial">xrea/mercurial</a>にある通り実行します。</p>

<p>ダウンロード後 make&amp;&amp;install</p>

<pre><code>$ wget mercurial-XXX; cd mercurial-XXX
$ HOME=$HOME/local make install-home
-- test
$ export PYTHONPATH=$HOME/local/lib/python
$ export PATH=$PATH:$HOME/local/bin
$ hg debuginstall
</code></pre>

<p>.bashrcに以下の内容を書き込みます。</p>

<pre><code>export PATH=$PATH:$HOME/local/bin
export PYTHONPATH=$HOME/local/lib/python
</code></pre>

<h4>MySQLについて</h4>

<h5>バックアップ</h5>

<p>圧縮ダンプします</p>

<pre><code>mysqldump  &lt;databas-name&gt;  -u &lt;user_name&gt; -p | bzip -c &gt;  path/to/file.bz2
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.2310.net/archives/666/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>xyzzyをちょこちょこ改造</title>
		<link>http://blog.2310.net/archives/618</link>
		<comments>http://blog.2310.net/archives/618#comments</comments>
		<pubDate>Tue, 22 Sep 2009 18:12:43 +0000</pubDate>
		<dc:creator>2310</dc:creator>
				<category><![CDATA[windows]]></category>
		<category><![CDATA[xyzzy]]></category>

		<guid isPermaLink="false">http://blog.2310.net/?p=618</guid>
		<description><![CDATA[テキストエディタxyzzyをUSBメモリーで使用できるよう少しずつ改造しています。

xyzzyとはフリー/シェアで公開されているエディタの中でもトップクラスの高性能なエディタです。詳しくはXyzzy Wikiの中にあるintroを見てみましょう。



機能

xyzzyに以下の機能を追加して再ビルドするものです。


Homeディレクトリの自動設定。以下の順に検索


$xyzzy/home
$DRIVE/xyzzyhome
$DRIVE/home
$xyzzy

xyzzy.iniを$XYZZY/usrに保存(ユーザ名やOS名でフォルダ分けしない)
ダンプファイルxyzzy.imageとしてシステムのTempフォルダへ保存/読込
unlha32.dllなど各種アーカイバDLLがシステムフォルダや$XYZZY内に存在しない場合は$XYZZY/libも検索
putenv関数の追加(詳しくは「パッチ更新の履歴」参照)


ダウンロード

xyzzy-0.2.235-2009092301.patch を適用した
xyzzy.exe、xyzzyenv.exe、xyzzycli.exe です。ダウンロード解凍後、本体のものと置き換えてください。


xyzzy-20090923.zip (xyzzy-0.2.235ベース 約741KB)


その他、個人的な設定など

以下はおまけですが私は.xyzzyの位置をusrディクレトリ直下に固定しています。USBメモリーなどから直接使用する際にHOMEディレクトリやXYZZYHOMEの設定と関係無く.xyzzyファイルを読み込むためです。なお、estartup.lcが存在する場合(というか普通は存在するはず)はestartup.lを編集後バイトコンパイルしなければいけません。

--- xyzzy/lisp/estartup.l   2003-06-29 01:07:14.000000000 +0900
+++ xyzzy-merged/lisp/estartup.l   2006-04-08 11:17:10.000000000 +0900
@@ -147,11 +147,12 @@
       (ignore-errors (load-history-file-compat)))
     (unless no-init-file
       (trap-errors
        (let ((*loading-user-initial-file* t))
    [...]]]></description>
			<content:encoded><![CDATA[<p>テキストエディタ<a href="http://www.jsdlab.co.jp/~kamei/">xyzzy</a>をUSBメモリーで使用できるよう少しずつ改造しています。</p>

<p>xyzzyとはフリー/シェアで公開されているエディタの中でもトップクラスの高性能なエディタです。詳しくは<a href="http://xyzzy.s53.xrea.com/wiki/">Xyzzy Wiki</a>の中にある<a href="http://xyzzy.s53.xrea.com/wiki/index.php?QuickTour%2Fintro">intro</a>を見てみましょう。</p>

<p><span id="more-618"></span></p>

<h3>機能</h3>

<p>xyzzyに以下の機能を追加して再ビルドするものです。</p>

<ul>
<li>Homeディレクトリの自動設定。以下の順に検索

<ul>
<li>$xyzzy/home</li>
<li>$DRIVE/xyzzyhome</li>
<li>$DRIVE/home</li>
<li>$xyzzy</li>
</ul></li>
<li>xyzzy.iniを$XYZZY/usrに保存(ユーザ名やOS名でフォルダ分けしない)</li>
<li>ダンプファイルxyzzy.imageとしてシステムのTempフォルダへ保存/読込</li>
<li>unlha32.dllなど各種アーカイバDLLがシステムフォルダや$XYZZY内に存在しない場合は$XYZZY/libも検索</li>
<li>putenv関数の追加(詳しくは「パッチ更新の履歴」参照)</li>
</ul>

<h3>ダウンロード</h3>

<p><a href="http://blog.2310.net/my-store/download/xyzzy-0.2.235-2009092301.patch.txt" title="xyzzy-0.2.235-2009092301.patch のダウンロード">xyzzy-0.2.235-2009092301.patch </a>を適用した
xyzzy.exe、xyzzyenv.exe、xyzzycli.exe です。ダウンロード解凍後、本体のものと置き換えてください。</p>

<ul>
<li><a href="http://blog.2310.net/my-store/download/xyzzy-20090923.zip" title="xyzzy-20090923.zipのダウンロード">xyzzy-20090923.zip</a> (xyzzy-0.2.235ベース 約741KB)</li>
</ul>

<h3>その他、個人的な設定など</h3>

<p>以下はおまけですが私は.xyzzyの位置をusrディクレトリ直下に固定しています。USBメモリーなどから直接使用する際にHOMEディレクトリやXYZZYHOMEの設定と関係無く.xyzzyファイルを読み込むためです。なお、estartup.lcが存在する場合(というか普通は存在するはず)はestartup.lを編集後バイトコンパイルしなければいけません。</p>

<pre><code>--- xyzzy/lisp/estartup.l   2003-06-29 01:07:14.000000000 +0900
+++ xyzzy-merged/lisp/estartup.l   2006-04-08 11:17:10.000000000 +0900
@@ -147,11 +147,12 @@
       (ignore-errors (load-history-file-compat)))
     (unless no-init-file
       (trap-errors
        (let ((*loading-user-initial-file* t))
          (load (namestring (if (file-system-supports-long-file-name-p "~/")
-                               "~/.xyzzy" "~/_xyzzy"))
+             (merge-pathnames "usr/.xyzzy" (si:system-root))
+             (merge-pathnames "usr/_xyzzy" (si:system-root))))
                :if-does-not-exist nil :verbose nil :print nil)))
       (unless *inhibit-history-load*
        (ignore-errors (load-history-file))))
     (ignore-errors (keep-compatibility))
     (ignore-errors (init-app-menus))
</code></pre>

<h3>Special Thanks</h3>

<ul>
<li><a href="http://xyzzy.s53.xrea.com/wiki/">Xyzzy Wiki</a>の佐野さん</li>
<li><a href="http://xyzzy.s53.xrea.com/wiki/">Xyzzy Wiki</a>のみなさん</li>
<li>そしてエディタ<a href="http://www.jsdlab.co.jp/~kamei/">xyzzy</a>を提供してくださっている亀井さん</li>
</ul>

<h3>更新の履歴</h3>

<h4>2009/09/23</h4>

<p><a href="http://blog.2310.net/my-store/download/xyzzy-0.2.235-2009092301.patch.txt" title="xyzzy-0.2.235-2009092301.patch.txt のダウンロード">xyzzy-0.2.235-2009092301.patch.txt </a></p>

<ul>
<li>xyzzycli.exeの接続不具合解消パッチ適用 <br />(<a href="http://xyzzy.s53.xrea.com/wiki/index.php?Memo%2F%A5%BD%A1%BC%A5%B9%A4%AB%A4%E9%A5%D3%A5%EB%A5%C9%A4%B7%A4%C6%A4%DF%A4%EB3">XyzzyWiki内「Memo/ソースからビルドしてみる3」</a>のコメント部分)</li>
</ul>

<h4>2008/09/21</h4>

<p><a href="http://blog.2310.net/my-store/download/xyzzy-0.2.235-2008092101.patch.txt" title="xyzzy-0.2.235-2008092101.patch.txt のダウンロード">xyzzy-0.2.235-2008092101.patch.txt </a></p>

<ul>
<li>putenv関数を追加
<pre><code>
;; .xyzzyとかで(si:putenv VARIABLE) を使用してみる
;; $xyzzy/binを環境変数PATHに追加(有効なのはxyzzy.exeからのプロセスだけです)
(in-package "editor")
(setq &#42;bin-path&#42; (merge-pathnames "bin" (si:system-root)))
(in-package "user")
(setq &#42;bin-path&#42; (merge-pathnames "bin" (si:system-root)))
(si:putenv  (concat "PATH=" (map-slash-to-backslash &#42;bin-path&#42;) ";" (si:getenv "PATH")));
</code></pre></li>
</ul>

<h4>2008/09/15</h4>

<p><a href="http://blog.2310.net/my-store/download/xyzzy-0.2.235-2008091502.patch.txt" title="xyzzy-0.2.235-2008091502.patch.txt のダウンロード">xyzzy-0.2.235-2008091502.patch.txt </a></p>

<ul>
<li>USBメモリーで使用できるようパッチを追加

<ul>
<li>Homeディレクトリの自動設定。以下の順に検索

<ul>
<li>$xyzzy/home</li>
<li>$DRIVE/xyzzyhome</li>
<li>$DRIVE/home</li>
<li>$xyzzy</li>
</ul></li>
<li>xyzzy.iniを$XYZZY/usrに保存(ユーザ名やOS名でフォルダ分けしない)</li>
<li>ダンプファイルxyzzy.imageとしてシステムのTempフォルダへ保存/読込</li>
<li>unlha32.dllなど各種アーカイバDLLがシステムフォルダや$XYZZY内に存在しない場合は$XYZZY/libも検索</li>
</ul></li>
</ul>

<h4>2008/09/15</h4>

<p><a href="http://blog.2310.net/my-store/download/xyzzy-0.2.235-2008091501.patch.txt" title="xyzzy-0.2.235-2008091501.patch.txt のダウンロード">xyzzy-0.2.235-2008091501.patch.txt </a></p>

<ul>
<li>VC9用のpatchを作成</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.2310.net/archives/618/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>emacs-w3m上で短縮URLを取得する &#8211; その2</title>
		<link>http://blog.2310.net/archives/604</link>
		<comments>http://blog.2310.net/archives/604#comments</comments>
		<pubDate>Sun, 06 Sep 2009 10:03:59 +0000</pubDate>
		<dc:creator>2310</dc:creator>
				<category><![CDATA[Emacs]]></category>

		<guid isPermaLink="false">http://blog.2310.net/?p=604</guid>
		<description><![CDATA[前回(emacs-w3m上で短縮URLを取得する &#8211; その1)で紹介したemacs-w3m内で短縮URLを取得する関数ですがちょっと整理して、TinyURL、bit.ly、ig.gdなど複数のサービスに対応するようにしてみました。


前回のサービス毎の関数を一つにまとめています。

;; サービスを使用して短縮URLをkill-ringに入れる関数
;; 引数 url     ... URL
;; 引数 service ... 使用するサービス -&#62; 'TinyURL or 'is.gd or 'bit.ly
(defun shorten-url-to-kill-ring (url &#38;optional service)
  (let (service-uri
        key
        get-regexp
        method)
   [...]]]></description>
			<content:encoded><![CDATA[<p>前回(<a href="http://blog.2310.net/archives/582">emacs-w3m上で短縮URLを取得する &#8211; その1</a>)で紹介したemacs-w3m内で短縮URLを取得する関数ですがちょっと整理して、<a href="http://www.tinyurl.com/">TinyURL</a>、<a href="http://bit.ly/">bit.ly</a>、<a href="http://is.gd/">ig.gd</a>など複数のサービスに対応するようにしてみました。</p>

<p><span id="more-604"></span>
前回のサービス毎の関数を一つにまとめています。</p>

<pre><code>;; サービスを使用して短縮URLをkill-ringに入れる関数
;; 引数 url     ... URL
;; 引数 service ... 使用するサービス -&gt; 'TinyURL or 'is.gd or 'bit.ly
(defun shorten-url-to-kill-ring (url &amp;optional service)
  (let (service-uri
        key
        get-regexp
        method)
    ;; default service to shorten
    (unless service (setq service 'TinyURL))
    ;; switch parameter by each url-shorten service
    (cond ((eq service 'TinyURL)
           ;; via http://tinyurl.com/  use API
           (setq service-uri "http://tinyurl.com/api-create.php")
           (setq key "url")
           (setq method "POST")
           (setq get-regexp "\\(http://tinyurl.com/.+\\)"))
          ((eq service 'is.gd)
           ;; via http://is.gd/  use API
           (setq service-uri "http://is.gd/api.php")
           (setq key "longurl")
           (setq method "GET")
           (setq get-regexp "\\(http://is.gd/.+\\)"))
          ((eq service 'bit.ly)
           ;; via http://bit.ly/  NOT USE API, get from web page
           (setq service-uri "http://bit.ly")
           (setq method "POST")
           (setq key "url")
           (setq get-regexp "id *= *\"shortened-url\" +value *= *\"\\(http://bit.ly/.+\\)\" +/&gt;")))
    ;; use url package ...
    (setq url-request-method method)
    (if (equal method "POST")
        (setq url-request-data (concat key "=" (url-hexify-string url)))
      (setq url-request-data nil)
      (setq service-uri (concat service-uri "?" key "=" (url-hexify-string url))))
    ;; Now, try to fetch short URL
    (url-retrieve service-uri
                  '(lambda (status cbargs)
                     (point-min)
                     (if (re-search-forward (car (cdr cbargs)) nil t)
                         (progn
                           (setq result-url (match-string-no-properties 1))
                           (kill-new result-url nil)
                           (message "Copy '%s' to ring, shorten %s" result-url (car cbargs))))
                     (kill-buffer (current-buffer)))
                  (list (list url get-regexp)))))




;; 上をw3m上から使用するための関数 (この例ではis.gdを使用する)
(defun my-w3m-shorten-url ()
  (interactive)
  (shorten-url-to-kill-ring
     (or (w3m-url-valid (w3m-anchor))
         (w3m-url-valid w3m-current-url))
     'is.gd))
</code></pre>

<p>キーバインドとかは必要だったら適当にしてください。</p>

<pre><code>(eval-after-load "w3m"
  '(progn
     ;; w3m-mode-map key binds
     (define-key w3m-mode-map "\C-cs" 'my-w3m-shorten-url)))
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.2310.net/archives/604/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>emacs-w3m上で短縮URLを取得する &#8211; その1</title>
		<link>http://blog.2310.net/archives/582</link>
		<comments>http://blog.2310.net/archives/582#comments</comments>
		<pubDate>Sat, 05 Sep 2009 03:52:39 +0000</pubDate>
		<dc:creator>2310</dc:creator>
				<category><![CDATA[Emacs]]></category>

		<guid isPermaLink="false">http://blog.2310.net/?p=582</guid>
		<description><![CDATA[Twitterを使用するようになってからTinyURLとかbit.ly使用する機会が増えたのでemacs上のw3mから簡単に短縮URLを取得できるように関数を作成しました。Twitter自体自動的にURLを短縮する機能を持っているようですけど。

この投稿については内容が更新されています。「emacs-w3m上で短縮URLを取得する &#8211; その2」の方を利用してください。


以下の関数を.emacsとかに書き込みます。

;; URLを短縮してkill-ringの中に入れる関数(TinyURLを使用バージョン ... API使用)
(defun shorten-url-tinyurl(url)
  (let ((shorten-uri "http://tinyurl.com/api-create.php")
        (url-request-method "POST")
        (url-request-extra-headers
             '(("Content-Type" . "application/x-www-form-urlencoded")))
        (url-request-data (concat "url=" (url-hexify-string url))))
 [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.twitter.com">Twitter</a>を使用するようになってから<a href="http://tinyurl.com">TinyURL</a>とか<a href="http://bit.ly/">bit.ly</a>使用する機会が増えたのでemacs上のw3mから簡単に短縮URLを取得できるように関数を作成しました。Twitter自体自動的にURLを短縮する機能を持っているようですけど。</p>

<p>この投稿については内容が更新されています。「<a href="http://blog.2310.net/archives/604">emacs-w3m上で短縮URLを取得する &#8211; その2</a>」の方を利用してください。</p>

<p><span id="more-582"></span>
以下の関数を.emacsとかに書き込みます。</p>

<pre><code>;; URLを短縮してkill-ringの中に入れる関数(TinyURLを使用バージョン ... API使用)
(defun shorten-url-tinyurl(url)
  (let ((shorten-uri "http://tinyurl.com/api-create.php")
        (url-request-method "POST")
        (url-request-extra-headers
             '(("Content-Type" . "application/x-www-form-urlencoded")))
        (url-request-data (concat "url=" (url-hexify-string url))))
    (url-retrieve shorten-uri
                  '(lambda (status cbargs)
                     (point-min)
                     (if (re-search-forward  "\\(http://tinyurl.com/.+\\)" nil t)
                         (progn
                           (setq result-url (match-string-no-properties 1))
                           (kill-new result-url nil)
                           (message "Copy '%s' to ring, shorten %s" result-url cbargs)))
                     (kill-buffer (current-buffer)))
                  (list url))))

;; URLを短縮してkill-ringの中に入れる関数(bit.lyを使用バージョン ... API不使用)
(defun shorten-url-bitly (url)
  (let ((shorten-uri "http://bit.ly")
        (shorten-uri-get-regexp "id *= *\"shortened-url\" +value *= *\"\\(http://bit.ly/.+\\)\" +/&gt;")
        (url-request-method "POST")
        (url-request-extra-headers
             '(("Content-Type" . "application/x-www-form-urlencoded")))
        (url-request-data (concat "url=" (url-hexify-string url))))
    (url-retrieve shorten-uri
                  '(lambda (status cbargs)
                     (point-min)
                     (if (re-search-forward (car (cdr cbargs)) nil t)
                         (progn
                           (setq result-url (match-string-no-properties 1))
                           (kill-new result-url nil)
                           (message "Copy '%s' to ring, shorten %s" result-url (car cbargs))))
                     (kill-buffer (current-buffer)))
                  (list (list url shorten-uri-get-regexp)))))



;; 上をw3m上から使用するための関数
(defun my-w3m-shorten-url ()
  (interactive)
  (shorten-url-tinyurl ;; もしくは shorten-url-bitly
   (or (w3m-url-valid (w3m-anchor))
       (w3m-url-valid w3m-current-url))))
</code></pre>

<p>キーバインドとかは必要だったら適当にしてください。</p>

<pre><code>(eval-after-load "w3m"
  '(progn
     ;; w3m-mode-map key binds
     (define-key w3m-mode-map "\C-cs" 'my-w3m-shorten-url)))
</code></pre>

<p>ちなみに<a href="http://tinyurl.com">TinyURL</a>と<a href="http://bit.ly/">bit.ly</a>バージョンを用意しています。好きな方を選択してください。ただしbit.lyバージョンはAPIではなく通常のWebページから取得しているためWebページの改装等で使用できなくなる可能性があります。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.2310.net/archives/582/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQLITE3のメモ</title>
		<link>http://blog.2310.net/archives/578</link>
		<comments>http://blog.2310.net/archives/578#comments</comments>
		<pubDate>Sun, 09 Aug 2009 08:53:02 +0000</pubDate>
		<dc:creator>2310</dc:creator>
				<category><![CDATA[uncategorized]]></category>

		<guid isPermaLink="false">http://blog.2310.net/?p=578</guid>
		<description><![CDATA[SQLITE3のメモ


バックアップとリストア(コマンドラインから)

sqlite3 test.sqlite3 .dump &#62; dump.sql
sqlite3 test.sqlite3 &#60; dump.sql

]]></description>
			<content:encoded><![CDATA[<p>SQLITE3のメモ
<span id="more-578"></span></p>

<h3>バックアップとリストア(コマンドラインから)</h3>

<pre><code>sqlite3 test.sqlite3 .dump &gt; dump.sql
sqlite3 test.sqlite3 &lt; dump.sql
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.2310.net/archives/578/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Git Memo</title>
		<link>http://blog.2310.net/archives/540</link>
		<comments>http://blog.2310.net/archives/540#comments</comments>
		<pubDate>Sun, 21 Jun 2009 03:46:01 +0000</pubDate>
		<dc:creator>2310</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Program]]></category>
		<category><![CDATA[git]]></category>

		<guid isPermaLink="false">http://blog.2310.net/?p=540</guid>
		<description><![CDATA[個人的なGitメモです。「WEB+DB PRESS 第50号」の中の「特集2 はじめてのGit」を基礎としています。



書式

レポジトリ 

/home/hoge/repositry ... ローカルのファイル形式
host:/home/repositry ... scp形式


各コマンド

git init

レポジトリの作成

git init --bare ... ワークツリー無し
git init --shared ... ワークツリー無し
※ 共有ディレクトリを作成する場合はumaskを002(グループ以外にも書き込み許可)とか007(グループ以外には読み込みも付加)


git status

状態表示

git diff

差分をとる。gitの場合、状態はワークツリー、インデックス(キャッシュ)、レポジトリの3種類ある。それぞれのdiffは下のかんじ。



git add

ワークツリーの状態をindexへ記録

git add -u ... ワークツリーの状態を一括してindexへ
git add -p ... diffのハンク毎にaddする(対話式)
git add -A ... git add . &#38;&#38; git add -u


git reset

状態を戻る(git revertとは異なりcommitを無かったことにする)

git reset HEAD^ ... HEADを一つ前のコミットまで戻る(インデックスも含め直近のコミットまでを取り消す)
git reset --soft HEAD^ ... 作業ツリーはそのままでレポジトリのポインタをHEADの一つ前まで戻る
git reset --hard HEAD  [...]]]></description>
			<content:encoded><![CDATA[<p>個人的なGitメモです。「<a href="http://gihyo.jp/magazine/wdpress/archive/2009/vol50">WEB+DB PRESS 第50号</a>」の中の「特集2 はじめてのGit」を基礎としています。</p>

<p><span id="more-540"></span></p>

<h3>書式</h3>

<h4>レポジトリ <repositry></h4>

<pre><code>/home/hoge/repositry ... ローカルのファイル形式
host:/home/repositry ... scp形式
</code></pre>

<h3>各コマンド</h3>

<h4>git init</h4>

<p>レポジトリの作成</p>

<pre><code>git init --bare ... ワークツリー無し
git init --shared ... ワークツリー無し
※ 共有ディレクトリを作成する場合はumaskを002(グループ以外にも書き込み許可)とか007(グループ以外には読み込みも付加)
</code></pre>

<h4>git status</h4>

<p>状態表示</p>

<h4>git diff</h4>

<p>差分をとる。gitの場合、状態はワークツリー、インデックス(キャッシュ)、レポジトリの3種類ある。それぞれのdiffは下のかんじ。</p>

<p><img src="http://blog.2310.net/my-store/images/20090621_git_diagram.png" alt="ダイアグラム" /></p>

<h4>git add</h4>

<p>ワークツリーの状態をindexへ記録</p>

<pre><code>git add -u ... ワークツリーの状態を一括してindexへ
git add -p ... diffのハンク毎にaddする(対話式)
git add -A ... git add . &amp;&amp; git add -u
</code></pre>

<h4>git reset</h4>

<p>状態を戻る(git revertとは異なりcommitを無かったことにする)</p>

<pre><code>git reset HEAD^ ... HEADを一つ前のコミットまで戻る(インデックスも含め直近のコミットまでを取り消す)
git reset --soft HEAD^ ... 作業ツリーはそのままでレポジトリのポインタをHEADの一つ前まで戻る
git reset --hard HEAD  ... ワークツリーの状態を含めてHEADまで戻る(ワークツリー上の変更をインデックスも含め取消)
git reset --hard HEAD^ ... ワークツリーの状態を含めてHEADの一つ前まで戻る
git reset --hard master~4 ... ブランチmasterから4つ前までを取り消す
</code></pre>

<h4>git commit</h4>

<p>indexに記録された状態をレポジトリへ</p>

<pre><code>git commit -a ... git add -u &amp;&amp; git commit
git commit -v ... git diff --cached の内容も表示する
git commit --amend ... 直前コミットの取消 (git reset --soft HEAD^ &amp;&amp; edit &amp;&amp; git commit -c ORIG_HEAD)
</code></pre>

<h4>git log</h4>

<p>ログ</p>

<pre><code>git log -p ... パッチ形式で取得
git log --pretty=short ... サマリー(最初の段落)のみ取得
git log --stat ... 変更されたファイル名なども含め表示
</code></pre>

<h4>git brame</h4>

<p>一行毎に表示</p>

<h4>git revert</h4>

<p>レポジトリ内の履歴を打ち消す(逆のパッチをあてるような感じ？)</p>

<h4>git show</h4>

<p>git logとの違いが把握できていない</p>

<h4>git push</h4>

<p>レポジトリに記録を反映させる</p>

<pre><code>git push &lt;repositry&gt; &lt;branch&gt; ... &lt;repositry&gt;の&lt;branch&gt;に反映
</code></pre>

<h4>git pull</h4>

<p>レポジトリから反映させる</p>

<h4>git push</h4>

<p>レポジトリに記録を反映させる</p>

<pre><code>git push &lt;repositry&gt; &lt;branch&gt; ... &lt;repositry&gt;の&lt;branch&gt;に反映
</code></pre>

<h4>git stash</h4>

<p>現在のコミットしてない変更状況を保存</p>

<pre><code>git stash ... 現在の状況を保存
git stash pop ... 保存した状況を再読み込み
</code></pre>

<h4>git branch</h4>

<pre><code>git branch ... branchのリストを表示/現在のブランチを確認
git branch &lt;branch&gt; ... &lt;branch&gt;とする(新規作成もそのままOK？)
</code></pre>

<h4>git checkout</h4>

<pre><code>git checkout &lt;branch&gt; ... &lt;branch&gt;にスイッチ
git checkout -b &lt;branch&gt; ... git branch &lt;branch&gt; &amp;&amp; git checkout &lt;branch&gt;
</code></pre>

<h4>git merge</h4>

<pre><code>git merge &lt;branch&gt; ... 現在のブランチと&lt;branch&gt;をマージ (git pull . &lt;branch&gt;)
</code></pre>

<h4>git rm</h4>

<pre><code>git rm --cached ... キャッシュの中からのみ取り除く(間違えてaddした場合など)
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.2310.net/archives/540/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>sqliteドライバ組込み済「ちいたん」</title>
		<link>http://blog.2310.net/archives/529</link>
		<comments>http://blog.2310.net/archives/529#comments</comments>
		<pubDate>Sat, 11 Apr 2009 11:28:18 +0000</pubDate>
		<dc:creator>2310</dc:creator>
				<category><![CDATA[uncategorized]]></category>

		<guid isPermaLink="false">http://blog.2310.net/?p=529</guid>
		<description><![CDATA[ちいたんにsqlite用ドライバを組み込んだものを置いておきます。ライセンスなどはちいたんに従います。

sqliteドライバ組込み済「ちいたん」(tar.gz形式 約8.14KB)
]]></description>
			<content:encoded><![CDATA[<p><a href="http://php.cheetan.net/" title="PHP軽量フレームワーク ちいたん">ちいたん</a>に<a href="http://cgi4.osk.3web.ne.jp/~nisitatu/wiki/wiki.cgi?p=Cheetan#p7">sqlite用ドライバ</a>を組み込んだものを置いておきます。ライセンスなどは<a href="http://php.cheetan.net/" title="PHP軽量フレームワーク ちいたん">ちいたん</a>に従います。</p>

<p><a href="http://blog.2310.net/my-store/download/cheetan0.8.0.8_sqlite.tar.gz" title="sqliteドライバ組込み済「ちいたん」のダウンロード">sqliteドライバ組込み済「ちいたん」</a>(tar.gz形式 約8.14KB)</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.2310.net/archives/529/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
