平衡点


2006/07/26

_ セミナ二日目

惑星科学フロンティアセミナ二日目です.

Habitable Condition:ある一瞬に惑星上で生命が生きられる条件
Continuously habitable Condition:ある程度長期間にわたって惑星上に生命が生きられる条件

って事で, Habitable Planet な話です.

今回のセミナでは Habitable Planet = 水の惑星, となってます.

Komabayashi-Ingersol 限界のココロがようやく把めた, 気がする.

_ Rails Migration その 2

どうも foreign key を追加するには, foreign key module が必要みたい. rails 本体にはそのうち組み込まれるんだろうけど.

メモφ(._.)


2014/07/26

_ Conky用のbiffスクリプト

普段はofflineimapでメールを同期し、localhostでdovecot-imapd上げてメールを読んでいる.

折角手元にIMAPサーバがあるのだから、

  • Conkyで未読メール数を表示させる
  • IMAP IDLEに対応する

といった事をやりたくなった.

...のででっち上げてみた.

# source: ruby
#! /usr/bin/env ruby
# -*- coding: utf-8 -*-
# Copyright 2014 Youhei SASAKI <uwabami@gfd-dennou.org>
#
# License: MIT/X11 @see http://opensource.org/licenses/mit-license.php
#
require 'yaml'
require 'net/imap'

$config = YAML.load_file(File.expand_path(File.dirname(__FILE__))+ '/config.yaml')

def openConnection()
  imap = Net::IMAP.new($config['server'], $config['port'], $config['ssl'], $config['certs'])
  imap.login($config['username'], $config['password'])
  imap.select($config['folder'])
  return imap
end

def checkMailbox(imap)
  status  = imap.status($config['folder'], ['UNSEEN','MESSAGES'])
  num_total  = status['MESSAGES']
  num_unseen = status['UNSEEN']
  File.open($config['notifyfile'], "w+"){|f|
    f.puts num_unseen.to_s+ "/" + num_total.to_s
  }
end

# first connection
imap = openConnection()
# update notifyFile
checkMailbox(imap)
# run imap idle
imap.idle do |res|
  begin
    if res.kind_of?(Net::IMAP::UntaggedResponse) and ['EXISTS', 'EXPUNGE', 'FETCH'].include? res.name
      # なんか馬鹿らしいけれど. response から UNSEEN, MESSAGES 取れないかなぁ...。
      checker = openConnection()
      checkMailbox(checker)
      checker.logout
      checker.disconnect
    end
  rescue Exception => err
    puts err
    imap.idle_done
  end
end

設定ファイルはこんな感じ

# source: yaml
server: SERVERNAME
port: PORTNUMBER
ssl: TRUE or FALSE
certs: LOCATION OF CERTIFICATES FILE
username: YOUR USERNAME
password: IMAP PASSWORD
folder: MAILBOX NAME(e.g. INBOX)
notifyfile: OUTPUT FILE FOR CONKY

これを ~/.conky に転がして、パーミッションを適宜調整しておく. あとは ~/.config/autostart あたりに適当なファイル名で

# source: conf
[Desktop Entry]
Type=Application
Exec=/home/uwabami/.conky/mail-checker.rb
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
Name=Mail checker use IMAP idle for conky
Comment=Mail checker use IMAP idle for conky, need Ruby >= 1.9.3

なんてしておいて, conky の設定ファイル内では ファイルの中身を cat しておく.

(2014/07/28) checker が無限増殖していたので, disconnect を追加


2018/07/26

_ dnsmasq での問い合わせ先の変更

某所に VPN で接続した際に, 接続先の DNS の反応が遅いせいで名前解決ができず, ネットワークアクセスで困る事が頻発していて, これどうにかならんのか, と.

とか言うてた訳ですが.

手元での名前解決には dnsmasq を使っていたので, dnsmasq.conf あたりに

server=/hoge.hero.fuga.ac.jp/8.8.8.8

みたいに書いておくと hoge.hero.fuga.ac.jp の名前解決の際には 8.8.8.8 を使ってくれるようになるようだ(当然 IP はダミーです, はい).

More specific domains take precedence over less specific domains, so:
--server=/google.com/1.2.3.4   --server=/www.google.com/2.3.4.5  will
send queries for *.google.com  to  1.2.3.4,  except  *www.google.com,
which will go to 2.3.4.5

The  special server address &#39;#&#39; means, "use the standard servers", so
--server=/google.com/1.2.3.4  --server=/www.google.com/#  will   send
queries  for  *.google.com  to  1.2.3.4, except *www.google.com which
will be forwarded as usual.

man にありました. これで快適快適.


連絡先など
最近の日記
一覧
2006|03|04|05|06|07|08|09|10|11|12|
2007|01|02|03|04|05|06|07|08|09|10|11|12|
2008|01|02|03|04|05|06|07|08|09|10|11|12|
2009|01|02|03|04|05|06|07|08|09|10|11|12|
2010|01|02|03|04|05|06|07|08|09|10|11|12|
2011|01|02|03|04|05|06|07|08|09|10|11|12|
2012|02|03|04|08|09|10|11|12|
2013|01|02|03|04|05|06|08|09|10|11|12|
2014|01|02|04|05|06|07|08|09|10|11|12|
2015|01|02|03|04|05|06|07|09|10|
2016|02|03|
2017|01|02|03|05|06|07|09|11|12|
2018|03|06|07|10|11|12|
2019|01|02|03|04|05|07|10|12|
2020|01|02|03|04|05|08|09|10|11|12|
2021|01|02|03|05|06|07|08|09|11|12|
2022|01|02|03|04|05|06|08|10|11|12|
2023|02|03|04|06|08|09|11|12|
2024|01|02|03|
Back to Top ▲