Gosuke Miyashita

Vimeo Tag Plugin

| Comments

Black Hole Sun - Astronomic Landscape and Milky Way TimeLapse from Christoph Malin on Vimeo.

A Liquid tag for Jekyll sites that allows embedding vimeo movies (vimeo_tag.rb) download
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# A Liquid tag for Jekyll sites that allows embedding vimeo movies
# by: Gosuke Miyashita
#
# Example usage: {% vimeo 28040685 800 600 %}

require 'open-uri'
require 'multi_json'

module Jekyll
  class VimeoTag < Liquid::Tag
    def initialize(tag_name, text, token)
      super
      @text = text
      @cache_dir = File.expand_path "../.vimeo-cache", File.dirname(__FILE__)
      FileUtils.mkdir_p @cache_dir
    end

    def render(context)
      if parts = @text.match(/(\d+) (\d+) (\d+)/)
        id, width, height = parts[1].strip, parts[2].strip, parts[3].strip
      end

      vimeo = get_vimeo(id)
      <<-HTML
<iframe src="http://player.vimeo.com/video/#{id}?color=ffffff" width="#{width}" height="#{height}" frameborder="0" webkitAllowFullScreen allowFullScreen></iframe><p><a href="http://vimeo.com/#{id}">#{vimeo["title"]}</a> from <a href="#{vimeo["author_url"]}">#{vimeo["author_name"]}</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
      HTML
    end

    def get_vimeo(id)
      cache_file = File.join @cache_dir, id
      if File.exist? cache_file
        MultiJson.decode(File.read cache_file)
      else
        json = open("http://vimeo.com/api/oembed.json?url=http%3A//vimeo.com/#{id}").read
        File.open(cache_file, "w") do |io|
          io.write json
        end
        MultiJson.decode(json)
      end
    end

  end
end

Liquid::Template.register_tag('vimeo', Jekyll::VimeoTag)

Typo to Octopress

| Comments

I’ve moved my Typo blog contents to this octopress blog.

For this purpose I made this tiny script.

自宅サーバが死にました

| Comments

10年ぐらい稼働していた mizzy.org の自宅サーバが死にました。(四男がコンセントぶち抜いたら起動してこなくなった。)

メールの方は Google Apps に移行したんですが、ブログはどうしようかなー、できれば GitHub でファイル管理したいなー、と思ってたところに、@mattn_jp さんのタイムリーなエントリ が。

とても良さそうなので、しばらくこれで運用してみます。

過去エントリについては、Trac に入ってた分ぐらいは移行しようかな、と考えてます。

My Resume

| Comments

Educations

  • Hokkaido University (1993-1997)
    • Department of Economics
      • Operations Research
      • Linear Programming
      • Multivariable Analysis
      • A theme of graduation thesis is “Analyze NBA Players ablility with Multivariable Analysis”

