query: tag:gist

Gist
はちょっとしたコードの切れ端を貼付けておくのに便利です。
先日紹介したEndless RubyのコードもGist上でのみ公開されていました。
Gemを作るまでもないコードをGistに貼付けて、そのままrequireして使えると便利そうだと思ったので、試してみました。

ruby>>
module Gist
module_function
def require(id, sha1 = "HEAD")
Kernel.require "open-uri"
gist = "http://gist.github.com"
eval(if sha1 == "HEAD"
open("#{gist}/#{id}.txt").read
else
Kernel.require "tmpdir"
cache = File.join(Dir.tmpdir, "gist-#{id}-#{sha1}")
if File.exist?(cache)
open(cache).read
else
open("#{gist}/raw/#{id}/#{sha1}") do |i|
code = i.read
open(cache, "w"){|o| o.write code}
code
end
end
end)
end
end

Gist.require("148479", "a59ea9ec3e865bafd1e4413b43b6ccb7a38d76fc")
#=> Hello, world!
<<--

Hash値で内容の変更が検出可能なので、md5のチェックサムを信用している人にとっては同程度の安全性で利用できそうです。

posted by genki genki on Thu 16 Jul 2009 at 16:57 with 0 comments
Today, I added the feature mentioned in the title above to [the Gist Ubiquitifier](http://ubiquity.s21g.com/).
Gist Ubiquitifier
Uploaded with plasq's Skitch!
Obviously, it lacks title of the commands. This spec came from our purpose of providing transparent service to make pages for installing ubiquity commands. But it might be provided in the future.
posted by takiuchi takiuchi on Tue 16 Sep 2008 at 21:36 with 0 comments

Gist
がUbiquityコマンドのインストールに対応してくれたので、
Gist Ubiquitiferの役目は終わったかなと思ったのですが、
ダウンロード数やPV、Ratingなんかがわかると嬉しいかもしれない、ということで、ちょっとだけ機能追加してみました。

Sample Page

GistもそこまでUbiquity専用に機能追加するとも思えないので、
Ubiquity専用サービスである利点を生かしてみました。

そのうち評判が高い順のリストを表示するようにしようかと思います。

posted by genki genki on Mon 8 Sep 2008 at 09:59 with 0 comments

Gist Ubiquitifierは、
Ubiquityコマンドを配布するためのサーバが無くても、
気軽にUbiquityコマンドを配布できるようにするためのサービスです。

このたび、拡張パラメータを指定することによって、
コマンドのインストールページをカスタマイズできるようになりました。

例えば、以下のように、QueryStringにパラメータを指定します。

http://ubiquity.s21g.com/7630?name=s21g-blog-search&Author=Genki+Takiuchi&Home+Page=http://blog.s21g.com/genki

name以外のパラメータは、インストールページ上で
表示されるだけで、実際のインストールの動作には影響しません。

posted by genki genki on Sun 7 Sep 2008 at 07:33 with 0 comments

やっつけで作ってみました。

Gist Ubiquitifier

Gist上のJavaScriptコードをUbiquityコマンド化してインストール可能にするサービスです。これを利用することで、Ubiquityコマンドインストール用のHTMLファイルを設置するサーバを持っていない場合でも、
コマンドを公開することができます。

USAGE:

まずは、Gist上でUbiquityコマンドをJavaScriptで登録します。
例えば、Gist上のURIが

http://gist.github.com/7630

の場合、

http://ubiquity.s21g.com/7630

がインストールページなります。
コマンド名は、nameパラメータで指定できます。

http://ubiquity.s21g.com/7630?name=s21g-blog-search

使えそうであれば、もうちょっとちゃんとしたデザインにしようと思います。

posted by genki genki on Thu 28 Aug 2008 at 13:40 with 0 comments