2008年11月10日 星期一

OpenBSD remove all pkg_info packages command

pkg_info -a | awk '{print $1}' | xargs sudo pkg_delete -f


check
/var/db/pkg

OpenBSD解 tar.bz2

setp:

bzip2 -d file.tar.bz2
tar xvf file.tar

2008年7月21日 星期一

安裝Zend framework

安裝Zend framework時httpd.conf要注意的地方.

; Windows: "\path1;\path2"
include_path = ".;c:\php\includes;C:\Apache2.2\htdocs\libary"
AllowOverride All

不然會有找不到hello問題.
http://localhost/html/index/hello

2008年7月17日 星期四

OpenBSD view log wtmp command

command:

strings /var/log/wtmp

2008年7月3日 星期四

PostgreSQL show process list

select * from pg_stat_activity;

2008年5月8日 星期四

起動net-snmp問題

問題
/usr/local/etc/rc.d/snmpd.sh start
Starting snmpd.
/libexec/ld-elf.so.1: Shared object "libperl.so" not found, required by "snmpd"


解決:
ln -s /usr/local/lib/perl5/5.8.8/mach/CORE/libperl.so /usr/lib/libperl.so

2008年4月22日 星期二

從檔案中找出關鍵字指令

從檔案中找出關鍵字指令
find *.html | xargs grep "Python"

find *.html | xargs grep -n "Python"

-n 會顯示找到的行數

2008年3月25日 星期二

啟動PostgreSQL指令

OpenBSD的pygreSQL是要去官網下載:
http://www.pygresql.org/readme.html#where-to-get

The released version of the source code is available at
ftp://ftp.pygresql.org/pub/distrib/PyGreSQL.tgz

>>>
>>> import pg
Traceback (most recent call last):
File "", line 1, in
File "pg.py", line 21, in
from _pg import *
ImportError: Shared object "libpq.so.3" not found, required by "_pg.so"


對於OpenBSD在安裝完PyGreSQL之後, 在import pg時會出現error,是因此找不到 libpq.so.x 只要ln -s之後就ok.
# ln -s /usr/local/pgsql/lib/libpq.so.5.0 /usr/lib/libpq.so.5.0
# ln -s /usr/local/pgsql/lib/libpq.so.5 /usr/lib/libpq.so.5

FreeBSD啟動PostgreSQL指令
/usr/local/pgsql/bin/pg_ctl -D /home/pgdata -l /var/log/pgsql.log start

啟動PostgreSQL指令
/usr/local/pgsql/bin/postgres -D /home/pgdata > /var/log/pgsql.log 2>&1 &

停止
/usr/local/pgsql/bin/pg_ctl -D /home/pgdata stop

改完pg_hba.conf 之後必須reload
reload
/usr/local/pgsql/bin/pg_ctl -D /home/pgdata reload


update user postgres password
alter user postgres with password 'new=password';

----

至於在OpenBSD啟動時出現Error, 需重新build kernel, 參數試著用底下.SYSVSHM, SYSVSEM
http://www.openbsd.org/faq/faq5.html#BldKernel

# cd /usr/src/sys/arch/i386/conf
# config GENERIC
# cd ../compile/GENERIC
# make clean && make depend && make
[...lots of output...]
# make install


http://twpug.net/docs/postgresql-doc-8.0-zh_TW/kernel-resources.html#SYSVIPC

信號燈. 您可能還需要增加信號燈的數量;系統預設的總數 60 只能允許大概 50 個 PostgreSQL 連接。 在內核配置文件裡設置您需要的值,比如:

options "SEMMNI=40"
options "SEMMNS=240"

FreeBSD
NetBSD
OpenBSD
編譯內核時需要把選項 SYSVSHM 和 SYSVSEM打開。 (預設是打開的。)共享內存的最大尺寸是由選項SHMMAXPGS(以頁計)。 下面顯示了一個如何設置這些參數的例子:

options SYSVSHM
options SHMMAXPGS=8196
options SHMSEG=256

options SYSVSEM
options SEMMNI=256
options SEMMNS=512
options SEMMNU=256
options SEMMAP=256
(在 NetBSD 和 OpenBSD裡, 關鍵字實際上是單數的 option)

Fraqtive

Fraqtive

Fraqtive is an open source, multi-platform generator of the Mandelbrot family fractals. It uses very fast algorithms supporting SSE2 and multi-core processors. It generates high quality anti-aliased images. It allows real-time navigation and dynamic generation of the Julia fractal preview.

Fraqtive is available for both Windows and Linux under the GNU General Public License.

http://fraqtive.mimec.org/

Web Console

Web Console

Web Console is a web-based application that allows remote users to execute UNIX/Windows shell commands on a server, upload/download files to/from server, edit text files directly on a server and much more. The application is represented as a web page that accepts user input such as a command, executes that command on a remote web server, and shows command output in a browser. As well, simple and functional file manager build-in into the application.

