Amazonアフィリエイトのテスト
アフィリエイトを試してみました。
どうかな。
ブラウザ上で選択したテキストを「英辞郎 on the WEB」で検索するブックマークレット
英語の文章を読むときに便利。
以下のブラウザで動作確認済み
- Chrom
- IE9
セッター呼び出しソースを出力するRuby
s =<<'EOS'
aaa あああ
bbb いいい
EOSs.each_line do |e|
e.chomp!
sp = e.split("\t")
n = sp[0]
n = n[0..0].upcase + n[1..n.size]
v = sp[1]
puts "set#{n}(#{v});" #=> setAaa(あああ);
end
なぜかインデントが正しく表示されないorz
SPACE ALCで検索するブックマークレット
javascript:var s = window.getSelection(); if (!s || s == '') {s = prompt('Input word.');} void(window.open('http://eow.alc.co.jp/' + s));
Apache SSL Setting
Ubuntu10.04 Netbook Edition でSSLサーバ(apache2.2.14)を立てたときの覚書。
インストール
$apt-get intall apache2
設定ファイル
$/etc/apache2/
コマンド
$/etc/init.d/apache2 {start|stop|restart|reload|force-reload|start-htcacheclean|stop-htcacheclean|status}
モジュールの追加
$a2enmod ssl
SSL
俺々証明書作成
$make-ssl-cert /usr/share/ssl-cert/ssleay.cnf /path/to/cert-file.crt
この辺のことは/usr/share/doc/apache2/README.Debian.gzに書いている。
$zless /usr/share/doc/apache2/README.Debian.gz
haru-sさん感謝HTTPS接続のための証明書作成方法(Apache2 + SSL) - Debian [Lenny] - ...ing logging 4.0
/etc/apache2/sites-enabled/default-sslに証明書を設定
SSLCertificateFile /path/to/cert-file.crt
Basic認証の設定は本家サイトを参照http://httpd.apache.org/docs/2.2/ja/howto/auth.html
ルータ設定
Mizushimaさん感謝http://mizushima.ne.jp/Windows/port/CTU/premium.php
大体こんな感じ、だったはず。
apache2の設定は、色々情報があふれているけど、環境やバージョンの違いのせいだと思うけど、結局は、/usr/share/doc/apache2配下のドキュメントが役に立った。
VB.NET 複数のExcelファイルのシートをコピーして、1つのファイルにまとめるサンプルソース
会社の後輩へ向けたサンプルソースです。
バグが入っていませんように(-人-)
Imports Microsoft.Office.Interop Imports System.IO Public Class ExcelSheetMerge #Region "複数のExcelファイルにあるシートを1つのExcelファイルにまとめる" Public Shared Sub CreateMergedFile(ByRef filePath() As String, ByRef savePath As String) Dim xlApp As Excel.Application = Nothing Dim xlBooks As Excel.Workbooks = Nothing Dim xlTargetBook As Excel.Workbook = Nothing Dim xlTargetSheets As Excel.Sheets = Nothing Dim xlTargetTailSheet As Excel.Worksheet = Nothing Try ' Excelアプリケーション起動 xlApp = New Excel.Application() xlBooks = xlApp.Workbooks ' Excel終了時にダイアログを表示しないように設定 xlApp.DisplayAlerts = False ' マージ先のワークブックを作成 ' テンプレートを指定することでデフォルトで存在するシートを1つにする。 xlTargetBook = xlBooks.Add(Excel.XlWBATemplate.xlWBATWorksheet) xlTargetSheets = xlTargetBook.Sheets ' シートを末尾に追加していくため、最後のシートを取得 xlTargetTailSheet = DirectCast(xlTargetSheets("Sheet1"), Excel.Worksheet) For Each aFilePath As String In filePath Dim xlSourceBook As Excel.Workbook = Nothing Dim xlSourceSheets As Excel.Sheets = Nothing Try ' シートのコピー元のブックを開く xlSourceBook = xlBooks.Open(aFilePath, UpdateLinks:=False) xlSourceSheets = xlSourceBook.Sheets ' 各シートをマージ先にコピーする xlSourceSheets.Copy(After:=xlTargetTailSheet) Util.MRComObject(DirectCast(xlTargetTailSheet, Object)) xlTargetTailSheet = DirectCast(xlTargetSheets(xlTargetSheets.Count), Excel.Worksheet) Finally If Not xlSourceSheets Is Nothing Then Util.MRComObject(DirectCast(xlSourceSheets, Object)) End If If Not xlSourceBook Is Nothing Then xlSourceBook.Close(SaveChanges:=False) Util.MRComObject(DirectCast(xlSourceBook, Object)) End If End Try Next ' シートのコピー開始前から存在するデフォルトのシート「Sheet1」を削除する。 Dim xlSheet1 As Excel.Worksheet = Nothing Try xlSheet1 = DirectCast(xlTargetSheets("Sheet1"), Excel.Worksheet) xlSheet1.Delete() Finally If Not xlSheet1 Is Nothing Then Util.MRComObject(DirectCast(xlSheet1, Object)) End If End Try ' マージしたExcelファイルを保存 xlTargetBook.SaveAs(Filename:=savePath) Finally If Not xlTargetTailSheet Is Nothing Then Util.MRComObject(DirectCast(xlTargetTailSheet, Object)) End If If Not xlTargetSheets Is Nothing Then Util.MRComObject(DirectCast(xlTargetSheets, Object)) End If If Not xlTargetBook Is Nothing Then xlTargetBook.Close() Util.MRComObject(DirectCast(xlTargetBook, Object)) End If If Not xlBooks Is Nothing Then Util.MRComObject(DirectCast(xlBooks, Object)) End If If Not xlApp Is Nothing Then xlApp.Quit() xlApp.DisplayAlerts = True Util.MRComObject(DirectCast(xlApp, Object)) End If End Try End Sub #End Region End Class