腦袋空空,只記得麗卿依照慣例又滑了一跤,阿們!感覺上比前次去四陵溫泉輕鬆許多。
- 4月 05 週二 200522:08
神仙縱走
- 2月 25 週五 200519:35
OpenSSL憑證製作
mkdir demoCA mkdir demoCA/certs mkdir demoCA/crls mkdir demoCA/newcerts mkdir demoCA/private touch demoCA/index.txt echo 01 > demoCA/serial # generate private key openssl genrsa -out demoCA/private/cakey.pem 2048 # generate certificate signing request openssl req -new -key demoCA/private/cakey.pem -out cacsr.pem # generate self-signed certificate openssl req -in cacsr.pem -out cacert.pem -key demoCA/private/cakey.pem -x509 -days 3652 # generate certificate revocation list openssl ca -gencrl -out demoCA/crl.pem # convert certificate to DER format openssl x509 -in demoCA/cacert.pem -inform PEM -out emoCA/cacert.der -outform DER # convert to pkcs12 format openssl pkcs12 -export -in demoCA/cacert.pem -inkey emoCA/private/cakey.pem -out cert.p12 -name "Forth Root CA" # generate certificate signing request openssl req -new -key mykey.pem -out mycsr.pem # generate cretificate openssl ca -in mycsr.pem -out mycert.pem -days 3652 -policy policy_anything
- 1月 15 週六 200519:34
安裝mod_auth_pam2和FreeRADIUS
首先,安裝mod_auth_pam和FreeRADIUS:
cd /usr/ports/www/mod_auth_pam2; make install clean cd /usr/ports/net/freeradius; make install clean /etc/rc.conf: radiusd_enable="YES" /etc/radius.conf: auth localhost testing123
將下列設定加入httpd.conf中欲使用身分驗證的<Directory>或<Location>:
AuthPAM_Enabled on AuthType Basic AuthName "Secured Area" Require valid-user /usr/local/etc/pam.d/httpd: auth required pam_radius.so account required pam_permit.so
- 1月 14 週五 200519:32
安裝DSPAM
安裝選項取消SQLITE2,改用POSTGRESQL74,編譯、安裝後執行:
chmod o+x /usr/local/bin/dspam
讓大家都能執行dspam(好孩子不要學:-)。接著建立資料庫,pgsql_objects.sql是用smallint,一下就爆炸了,所以改成int:
createdb -E SQL_ASCII dspam cat /usr/local/share/examples/dspam/pgsql/pgsql_objects.sql | sed "s/smallint/int/" | psql dspam
再修改相關設定檔。
- 12月 02 週四 200419:31
Canon 20D入手
除了20D機身,還購入三顆鏡頭,分別是:16-35mm F2.8L、50mm F1.8、100mm F2.8 MACRO,總共是116,500元。
- 2月 01 週日 200419:29
TaipeiLink Photo Grabber
This is my first Ruby script to fetch photos from TaipeiLink.
#!/usr/local/bin/ruby require "net/http"if ARGV.length == 0 puts "tplink.rb <account>" exit end
ARGV.delete("tplink.rb") ARGV.each { |account| puts "Fetching photos from #{account}..." Dir.mkdir(account) if !FileTest.exist?(account) Net::HTTP.start("photo.taipeilink.net", 80) { |http| http.get("/#{account}").body.scan(/<a href="http://photo.taipeilink.net/#{account}?st=album&pg=(d*)"/) { |pg| Dir.mkdir("#{account}/#{pg}") if !FileTest.exist?("#{account}/#{pg}") http.get("/#{account}?st=album&pg=#{pg}").body.scan(/<a href="http://photo.taipeilink.net/#{account}/(d*-d*-d*-d*)?m=0&pg=(d*)"/) { |fileName, pg| url = "/#{account}/#{fileName}?m=1&pg=#{pg}" response = http.head(url) if response["content-type"] == "image/gif" fileName += ".gif" else fileName += ".jpg" end fileName = "#{account}/#{pg}/#{fileName}" if FileTest.exist?(fileName) puts "Skip #{fileName}" else puts "Fetch #{fileName}" response = http.get(url) file = File.new(fileName, "w") file.write(response.body) file.close() end } } } }
- 9月 07 週日 200319:28
WorkQueue
public class WorkQueue { private final int nThreads; private final PoolWorker[] threads; private final LinkedList queue; public WorkQueue(int nThreads) { this.nThreads = nThreads; queue = new LinkedList(); threads = new PoolWorker[nThreads]; for (int i=0; i < nThreads; i++) { threads[i] = new PoolWorker(); threads[i].start(); } } public void execute(Runnable r) { synchronized(queue) { queue.addLast(r); queue.notify(); } } private class PoolWorker extends Thread { public void run() { Runnable r; while (true) { synchronized(queue) { while (queue.isEmpty()) { try { queue.wait(); } catch (InterruptedException ignored) { } } r = (Runnable) queue.removeFirst(); } // If we don't catch RuntimeException, // the pool could leak threads try { r.run(); } catch (RuntimeException e) { // You might want to log something here } } } } }- 10月 21 週日 200119:27
PostgreSQL的cursor用法
PreparedStatement l_stmt = null; PreparedStatement l_stmtFetch = null; PreparedStatement l_stmtClose = null; ResultSet l_rset = null; try { //exception try { //finally //open the cursor l_stmt = m_dbcon.prepareStatement("DECLARE FOO CURSOR FOR SELECT BAR FROM FOOBAR"); l_stmt.execute(); l_stmtFetch = m_dbcon.prepareStatement("FETCH FORWARD 10 FROM FOO"); while (true) { //perform a fetch from the cursor (possibly multiple fetches will be done) l_rset = l_stmtFetch.executeQuery(); l_rows = 0; while (l_rset.next()) { String l_bar = l_rset.getString(1); //do something useful with the data l_rows++; } l_rset.close(); l_rset = null; if (l_rows == 0) { //no more rows, so we are done break; } } //don't forget to close the cursor l_stmtClose = m_dbcon.prepareStatement("CLOSE FOO"); l_stmtClose.execute(); } finally { if (l_rset != null) { l_rset.close(); } if (l_stmt != null) { l_stmt.close(); } if (l_stmtFetch != null) { l_stmtFetch.close(); } if (l_stmtClose != null) { l_stmtClose.close(); } } } catch (SQLException l_se) { //do something useful here }- 10月 15 週一 200119:25
安裝PostgreSQL 7.2
您可以從PostgreSQL網站下載最新的版本,目前是7.2版。下載後,建立一個叫postgres 的使用者,然後建立/usr/local/pgsql目錄,並將擁有者設為postgres,再將/usr/local/pgsql/bin加入postgres的PATH,再以postgres身分進行安裝。如果不要編譯JDBC driver的話可以不用--with-java,JDBC driver可以由jdbc.postgresql.org下載。
$ cd /tmp $ tar xzf postgresql.7.2.tar.gz $ cd /tmp/postgresql-7.2 $ ./configure --enable-locale --enable-multibyte --enable-nls --with-java $ make all install $ setenv PGDATA /usr/local/pgsql/data $ setenv PGLIB /usr/local/pgsql/lib $ setenv LD_LIBRARY_PATH /usr/local/pgsql/lib $ initdb $ postmaster -i & $ createdb -E UNICODE dbname