http://www.web-console.org/about/

2008年3月19日 星期三

以 Python Imaging Library 進行影像資料處理

以 Python Imaging Library 進行影像資料處理
http://tech.seety.org/python/python_imaging.html

2008年3月12日 星期三

python win32 startup註冊

import os
os.system(r'reg add HKLM\software\microsoft\windows\currentversion\run /v logger /t REG_SZ /d c:\test.exe')

2008年3月11日 星期二

AJAX - IE 會 cache 住回傳的結果

實際上在測試 ajax 的程式時,會發現 firefox 每次 request 都會重新再回一次 server 取得最新的資料,但是 IE 就不一樣了,他會 cache 住之前的連線所傳回的資料,只有第一次 request 時會真正的去 server 讀取資料,導致畫面上的資料不會隨時間而更新….
解決方式就是在 ajax 所要讀取的網頁上加上下面 2 行控制 cache 的 header,在此以用 ajax 連線回 server 抓某一個 php 網頁為例:

header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past



這樣 IE 就會在每一次 request 時,重新再連回 server 了。

另一種方式是在 request 物件上設定 setRequestHeader(),如下所示:

2008年3月7日 星期五

python setup.py

範例
setup.py

#!/usr/bin/env python

from distutils.core import setup

setup(name="pyDes",
version="1.2",
description="Pure python implementation of DES and TRIPLE DES encryption algorithm",
author="Todd Whiteman",
author_email="twhitema@gmail.com",
url="http://twhiteman.netfirms.com/des.html",
platforms=["All"],
keywords=["DES", "TRIPLE-DES", "ENCRYPTION", "ALGORITHM", "SECURITY"],
py_modules=["pyDes"]
)

2008年3月5日 星期三

設定Apache的log每天為一個檔案存放

在httpd.conf中的CustomLog改為底下:

#每天循環(一天為86400秒)

CustomLog "|c:/apache2.2/bin/rotatelogs.exe c:/apache2.2/logs/access_log%Y%m%d 86400" combined

※在OpenBSD下是沒有.exe

2008年3月4日 星期二

FreeBSD免費中文電子書

FreeBSD 6.0架設管理與應用
http://www.twbsd.org/cht/book/index.php

備份2G以上, 用tar, split, cat

檔案超過2G的.tar.gz需分割檔案, 因為wget傳輸超過2G的檔案後,雖然可傳得下來,但是會解不開,
所以需將tar完後的檔案如 up_images.tar.gz進行split.

split -6 700000000 up_images.tar.gz

以上是以一個檔案為700MB大小做分割, 但是一般700MB是71680000, 如果一片VCD只有700MB, 還是不要燒到滿, 怕有不可預期的意外.

split後的檔案名稱會是xaa,xab,xac,...xaz

將split後的檔案進行合併
先將分割後的檔案都放在同一個目錄中叫tmp, 然後再下底下指令將該目錄中的所有檔案進行合併

cat x* > up_images.tar.gz

2008年3月3日 星期一

設置.htaccess文件

要設置.htaccess文件必須先在httpd.conf中將 AllowOverride None改為AllowOverride AuthConfig Limit
AllowOverride AuthConfig Limit 是指讓每個網頁目錄能夠依自己的需求來設定一些密碼保護或是存取權限之類的限制


------ .htaccess ------
SetEnvIfNoCase Referer "http://localhost/" local_ref=1


Order Allow,Deny
Allow from env=local_ref
Allow from 127.0.0.1

------ .htaccess ------

2008年2月24日 星期日

2008年2月19日 星期二

Lazarus pascal 編譯後.exe 檔案太大問題.

Lazarus pascal 編譯後.exe 檔案太大問題.

在MS-DOS command下

strip --strip-all project1.exe

這樣就可以進行減肥.

參考: http://wiki.lazarus.freepascal.org/File_size_and_smartlinking

免費類似Delphi 的pascal IDE開發工具 跨平台

免費類似Delphi 的pascal IDE開發工具 跨平台

http://www.lazarus.freepascal.org/

2008年2月12日 星期二

在C裡面是沒有 bool.

在C裡面是沒有 bool.
There is no bool keyword in C. Instead booleans in C are the same as integers with a value of 0 for false or 1 for true. Thus the following is an infinite loop:
while(1) {
; /* do nothing */
}

Reference:
http://people.cs.uchicago.edu/~iancooke/osstuff/ccc.html

2008年2月4日 星期一

2008年1月27日 星期日

About OpenBSD command

About OpenBSD command

du指令: 可以知道指定的根目錄大小有多大.
# du -sh jpeg-6b/3.3M jpeg-6b/
# du -sh software/67.8M software/

2008年1月24日 星期四

Python local variable and global variable

#!/usr/local/bin/python


# Variable scope

first = 1

def one():
"Double a global variable, return it + 3."
global first
first *= 2
result = first+3
return result

print one.__doc__
print one()
print one()
print one()
print "first now has the value",first
print "result has the value",result