Jobs

  • CTC
    • 1997-
      • Netscape Server Software Products Engineer
        • Netscape Enterprise Server (Web Server)
        • Netscape Messaging Server (Mail Server)
        • Netscape Directory Server (LDAP Server)
        • and so on
    • 1998-
      • Support Engineer of Netscape Server Software Products at Netscape Japan
    • 1999-2000
      • QA of I18N Netscpe Server Software Products at Netscape US
      • Working at Mountain View
      • Lining in Sunnyvale
    • 2000-2005
      • iPlanet(formerly known as Netscape) Server Software Products Engineer at CTC again.

  • Netmarks
    • 2005-
      • Testing Network Quarantine Systems
        • It is for blocking insecure computers automatically.

  • paperboy&co. (Now)
    • 2006-
      • Software Engineer
      • JugemKey (http://jugemkey.jp/)
        • Central authorization system for multiple services in paperboy&co.
        • Write backend API with Perl
      • JugemKey Authentication API
        • Similar to Flickr authentication API
        • Write frontend with PHP and backend with Perl
      • JUGEM (http://jugem.jp/)
        • Blog service
        • Write accounting function by credit cards with PHP
    • 2007-
      • Technical Manager
      • 30days Album (http://30d.jp/)
        • A photo Album Service
        • In charge of overall architect design
        • Write some Perlbal plugins
        • Write frontend API for MogileFS
          • Perl + Catalyst
        • Other technology stacks
          • Linux, Ruby On Rails, lighttpd, Gearman, TheSchwartz
      • Lolipop Rental Server (http://lolipop.jp/)
        • A plain old style rental servers
        • In charge of overall architect design in system renewal
        • Designed Internal API and implemented a proto type
        • Other technology stacks
          • Linux, Cobbler, LVS, Apache, MySQL, Postfix, qpsmtpd, Courier-IMAP, ClamAV, Puppet, Func
      • Improve development environments in the company
        • Introduce Subversion and Trac
        • Recently introduce Git and Jenkins CI
        • Now writing original internal cloud tool

Talks


Others

  • I4PC (Instagram for PC)
    • http://www.i4pc.jp/
  • CPAN
    • http://search.cpan.org/~mizzy/
  • GitHub
    • https://github.com/mizzy
  • codewall
    • http://coderwall.com/mizzy
  • twitter
    • http://twitter.com/gosukenator
  • Facebook
    • http://www.facebook.com/gosukenator
  • SlideShare
    • http://www.slideshare.net/mizzy/presentations
  • Articles about Puppet in gihyo.jp (Japanese)
    • http://gihyo.jp/admin/serial/01/puppet
  • Articles about Puppet in Software Design magazine (Japanese)
    • http://gihyo.jp/magazine/SD/archive/2007/200712
  • Interview articles (Japanese)
    • http://japan.cnet.com/extra/paperboy_0907/story/0,3800098768,20394957,00.htm
    • http://web-engineer.buyuden.net/buyuden/2010/01/39paperboyco.html
    • http://jibun.atmarkit.co.jp/lcom01/rensai/comrade04/comrade01.html
  • LinkedIn
    • http://www.linkedin.com/in/mizzy
  • Personal sites
    • http://mizzy.org/
    • http://astralscape.tumblr.com/

mailto: gosukenator at gmail.com

SSLCertOfLolipop

| Comments

FFFTP開発終了で大騒ぎしている人たちへ にて、

SSL証明書がまともなものでないと接続時にエラーが出るのですが、ロリポップなんかだと
このエラーを無視するように公式ドキュメントに書いてあるので、かなり悪質です。

と書かれていますので、これについて説明させて頂きます。

この方が指摘されているのは、Win FileZillaの設定 / ホームページ / マニュアル - ロリポップ! (FileZilla非推奨のため現在は削除されています)の中の、

 証明書の確認を行います。『今後もこの証明書を常に信用する(A)』にチェックを入れて、『OK』をクリックします。

という部分だと思われるのですが、確かに、無条件で信用するにチェックを入れるようお客様に指示するのは大変良くないですね。

ロリポップでは DigiCert Inc社 によって発行されている証明書を利用しているのですが、Filezillaでは警告が出てしまうようです。

調べてみたところ、FilezillaはルートCAの証明書を保持しておらず、どのような証明書であっても、ユーザが「信用する」にチェックを入れなければ警告が出る仕様となっているようです。

how to install root CA certificate on Filezilla

OR6 blog 様のご指摘により、このような証明書の検証をきちんと行っていないソフトウェアをお客様に推奨すべきではないと判断いたしましたので、Windows/Mac版ともに存在し、証明書の検証をきちんと行っている Cyberduck を推奨するよう、マニュアルを変更させて頂くことになりました。

また、蛇足ですが、ロリポップの チカッパプラン では SSH サービスを提供していますので、FTPS の代わりに SCP/SFTP もご利用頂けます。

OR6 blog 様、この度はご指摘誠にありがとうございました。

MaglicaInternalCloudTool

| Comments

Overview

Maglica is a Python library and command-line tool for an internal cloud. (This tool is very primitive beta now.)

This is very simple and based on libvirt, virt-clone and zeromq (for RPC).

The name “Maglica” is derived from a Bosnian word that means “Nebula.”

I’m developing this tool because other internal cloud tools(CloudStack, OpenStack, Eucalyptus and so on) are so complicated for internal use.I need a simple tool.


Architecture of Maglica

Maglica has four components.

  1. Library
  2. CLI
  3. Client worker
  4. Host workers

Maglica library is a main component of Maglica.Maglica CLI calls the library to do the jobs.The library talks to libvirtd on other hosts directly to get virtual machines information.

Maglica client worker is running on the same host on which CLI runs. Client worker binds zeromq PUB socket to tcp://:5555 and REP socket to tcp://:5556.

Client worker recieves requests from library through REP socket and throws request to host workers through PUB socket.Also REP socket recives job results from host workers.

Host workers are running on hosts which virtual machines are running on.

Host workers connect to the PUB socket of a client worker to receive job requests and the REP socket of a client worker to throw job results.

[[Image(http://mizzy.org/img/maglica_architecture.jpg)]]


How to use Maglica

You must setup libvirtd running on host machines and accessible through tcp port. (See http://libvirt.org/remote.html)

Clone Maglica on a host machine and run the host worker.

# git clone git://github.com/mizzy/maglica.git
# cd maglica
# cp etc/maglica.conf.example etc/maglica.conf

Edit etc/maglica.conf that points to the correct client worker host and port.

# ./scripts/maglica_host_worker

Clone Maglica on a client machine.

# git clone git://github.com/mizzy/maglica.git
# cd maglica
# cp etc/maglica.conf.example etc/maglica.conf

Edit etc/maglica.conf that points to host machines.

Run the client worker.

# ./scripts/maglica_client_worker

Run maglica command to list up “original images”(which name is end with the string “oroginal”).

# PYTHONPATH=. ./scripts/maglica image list
Name                                     Host
---------------------------------------------------------
SL6.0-x86_64.original                    host0.example.jp  
SL6.1-x86_64.original                    host0.example.jp  
SL6.0-x86_64.original                    host1.example.jp  
SL6.1-x86_64.original                    host1.example.jp  

Run maclica command to clone a virtual machine image.

# ./scripts/maglica vm clone --image=SL6.1-x86_64.original --hostname=vm0.example.jp

This command clones the image on a host and rewrites network setting of the image with libguestfs.

HowToGetGraphiteWorkingOnScientificLinux6

| Comments

I found a interest tool, Graphite when I was exploring https://github.com/etsy .(Screen Shots of Graphite.)

Install Carbon

Carbon is a backend storage application for Graphite.

# wget http://launchpad.net/graphite/1.0/0.9.8/+download/carbon-0.9.8.tar.gz
# tar zxvf carbon-0.9.8.tar.gz
# pushd carbon-0.9.8
# python setup.py install
# popd

Install Whisper

Whisper is an alternate to RRD.

# wget http://launchpad.net/graphite/1.0/0.9.8/+download/whisper-0.9.8.tar.gz
# tar zxvf whisper-0.9.8.tar.gz
# pushd whisper-0.9.8
# python setup.py install
# popd

Install Graphite

# wget http://launchpad.net/graphite/1.0/0.9.8/+download/graphite-web-0.9.8.tar.gz
# tar zxvf graphite-web-0.9.8.tar.gz
# pushd graphite-web-0.9.8      

Run check-dependencies.py.

# ./check-dependencies.py 
[FATAL] Unable to import the 'cairo' module, do you have pycairo installed for python 2.6.5?
[FATAL] Unable to import the 'django' module, do you have Django installed for python 2.6.5?
[WARNING] Unable to import the 'mod_python' module, do you have mod_python installed for python 2.6.5?
This means you will only be able to run graphite in the development server mode, which is not
recommended for production use.
[WARNING]
Unable to import the 'memcache' module, do you have python-memcached installed for python 2.6.5?
This feature is not required but greatly improves performance.

[WARNING]
Unable to import the 'ldap' module, do you have python-ldap installed for python 2.6.5?
Without python-ldap, you will not be able to use LDAP authentication in the graphite webapp.

[WARNING]
Unable to import the 'twisted' package, do you have Twisted installed for python 2.6.5?
Without Twisted, you cannot run carbon on this server.
[WARNING]
Unable to import the 'txamqp' module, this is required if you want to use AMQP.
Note that txamqp requires python 2.5 or greater.
2 necessary dependencies not met. Graphite will not function until these dependencies are fulfilled.
5 optional dependencies not met. Please consider the warning messages before proceeding.

I use a development server included in Graphite, so mod_python is not needed.

Install packages other than mod_python.

# yum install pycairo
# rpm -ivh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-5.noarch.rpm
# yum install Django python-twisted python-memcached python-ldap
# yum install python-setuptools gcc python-devel
# easy_install txamqp

You need bitmap fonts, so intall it.

# yum install bitmap-console-fonts

Install Graphite and setup it.

# python setup.py install
# python /opt/graphite/webapp/graphite/manage.py syncdb
# pushd /opt/graphite/conf
# cp carbon.conf.example carbon.conf
# cp storage-schemas.conf.example storage-schemas.conf
# cp dashboard.conf.example dashboard.conf

Edit dashborad.conf and uncomment these.

[ui]
default_graph_width = 400
default_graph_height = 250
automatic_variants = true
refresh_interval = 60

Start Carbon.

# /opt/graphite/bin/carbon-cache.py start

Start example-client included in Graphite source code to send load average data to Carbon.

# popd
# python ./examples/example-client.py

Start a develepment server of Graphite.

# /opt/graphite/bin/run-graphite-devel-server.py /opt/graphite  

Access to port 8080 of this server and you’ll see the screen of Graphite.

HowDotCloudLazyCopyImplementsCopyOnWrite

| Comments

dotcloud/lazycopy is a copy-on-write version of cp.It’s based on aufs.

Scientific Linux 5 has aufs rpm on its base repo.So I tried aufs and lazycopy on SL5.CentOS and SL6 don’t have aufs rpm.

I created source directories and files in them first.

# mkdir /tmp/source0
# mkdir /tmp/source1
# mkdir /tmp/source2
# echo source0 > /tmp/source0/0
# echo source1 > /tmp/source1/1
# echo source2 > /tmp/source2/2

And copied these directories to /tmp/dest with lazycopy command.

# lazycopy /tmp/source0 /tmp/source1 /tmp/source2 /tmp/dest
['/tmp/source0', '/tmp/source1', '/tmp/source2'] -> /tmp/dest

Confirmed that three files wiere there and the content of one of the files.

# ls /tmp/dest/
0  1  2
# cat /tmp/dest/0
source0

Changed the content of /tmp/dest/0 and confirmed that /tmp/source0/0 was not changed.

# echo dest > /tmp/dest/0 
# cat /tmp/dest/0 
dest
# cat /tmp/source0/0 
source0

Lazycopy implements copy-on-write by mounting directories with aufs like this.

# mount
...
none on /tmp/dest type aufs (rw,br:/tmp/dest/.aufs/0=rw:/tmp/source0=ro:/tmp/source1=ro:/tmp/source2=ro)

Lazycopy creates .aufs/0 directory in the destination directory if it doesn’t exist and mounts it with rw mode as one of the aufs branch.Other source directories are mounted with ro mode, so files in these directories will not be changed.

Changed files and newly created files are saved under /tmp/dest/.aufs/0 directory.So you can see the directory structures like this after unmounting /tmp/dest.

# touch /tmp/dest/3
# umount /tmp/dest
# tree -a /tmp/dest
/tmp/dest
`-- .aufs
    `-- 0
        |-- .wh..wh..tmp
        |-- .wh..wh.aufs
        |-- .wh..wh.plnk
        |-- 0
        `-- 3

So if you unmount /tmp/dest directory and run lazycopy with same options again, you can see the changed files and created files again.