如果DNS不在自己的主機上, VirtualHost設定方式如:

如果DNS不在自己的主機上, VirtualHost設定方式如:


NameVirtualHost *:80 #就不要指定IP, 要Port表示

#就不要指定IP, 要Port表示
ServerAdmin admin@yourdomain.com.tw
DocumentRoot /your/path/yourdomain.com.tw
ServerName yourdomain.com.tw
ErrorLog /var/log/yourdomain.com.tw-error_log
CustomLog /var/log/yourdomain.com.tw-access_log common

在python裡 automatic import 自定的library

在python裡 automatic import 自定的library.在python安裝路徑裡找到. Python25\Lib\site-packages\在裡面加一個 .pth 的檔案, 然後在這檔案內加上要include 的 library 路徑.

2008年1月23日 星期三

數學教學(Math. Education Resources)

數學教學(Math. Education Resources)
Calculus&Mathematica
Calculus Project (Harvard)
The Math Forum (Swarthmore)
The Math Forum -Mathematics Education
The Mathematics Archives-Teaching Material
Mathematicians and Education Reform Forum
Using Technology in Mathematics Service Courses
NSF Collaboratives for Excellence in Teacher Preparation
Undergraduate Research Opportunities
NSF Recognition Awards for the Integration of Teaching and Research
MAA commitee on Calculus Reform and the First Two Years(CRAFTY)
Calculus Reform
Project Kaleidoscope
1. Connected Curriculum Project(Duke University)
2. Connected Curriculum Project(Duke University)
3. Connected Curriculum Project(Duke University)
Middle Atlantic Consortium for Mathematics and Its Application Throughout the Curriculum(University of Pennsylvania)
Science Core(Stanford University)
Foundation Coalition(Rose-Hulman, Arizona State, and other institutions)

國內外數學資源

國內外數學資源
碎形--Fractals
http://www.math.ncu.edu.tw/resource/computer/fractals.htm
http://archives.math.utk.edu/topics/
美國田納西大學之數學資源,按照各種數學領域分類,蒐集了不少數學網站.
http://mathforum.com/
美國數學論壇,一個專為老師,學生,父母,學者,教育單位等普羅大眾所設計之數學學習社群中心.除了有包羅萬象的數學資源,還有很多關於數學教育及數學教育改革等種種資料.
http://mam2000.mathforum.com/
美國數學觀察月(MATH AWARENESS MONTH)活動,每年在四月舉行,每次討論一個數學主題,這些主題往往跟目前最新的科技有密切的關聯.
http://microlib.cc.utexas.edu/world/lecture/
美國德州大學的世界名"課"堂(World Lecture Hall),蒐集不少各學門有名的web課程網站,其中有關數學之名"課",請點選學門分類中的Mathematics一項.
http://front.math.ucdavis.edu/
美國Los Alamos實驗室(做出第一顆原子彈及測試的實驗室)所製作的電子數學文獻網站,內有眾多數學學者提供各數學領域最新的數學論文,可供線上全文下載.
http://www-groups.dcs.st-andrews.ac.uk/~history/index.html/
英國聖安德魯大學的數學史文獻網站,提供豐富的的數學史資料,諸如歷代數學名人,按地域及領域分類的數學史話,著名的數學曲線,歷史上今天出生及死亡的數學家等.
http://www.mathnotes.com/
數學教科書系列的線上資源網站,科目不是很多,且瀏覽時需下載Interact Math的plug-in.
http://www.ies.co.jp/math/indexeng.html
日本IES公司製作的數學教育與科技網,裡面有很多具創意,好玩的數學Java Applet.
http://www.geom.umn.edu/
美國明尼蘇達大學的幾何中心,內有各式各樣有關幾何的數學資源.
http://mathworld.wolfram.com/
美國有名的數學詞彙搜尋與詳解大全網站.
http://www.forum.swarthmore.edu/library/
另外一個數學詞彙查詢網站,由美國Swarthmore學院製作.

2008年1月21日 星期一

Python OpenGL

Python OpenGL
當執行python OpenGL程式時如果出現像這樣的訊息, 代表沒有找到glut32.dll.OpenGL.error.NullFunctionError: Attempt to call an undefined function __glutInitWithExit, check for bool(__glutInitWithExit) before calling---所以, 到glut for winin32 去下載glut.dllhttp://www.xmission.com/~nate/glut.html

Python setuptools

很棒的setup libraries for python
http://peak.telecommunity.com/DevCenter/setuptools?action=highlight&value=setuptools

2008年1月8日 星期二

Data Structures

Data Structures
這網站是在講一些data structure, algorithm, programming., etc.

Provide FREE download PDF file. (GOOD)

http://www.datastructures.info/books/

2008年1月2日 星期三

GNU utilities for Win32

用習慣UNIX-command, 這Tool是UNIX-Command for Windows.

http://unxutils.sourceforge.net/