intro 3 for dev

Tags: OpenBSD
INTRO(3)                  OpenBSD Programmer's Manual                 INTRO(3)

NAME
intro - introduction to the C libraries

SYNOPSIS
cc [flags] file ... [-llibrary]

DESCRIPTION
The manual pages in section 3 provide an overview of the C library func-
tions, their error returns, and other common definitions and concepts.
Most of these functions are available from the C library, libc. Other
libraries, such as the math library, libm, must be indicated at compile
time with the -l option of the compiler.

The various libraries (followed by the loader flag):

libc (-lc)
Standard C library functions. When using the C compiler cc(1),
it is not necessary to supply the loader flag -lc for these func-
tions. There are several ``libraries'' or groups of functions
included inside of libc: the standard I/O routines, database rou-
tines, bit operators, string operators, character tests and char-
acter operators, DES encryption routines, storage allocation,
time functions, signal handling, and more.

libcompat (-lcompat)
Functions which are obsolete but are available for compatibility
with 4.3BSD. In particular, a number of system call interfaces
provided in previous releases of BSD have been included for
source code compatibility. Use of these routines should, for the
most part, be avoided. The manual page entry for each compati-
bility routine indicates the proper interface to use.

libcrypto (-lcrypto)
The OpenSSL crypto library. Implements a range of cryptographic
algorithms, providing such functionality as symmetric encryption,
public key cryptography, and certificate handling. See
crypto(3).

libcurses (-lcurses)
libncurses (-lncurses)
libtermcap (-ltermcap)
libtermlib (-ltermlib)
Terminal-independent screen management routines for two-dimen-
sional non-bitmap display terminals. This implementation is
``new curses'' and is a replacement for 4.2BSD classic curses.
The libraries libncurses, libtermcap, and libtermlib are all hard
links to libcurses. This is for compatibility purposes only; new
programs should link with -lcurses. See curses(3) and
termcap(3).

libdes (-ldes)
Implementation of the DES encryption algorithm. See
des_crypt(3).

libedit (-ledit)
Generic line editing and history functions, similar to those
found in sh(1). Functions using the libedit library must be
linked with the libcurses library, i.e. -ledit -lcurses. See
editline(3).

libevent (-levent)
Provides a mechanism to execute a function when a specific event
on a file descriptor occurs or after a given time has passed.
See event(3).

libexpat (-lexpat)
Library routines for parsing XML documents.

libform (-lform)
Terminal-independent facilities for composing form screens on
character-cell terminals. Functions using the libform library
must be linked with the libcurses library, i.e. -lform -lcurses.
See form(3).

libfrtbegin (-lfrtbegin)
libg2c (-lg2c)
Support routines for Fortran functions. These two libraries were
separated to allow linking Fortran code with other languages on
ELF platforms. See g77(1).

libgcc (-lgcc)
GCC runtime support, including long arithmetic, propolice, and
language independent exception support. Note: users do not nor-
mally have to explicitly link with this library.

libgssapi (-lgssapi)
The Generic Security Service Application Program Interface
(GSS-API) provides security services to callers in a generic
fashion. See gssapi(3).

libiberty (-liberty)
Collection of subroutines missing in other operating systems, as
well as the C++ demangler and other functions used by the GNU
toolchain.

libkadm5clnt (-lkadm5clnt)
Kerberos administration client library, for talking to a Kerberos
database. Clients communicate via the network.

libkadm5srv (-lkadm5srv)
Kerberos administration server library, for talking to a Kerberos
database. Servers talk directly to the database.

libkeynote (-lkeynote)
System library for the keynote trust-management system. Trust-
management systems provide standard, general-purpose mechanisms
for specifying application security policies and credentials.
Functions using the libkeynote library must be linked with the
libm and libcrypto libraries, i.e. -lkeynote -lm -lcrypto. See
keynote(3) and keynote(4).

libkrb5 (-lkrb5)
libasn1 (-lasn1)
libcom_err (-lcom_err)
libhdb (-lhdb)
libkafs (-lkafs)
Kerberos 5 libraries. The libraries libasn1, libcom_err, libhdb,
and libkafs are all hard links to libkrb5. See krb5(3).

libkvm (-lkvm)
Kernel memory interface library. Provides a uniform interface
for accessing kernel virtual memory images, including live sys-
tems and crash dumps. See kvm(3).

libl (-ll)
libfl (-lfl)
The library for lex(1), a lexical analyzer generator. The libfl
library is a hard link to libl.

libm (-lm)
Mathematical functions which comprise the C math library, libm.
See math(3).

libmenu (-lmenu)
Terminal-independent facilities for composing menu systems on
character-cell terminals. Functions using the libmenu library
must be linked with the libcurses library, i.e. -lmenu -lcurses.
See menu(3).

libmilter (-lmilter)
The sendmail(8) mail filter API. See the documentation in
/usr/share/doc/html/milter/.

libobjc (-lobjc)
Library for Objective C, an object-oriented superset of ANSI C.
Use this to compile Objective C programs.

libocurses (-locurses)
libotermcap (-lotermcap)
Routines to provide the user with a method of updating screens
with reasonable optimisation. The ocurses(3) library is compati-
ble with the curses library provided in 4.3. libotermcap is the
4.3-compatible termcap library, and is a hard link to libocurses.
See otermcap(3).

libossaudio (-lossaudio)
Provides an emulation of the OSS (Linux) audio interface. This
is used only for porting programs. See ossaudio(3).

libpanel (-lpanel)
Terminal-independent facilities for stacked windows on character-
cell terminals. Functions using the libpanel library must be
linked with the libcurses library, i.e. -lpanel -lcurses. See
panel(3).

libpcap (-lpcap)
Packet capture library. All packets on the network, even those
destined for other hosts, are accessible through this library.
See pcap(3).

libperl (-lperl)
Support routines for perl(1).

libpthread (-pthread)
IEEE Std 1003.1-2001 (``POSIX'') threads API and thread sched-
uler. Threaded applications should use -pthread not -lpthread.
See pthreads(3). Note: users do not normally have to explicitly
link with this library.

libreadline (-lreadline)
Command line editing interface. See readline(3).

librpcsvc (-lrpcsvc)
Generated by rpcgen(1), containing stub functions for many common
rpc(3) protocols.

libsectok (-lsectok)
Library for communicating with ISO 7816 smartcards. See
sectok(3).

libskey (-lskey)
Support library for the S/Key one time password (OTP) authentica-
tion toolkit. See skey(3).

libssl (-lssl)
The OpenSSL ssl library implements the Secure Sockets Layer (SSL
v2/v3) and Transport Layer Security (TLS v1) protocols. See
ssl(3).

libstdc++ (-lstdc++)
GCC subroutine library for C++. See c++(1). Note: users do not
normally have to explicitly link with this library.

libsupc++ (-lsupc++)
(GCC 3.3.x systems only) C++ core language support (exceptions,
new, typeinfo). Note: users do not normally have to explicitly
link with this library.

libusbhid (-lusbhid)
Routines to extract data from USB Human Interface Devices (HIDs).
See usbhid(3).

libutil (-lutil)
System utility functions. These are currently check_expire(3),
fmt_scaled(3), fparseln(3), getmaxpartitions(3),
getrawpartition(3), login(3), login_fbtab(3), opendev(3),
opendisk(3), openpty(3), pidfile(3), pw_init(3), pw_lock(3),
readlabelfs(3) and uucplock(3).

libwrap (-lwrap)
TCP wrapper access control library. See hosts_access(3) and
rfc1413(3).

liby (-ly)
The library for yacc(1), an LALR parser generator.

libz (-lz)
General purpose data compression library. The functions in this
library are documented in compress(3). The data format is de-
scribed in RFCs 1950 - 1952.

Platform-specific libraries:

libalpha (-lalpha)
Alpha I/O and memory access functions. See inb(2).

libamd64 (-lamd64)
AMD64 I/O and memory access functions. See amd64_get_ioperm(2)
and amd64_iopl(2).

libarm (-larm)
ARM I/O and memory access functions. See arm_drain_writebuf(2)
and arm_sync_icache(2).

libi386 (-li386)
i386 I/O and memory access functions. See i386_get_ioperm(2),
i386_get_ldt(2), i386_iopl(2), and i386_vm86(2).

LIBRARY TYPES
The system libraries are located in /usr/lib. Typically, a library will
have a number of variants:

libc.a
libc.so.30.1
libc_p.a
libc_pic.a

Libraries with an `.a' suffix are static. When a program is linked
against a library, all the library code will be linked into the binary.
This means the binary can be run even when the libraries are unavailable.
However, it can be inefficient with memory usage. The C compiler, cc(1),
can be instructed to link statically by specifying the -static flag.

Libraries with a `.so.X.Y' suffix are dynamic libraries. When code is
compiled dynamically, the library code that the application needs is not
linked into the binary. Instead, data structures are added containing
information about which dynamic libraries to link with. When the binary
is executed, the run-time linker ld.so(1) reads these data structures,
and loads them at a virtual address using the mmap(2) system call.

`X' represents the major number of the library, and `Y' represents the
minor number. In general, a binary will be able to use a dynamic library
with a differing minor number, but the major numbers must match. In the
example above, a binary linked with minor number `3' would be linkable
against libc.so.30.1, while a binary linked with major number `31' would
not.

The advantages of dynamic libraries are that multiple instances of the
same program can share address space, and the physical size of the binary
is smaller. The disadvantage is the added complexity that comes with
loading the libraries dynamically, and the extra time taken to load the
libraries. Of course, if the libraries are not available, the binary
will be unable to execute. The C compiler, cc(1), can be instructed to
link dynamically by specifying the -shared flag, although on systems that
support it, this will be the default and need not be specified.

Libraries with a `_p.a' suffix are profiling libraries. They contain ex-
tra information suitable for analysing programs, such as execution speed
and call counts. This in turn can be interpreted by utilities such as
gprof(1). The C compiler, cc(1), can be instructed to generate profiling
code, or to link with profiling libraries, by specifying the -pg flag.

Libraries with a `_pic.a' suffix contain position-independent code (PIC).
Normally, compilers produce relocatable code. Relocatable code needs to
be modified at run-time, depending on where in memory it is to be run.
PIC code does not need to be modified at run-time, but is less efficient
than relocatable code. PIC code is used by shared libraries, which can
make them slower. The C compiler, cc(1), can be instructed to generate
PIC code, or to link with PIC libraries, by specifying the -fpic or -fPIC
flags.

With the exception of dynamic libraries, libraries are generated using
the ar(1) utility. The libraries contain an index to the contents of the
library, stored within the library itself. The index lists each symbol
defined by a member of a library that is a relocatable object file. This
speeds up linking to the library, and allows routines in the library to
call each other regardless of their placement within the library. The
index is created by ranlib(1) and can be viewed using nm(1).

The building of PIC versions of libraries and dynamic libraries can be
prevented by setting the variable NOPIC in /etc/mk.conf. The building of
profiling versions of libraries and/or dynamic libraries can be prevented
by setting the variable NOPROFILE in /etc/mk.conf. See mk.conf(5) for
more details.

FILES
/usr/lib/libasn1.a
/usr/lib/libc.a
/usr/lib/libcom_err.a
/usr/lib/libcompat.a
/usr/lib/libcrypto.a
/usr/lib/libcurses.a
/usr/lib/libdes.a
/usr/lib/libedit.a
/usr/lib/libevent.a
/usr/lib/libexpat.a
/usr/lib/libfl.a
/usr/lib/libform.a
/usr/lib/libfrtbegin.a
/usr/lib/libg2c.a
/usr/lib/gcc-lib/${ARCH}-unknown-openbsd${OSREV}/${GCCREV}/fpic/libgcc.a
/usr/lib/libgssapi.a
/usr/lib/libhdb.a
/usr/lib/libiberty.a
/usr/lib/libkadm5clnt.a
/usr/lib/libkadm5srv.a
/usr/lib/libkafs.a
/usr/lib/libkeynote.a
/usr/lib/libkrb5.a
/usr/lib/libkvm.a
/usr/lib/libl.a
/usr/lib/libm.a
/usr/lib/libmenu.a
/usr/lib/libmilter.a
/usr/lib/libncurses.a
/usr/lib/libobjc.a
/usr/lib/libocurses.a
/usr/lib/libossaudio.a
/usr/lib/libotermcap.a
/usr/lib/libpanel.a
/usr/lib/libpcap.a
/usr/lib/libperl.a
/usr/lib/libpthread.a
/usr/lib/libreadline.a
/usr/lib/librpcsvc.a
/usr/lib/libsectok.a
/usr/lib/libskey.a
/usr/lib/libssl.a
/usr/lib/libstdc++.a
/usr/lib/libsupc++.a
/usr/lib/libtermcap.a
/usr/lib/libtermlib.a
/usr/lib/libusbhid.a
/usr/lib/libutil.a
/usr/lib/libwrap.a
/usr/lib/liby.a
/usr/lib/libz.a

/usr/lib/libalpha.a
/usr/lib/libamd64.a
/usr/lib/libarm.a
/usr/lib/libi386.a

SEE ALSO
ar(1), c++(1), cc(1), g77(1), gcc-local(1), gprof(1), ld(1), ld.so(1),
lex(1), nm(1), perl(1), ranlib(1), yacc(1), intro(2), compress(3),
crypto(3), curses(3), des_crypt(3), editline(3), event(3), form(3),
hosts_access(3), keynote(3), kvm(3), math(3), menu(3), ocurses(3),
ossaudio(3), panel(3), pcap(3), pthreads(3), readline(3), rfc1413(3),
rpc(3), sectok(3), skey(3), ssl(3), stdio(3), termcap(3), usbhid(3),
keynote(4), mk.conf(5)

HISTORY
An intro manual appeared in Version 7 AT&T UNIX.

OpenBSD 4.4 August 26, 2008

No Comments 2008-10-30 22:29:24 by No.0023

硬盘与分区

Tags: OpenBSD

Shell:~/tmp >: df  
Filesystem     Size    Used   Avail Capacity iused   ifree  %iused  Mounted on
/dev/sd0a     97.9M   43.2M   49.9M    46%    2462   13536    15%   /
/dev/sd0f     22.6G    5.3G   16.2G    25%  142498 2897628     5%   /home
/dev/sd0d     1005M   20.0K    955M     0%      39  155863     0%   /tmp
/dev/sd0g     34.5G    6.4G   26.3G    20%  351775 4273375     8%   /usr
/dev/sd0e     1005M   70.3M    885M     7%    2891  153011     2%   /var
procfs         447M    280M      0B   100%      76   65459     0%   /proc
/dev/sd0i     19.5G    9.9G    9.7G    51%   89632 10125452     1%   /mnt/c
/dev/sd0j     30.1G   20.3G    9.8G    67%   57920 10292980     1%   /mnt/d
Shell:~/tmp >: cat /etc/fstab
/dev/sd0a / ffs rw 1 1
/dev/sd0f /home ffs rw,nodev,nosuid 1 2
/dev/sd0d /tmp ffs rw,nodev,nosuid 1 2
/dev/sd0g /usr ffs rw,nodev 1 2
/dev/sd0e /var ffs rw,nodev,nosuid 1 2
/proc /proc procfs rw,linux 0 0

Shell:~/tmp >: disklabel sd0
# Inside MBR partition 2: type A6 start 104165460 size 130271085
# /dev/rsd0c:
type: ESDI
disk: ESDI/IDE disk
label: SAMSUNG HM120JI
flags:
bytes/sector: 512
sectors/track: 63
tracks/cylinder: 16
sectors/cylinder: 1008
cylinders: 16383
total sectors: 234441648
rpm: 3600
interleave: 1
trackskew: 0
cylinderskew: 0
headswitch: 0        # microseconds
track-to-track seek: 0    # microseconds
drivedata: 0

16 partitions:
#                size           offset  fstype [fsize bsize  cpg]
  a:           204876        104165460  4.2BSD   2048 16384    1
  b:          4195296        104370336    swap                  
  c:        234441648                0  unused      0     0     
  d:          2097648        108565632  4.2BSD   2048 16384    1
  e:          2097648        110663280  4.2BSD   2048 16384    1
  f:         48234816        112760928  4.2BSD   2048 16384    1
  g:         73440801        160995744  4.2BSD   2048 16384    1
  i:         40965687               63 unknown                  
  j:         63199710         40965750 unknown                  
Shell:~/tmp >:

for my notebook.

No Comments 2008-10-30 21:14:22 by No.0023

apropos

Tags: OpenBSD

Shell:~/tmp >: man apropos

APROPOS(1)                 OpenBSD Reference Manual                 APROPOS(1)

NAME
     apropos - locate commands by keyword lookup

SYNOPSIS
     apropos [-C file] [-M path] [-m path] keyword ...

DESCRIPTION
     apropos shows which manual pages contain instances of any of the given
     keyword(s) in their title line.  Each word is considered separately and
     case of letters is ignored.  Words which are part of other words are con-
     sidered; when looking for ``compile'', apropos will also list all in-
     stances of ``compiler''.

     If the line output by apropos starts ``name (section) ...'', you can en-
     ter ``man section name'' to get its documentation.

 

unix-center.net:~ >: man apropos
apropos(1)                                                          apropos(1)



NAME
       apropos - search the whatis database for strings

SYNOPSIS
       apropos keyword ...

DESCRIPTION
       apropos searches a set of database files containing short descriptions of system commands for keywords and
       displays the result on the standard output.

AUTHOR
       John W. Eaton was the original author of man.  Zeyd M. Ben-Halim released man  1.2,  and  Andries  Brouwer
       followed  up  with  versions  1.3 thru 1.5p.  Federico Lucifredi <flucifredi@acm.org> is the current main-
       tainer.

竟然一直不知道有这个命令,以前就知道man -k了,以后也要记得还有whatis, whereis.

No Comments 2008-10-30 21:11:48 by No.0023

Bind On OpenBSD

Tags: OpenBSD

Shell:~ >: sudo vi /etc/rc.conf.local
named_flags=""

Shell:~ >: sudo cp -rf /var/named/etc/root.hint /var/named/standard/root.hint
Shell:~ >: cd /var/named/standard
Shell:/var/named/standard >: sudo wget ftp://ftp.internic.net/domain/db.cache
Shell:/var/named/standard >: sudo wget ftp://ftp.internic.net/domain/named.cache
Shell:/var/named/standard >: sudo wget ftp://ftp.internic.net/domain/named.root

Shell:~ >: cat /etc/resolv.conf                                                        
lookup file bind
nameserver 127.0.0.1
nameserver 202.96.128.166
nameserver 202.96.134.133

No Comments 2008-10-23 23:15:19 by No.0023

Gidot Black - 微软非官方黑屏增值服务

Tags: others

小众软件读者 李二嫂的猪 强烈推荐!

最近的黑屏事件,真是如火如荼:

  1. 有人恶搞,DIY 纯黑壁纸,上书“绝对盗版自觉黑屏”几个大字。AHK 粉丝请参考 AutoHotKey 中文论坛自觉黑屏法
  2. 有人向公安部举报,称微软黑屏是最大黑客行为
  3. 有人利用黑屏计划传播病毒
  4. 有人爆料:XP 家庭版不参加”黑屏”验证
  5. 有人破解黑屏补丁,链接就不给出,有兴趣自信搜索。注意防毒防虫防火。
  6. Keso 也来三言二拍:我们对微软的复杂情感

小众跟着瞎掺和什么?我们可不是跟风炒作。微软非官方黑屏增值服务真的是个好东西!

Gidot Black 的作者有这两个软件在小众介绍过:

先来看界面:

明白了吧?是个护眼软件!效果很棒哦,一个渐渐出现的黑色窗口遮满这个屏幕,只留下鼠标。运行软件之后,可以右击其托盘图标,选择“立即体验黑屏”。

在真正黑屏期间(非预览模式),用快捷键调用任务管理器的话,会是这个效果:

如果能加上音乐播放,还有在最后 10 分钟每隔一分钟进行提醒就更好了。这个最后时间要能自定义。

下载(800KB):uushare(国内)|官方网站|来自小众软件|box.net|dropbox

 

from http://www.appinn.com/gidot-black/

No Comments 2008-10-22 12:17:45 by No.0023

Android

Tags: Google, java

详情查看:http://source.android.com/

No Comments 2008-10-22 12:15:13 by No.0023

OpenBSD使用cdio刻录cd

Tags: OpenBSD

Shell:~/tmp >: dmesg | grep cd | head
cd0 at scsibus0 targ 0 lun 0: <QSI, DVD+-RW SDW-082S, LX06> SCSI0 5/cdrom removable
cd0(pciide0:0:0): using PIO mode 4, Ultra-DMA mode 2

Shell:~ >: wget http://ftp.bsdanywhere.org/4.3/bsdanywhere43-i386.iso
Shell:~ >: eject cd0
Shell:~ >: sudo cdio -f cd0c tao bsdanywhere43-i386.iso


太简单了,电池内置啊。

No Comments 2008-10-21 00:50:59 by No.0023

一些常见的关于 IT 的定律

Tags: others

摩尔定律

集成电路芯片上所集成的电路的数目,每隔18个月就翻一番。(refer)

摩尔定律人人都知道,也是老生常谈了。近年来摩尔也做了一点修正,总体来说,再来一段时间内,仍然管用。

Metcalfe 定律

网络的价值与上网人数的平方成正比。Bob Metcalfe@3Com

Metcalfe 定律现在来看,也适用于 SNS。尽管关键节点的作用可能对整天定律的准确性有很大影响。

吉尔德定律

未来25年,带宽每六个月增一倍。by George Gilder

在国内基本上很难感受到每六个月增一倍。倒是每六个月网速度慢一倍差不多。

Traver 定律

一条连接的价值等于用户所能访问到的应用程序功能的倍数 by Traver Grue Kennedy@Cisco

达维多定律

一家企业要在市场中总是占据主导地位,那么就要做到第一个开发出新一代产品,第一个淘汰自己现有的产品。by William H Davidow@Intel

这一条对于个人技能发展很有参考价值。

 

from http://www.dbanotes.net/geek/it_laws.html

No Comments 2008-10-20 21:49:52 by No.0023

DjangoBBS

Tags: Django

http://code.google.com/p/djangobbs, 欢迎参加...

No Comments 2008-10-20 17:02:45 by No.0023

用 Python + django 10分鐘內作出一個 blog

Tags: Python, dev, Django

Ruby on Rails 的官方網站上有 15 分鐘作出一個 weblog 的 screencast,的確 demo 了 RoR 開發的快速。不過萬萬不可太迷信只有 RoR 能這麼神速,根據最近擠出一點時間看 django 的東西後,我也想先來作個「10分鐘做出 blog 的挑戰」。(由於還不太會用製作 screen cast 的軟體,所以只能用文字介紹..)這篇文章只是描述一下建構過程,所以不會介紹 django 環境的安裝設定,請讀者見諒。

稍微簡介一下 django,它是一個基於 Python 語言的 Web 開發框架(framework)。

建立 project 及 app

在 django 的環境裡,一個 project 裡可以有很多個 application,如此一來同一個 project 下的 application 便能共用同一套環境設定。所以我們先在命令列下執行 django-admin.py 來建立一個 project:

django1

先來改一下 demo/settings.py 的設定,裡面設定我們會用 sqlite3 來作資料庫的引擎,然後產生一個 demo.db 的檔案來當資料庫,再設定一些時區及 template 目錄等:

DATABASE_ENGINE = 'sqlite3'
DATABASE_NAME = 'demo.db'
...
TIME_ZONE='Asia/Taipei'
LANGUAGE_CODE='zh-tw'
...
TEMPLATE_DIRS = (
...
'.',
)

INSTALLED_APPS = (
'django.contrib.admin',
..
'demo.blog', # 等一下就會產生
)

然後在 demo 目錄下建立一個 blog 的 app:

圖片 1

然後在 demo/blog/models.py 裡建立需要的 model(DB Table):

from django.db import models

class Category(models.Model):
name = models.CharField(max_length=32)
def __unicode__(self):
return self.name
class Admin:
pass

class Article(models.Model):
title = models.CharField(max_length=64)
published_at = models.DateTimeField('date published')
content = models.TextField()
category = models.ForeignKey(Category)
def __unicode__(self):
return self.title
class Admin:
pass

然後可以看看 django 產生的 SQL DDL,確定的話就用 syncdb 來建立資料庫表格:

django3 django4

其中會要求你建立一個管理者帳號,這是為了之後進管理介面發表文章使用的帳號。完成這些動作之後,修改一下 demo/urls.py 的內容:

from django.conf.urls.defaults import *

urlpatterns = patterns('',
(r'^blog/', include('demo.blog.urls')),
(r'^admin/', include('django.contrib.admin.urls')),
)

先在 demo/blog/ 下建立一個 urls.py 的檔案,然後在命令列下輸入 python manage.py runserver,再打開瀏覽器輸入網址 http://localhost:8000/admin/ 馬上就有一個後台介面可以使用了呀!

django5 django6
發表文章的介面還蠻好用的呢

登入後你就可以直接建立 Category 及 Artical 的內容,這不就是一個現成的文章發表介面了嗎?一開始操作到現在不會超過5分鐘吧!

文章列表、單篇文章

可以發表文章之後,當然是要能夠瀏覽呀,所以我們馬上打開 demo/blog/urls.py 這個檔案,然後貼上下列的 code:

from django.conf.urls.defaults import *
from demo.blog.models import Article

info_dict = {
'queryset': Article.objects.all(),
}

urlpatterns = patterns('',
(r'^$', 'django.views.generic.list_detail.object_list', info_dict),
(r'^(?P<object_id>\d+)/$', 'django.views.generic.list_detail.object_detail', info_dict),
)

然後再分別建立 demo/blog/article_list.html 及 demo/blog/article_detail.html 這兩個檔案,分別表示文章列表及文章內容:

article_list.html:

{% if object_list %}
{% for article in object_list %}
<div class="article">
<div class="title"><a href="/blog/{{ article.id }}">{{ article.title }}</a></div>
</div>
{% endfor %}
{% else %}
<p>對不起沒有文章喔!</p>
{% endif %}

article_detail.html:

<div class="article">
<div class="title">標題: {{ object.title }}</div>
<div class="pub_date">{{ object.published_at }}</div>
<div class="content">{{ object.content }}</div>
<div class="category">發表於: {{ object.category.name }}</div>
</div>
<p><a href="/admin/blog/article/{{ object.id }}">修改</a></p>
<p><a href="/blog">BACK</a></p>

這樣很快就弄出一個很像樣的 blog (只是不能留言 XD),網址在 http://localhost:8000/blog/。

django7 django8

很快吧!當然我忽略了美工,也沒有客製化一下後台,不過 Web 開發愈來愈可怕了….真怕這種開發框架愈來愈多,老板都覺得寫網頁沒什麼了呢!

值得一提的是,django 在 runserver 之後,都會把程式碼 compile 成 pyc 檔,看起來效率應該還不錯,也許要等我多玩熟一點才能做些實驗囉。

from http://blog.ericsk.org/archives/815

 

1 Comment 2008-10-20 16:58:36 by No.0023

120+网页开发资源汇集

Tags: dev

"工欲善其事,必先利其器。"花大量时间去找资源和工具是件令人痛苦的事,好在有大善人为我们做了这件事,这里有超过 120 个网络开发资源,因篇幅过长,以下只是一部分,更多请见文末链接。



参考手册和综合资源:

TechCheatSheets-收集各类编程的清单和参考指南。
Creative Commons-用它给你做的网络应用程序授以部分或全部权限。
Yahoo! Design Pattern Library-雅虎设计模式库(带详解的常见问题最佳解决方案)

综合开发工具:

TurboDbAdmin-一个基于浏览器、用来察看和编辑数据库且无需刷新和提交的解决方案
GENNIT-帮您生成代码,节省大量时间
Kaosweaver-Dreamwaver拓展,包括"高级随机图片"和"面包屑"( Breadcrumbs ,"面包屑型"网站架构)。

应用程序开发工具:

Coghead-用直观的界面开发基于网络的应用程序。
Iceberg On Demand-一个基于网络用来开发、分享和销售网络应用程序的平台。
Nenest-一个网络应用程序框架,包括一个表单开发工具和数据库,且无需编程。

代码片断(Code Snippets)、搜索引擎和宝库(Repositories):

krugle-一个代码搜索引擎。
All The Code-源码搜索引擎。
Ohloh-开源软件目录。

开发环境及框架:

BackBase Ajax 360-一个企业级 Ajax 开发框架。
Maguma Workbench-全功能的 PHP & Python 集成开发平台
Tapestry-用来开发动态、强健、高可拓展性 Java 网络应用程序的开源框架。

聚合(Mashup)与API:

OpenKapow-聚合编辑器和主机寄存(hosting)服务。
Dapper-允许你抓取来自任何网站的 RSS、XML 或任何其他类型的订阅,使之对你的聚合或其他应用程序有效。
OpenLayers-允许你把一个动态地图放置在任何网页上。

测试、查错和工程管理:

spigit-它是一个可供开发者展示他们的新想法和开创一个专业的网络的社区。通过模拟,使你能在发布一个beta之前去开发和完善你的构想。
Rainbow9-在线编码、测试 javascript、css和html。
16bugs-容易而不冒失的 bug 查找

Ruby & Ruby on Rails 资源及工具:

Ruby on Rails-一个偏爱常规的开源网络框架。
Instant Rails-一个"运行时"(runtime)方案,预置Ruby, Rails, Apache and MySQL,无需安装。
Nitro-Ruby和Javascript网络应用程序框架,轻易创造出 Web 2.0 应用程序。

Ajax 资源及工具:

ajaxload.info-这个易上手的网络应用程序使你创造出基于AJAX的载入条、花朵(和其他形态的),用以显示网站载入状态。
Aptana-免费、开源的以 Javascript 为中心创建 AJAX 应用程序的开发环境。(不错,我用过,也可编辑CSS)
Mini ajax-提供免费、简易、可下载的 ajax & dhtml 代码。

PHP 资源及工具:

PHP Object Generator-生成完整的 PHP4/PHP5 面向对象代码。
Symfony-一个 PHP5 工程专用的网络应用程序框架,有简单模版、Ajax 支持、智能 URL 等功能。
CakePHP-它是一个快速的PHP开发框架,提供结构化的框架使各种水平的 PHP 用户都能快速地开发出可伸缩性的网络应用程序。

Flash 资源及工具:

flashvillage-免费高质量 flash 模版。需注册才能下载。
Dontclick.it-一个用以创建免点击用户界面的框架。
Flash Developer Center-Adobe 公司的flash 开发者中心,提供下载、实例、快速启动和社区。

Python 资源及工具:

Pylons-将 Ruby、Python & Perl 结合在一个轻量级的网络框架中,使之能在快速开发的同时,依然保持可拓展性。
zope-支持 Python 网络应用程序的开源应用程序服务器。
Spyce-使网络开发又变得有趣。

 

from http://www.wujianrong.com/archives/2008/10/120.html

No Comments 2008-10-20 09:00:27 by No.0023

代码之美(精选版)

Tags: dev, others

本迷你书是《代码之美》的精选版(互动出版网购买), 包括正则表达式匹配器、最美丽的代码、美丽测试、NASA火星漫步者任务中的高可靠企业系统、美丽的并发、以REST方式集成业务伙伴等。《代码之美》由 华章图书出版公司出版,全书收录的皆为软件设计领域中的一组大师级作品。每一章都是由一位或几位著名程序员针对某个问题给出的完美的解决方案,并且细述了 这些解决方案的巧妙之处。

《Beautiful Code》是由Greg Wilson在2006年构思的,本书的初衷是希望从优秀的软件开发人员和计算机科学家中提炼出一些有价值的思想。他与助理编辑Andy Oram一起走访了世界各地不同技术背景的专家。一堆如雷贯耳的名字居然出现在同一本书中,怎能不令人兴奋?! 你是程序员吗?你对代码之美的认识是什么?33位作者,33个来自不同开发领域的专业经验,33种不同的意见。你想知道牛人们对代码之美是怎么想的吗? 其实,这本书最奇妙的地方还不在于这一点,而在于,如果你知道这些作者的名字,你肯定会忍不住去看一看。如果你不知道这些作者的名字,你更加会忍不住去看 一看。因为你知道这些人的观点肯定不会让你失望!

免费下载,购买原版《代码之美》

如果你喜欢本书,请通过购买本书原版《代码之美》支持华章图书出版公司和InfoQ中文站。 免费下载这本书(PDF) 免费下载这本书(PDF)

 

from http://www.infoq.com/cn/minibooks/beautiful-code

No Comments 2008-10-18 15:37:45 by No.0023

hosts for GAE

Tags: GAE

Shell:~/dev/AppEngine/google_appengine/n23 >: tail -n 3 /etc/hosts
209.85.171.118    n23.appspot.com
64.233.189.99   appengine.google.com
#203.208.35.100  appengine.google.com
Shell:~/dev/AppEngine/google_appengine/n23 >:

No Comments 2008-10-18 00:09:49 by No.0023

GAE Secure_URLs

Tags: GAE

from http://code.google.com/appengine/docs/configuringanapp.html#Secure_URLs

Shell:~/dev/AppEngine/google_appengine/n23 >: head -n 45 app.yaml
application: n23
version: 1
runtime: python
api_version: 1

handlers:

- url: /blog
  script: blog.py
  secure: always

- url: /blog/.*
  script: blog.py
  secure: always

- url: /themes/.+
  script: cache.py
  secure: always

- url: /static/.+
  script: cache.py
  secure: always
...

No Comments 2008-10-18 00:08:44 by No.0023

count_history_cmd.py

Tags: Python, dev

#!/usr/bin/env python
# -*- coding: UTF-8 -*-

import os

def f(his, n):
    lines = open(os.path.join(os.getenv('HOME'), his)).readlines()
    d = {}
    for line in lines:
        line = line.split()
        if not line: continue
        s = line[0]
        if line[0] == 'sudo':
            s = line[1]
        d[s] = d.get(s, 0) + 1

    l = sorted(d.items(), key=lambda t: t[1], reverse=True)
    for t in l[:n]:
        print '%s : %d' % (t[0].ljust(16), t[1])

if __name__ == '__main__':
    from optparse import OptionParser
    parser = OptionParser()
    parser.add_option('-f', '--file', dest='f', default='.history',
                      help='the history file', metavar='FILE')
    parser.add_option('-c', '--count', dest='c', type='int', default='30',
                      help='for display count', metavar='COUNT')
    (options, args) = parser.parse_args()
    f(options.f, options.c)

 

运行结果:

Shell:~ >: count_his_cmd
cd               : 4895
ls               : 4533
vi               : 988
man              : 679
hitfm            : 583
cat              : 532
ifconfig         : 414
ant              : 401
rm               : 386
lt               : 349
ll               : 341
tmp              : 340
svn              : 333
tlist            : 332
top              : 311
my               : 292
exit             : 278
run              : 277
unlcall          : 249
pkg_list         : 249
glib             : 242
locate           : 235
shutdown         : 226
bbs.sh           : 220
check            : 216
ping             : 215
pkill            : 198
mv               : 196
vpn              : 190
sock             : 186
Shell:~ >:

 

from http://code.google.com/p/mylibs/source/browse/trunk/tools/Python/count_history_cmd.py

No Comments 2008-10-15 22:21:44 by No.0023

GAE SDK Release 1.1.5

Tags: GAE

Today is the release of the 1.1.5 SDK, which, as always, is available for download on our Google hosting project. The release notes contain all of the nitty gritty details. Here's a summary:

 

For this release, we've added these features:

The SDK also contains the following issue fixes:

It's also worth noting we released the 1.1.4 SDK on Friday, September 26, fixing two Windows SDK bugs: one issue with escaping in the app.yaml file, and another fixing issues with the datastore viewer on the SDK.

We'd love to hear your feedback on the Google group!

1 Comment 2008-10-04 20:54:34 by No.0023

Python 2.6 final release

Tags: Python
We are pleased to announce the release of Python 2.6 (final), a new production-ready release, on October 1st, 2008.

There are a huge number of new features, modules, improvements and bug fixes. For information on what's changed, see:

  • Andrew Kuchling's guide to What's New in Python 2.6.
  • NEWS file contains a listing of everything that's new in each alpha, beta, and release candidate of Python 2.6.
  • PEP 361.

Please report bugs at http://bugs.python.org

See also the license.

Python 2.6 Released: 01-Oct-2008

Download

This is a production release; we currently support these formats:

MD5 checksums and sizes of the released files:

837476958702cb386c657b5dba61cdc5  10957859  Python-2.6.tar.bz2
d16d29a77db2cd3af882a591f431a403 13023860 Python-2.6.tgz
fe34764ad0027d01176eb1b321dd20c5 14503936 python-2.6.amd64.msi
6c62c123d248a48dccbaa4d3edc12680 14173184 python-2.6.msi
29a1a22f8d9fd8a4501b30d97fbee61c 23593748 python-2.6-macosx2008-10-01.dmg

The signatures for the source tarballs above were generated with GnuPG using release manager Barry Warsaw's public key which has a key id of EA5BBD71. The Windows installers was signed by Martin von L&ouml;wis' public key which has a key id of 7D9DC8D2. The signature on the Mac disk image was signed by Benjamin Peterson's public key which has a key id of A4135B38.

Vista Note

Administrators installing Python for all users on Windows Vista either need to be logged in as Administrator, or use the runas command, as in:

runas /user:Administrator "msiexec /i <path>\<file>.msi"

Documentation

The documentation has also been updated. You can browse the HTML on-line or download the HTML

No Comments 2008-10-03 12:39:53 by No.0023

API JAVA

Tags: java

http://api.java2000.net/

No Comments 2008-10-02 23:03:01 by No.0023

pf-view-rule

Tags: OpenBSD

Shell:~ >: pf-view-rule
scrub in all fragment reassemble
block drop log all
pass quick on lo0 all flags S/SA keep state
pass in on re0 inet from 192.168.1.0/24 to any flags S/SA keep state
pass out on re0 inet from any to 192.168.1.0/24 flags S/SA keep state
block drop in quick on tun0 inet from 127.0.0.0/8 to any
block drop in quick on tun0 inet from 10.0.0.0/8 to any
block drop in quick on tun0 inet from 172.16.0.0/12 to any
block drop in quick on tun0 inet from 192.168.0.0/16 to any
block drop out quick on tun0 inet from any to 127.0.0.0/8
block drop out quick on tun0 inet from any to 10.0.0.0/8
block drop out quick on tun0 inet from any to 172.16.0.0/12
block drop out quick on tun0 inet from any to 192.168.0.0/16
block drop in log quick on ! re0 inet from 192.168.1.0/24 to any
block drop in log quick inet from 192.168.1.23 to any
pass out on tun0 proto tcp all flags S/SA modulate state
pass out on tun0 proto udp all keep state
pass out on tun0 proto icmp all keep state
pass out on tun0 proto esp all keep state
pass out on tun1 proto tcp all flags S/SA modulate state
pass out on tun1 proto udp all keep state
pass out on tun1 proto icmp all keep state
pass out on tun1 proto esp all keep state
pass in on tun0 proto tcp from any to any port = 44123 flags S/SA keep state
pass in on tun0 proto udp from any to any port = 44123 keep state

No Comments 2008-09-30 23:06:06 by No.0023

OpenBSD manual files

Tags: OpenBSD

Shell:~/mylibs/manual/OpenBSD >: ls
A_Beginner_Guide_to_xDSL_Firewalling.html
Install_and_run_MySQL_5.x_from_a_package_on_a_OpenBSD_3.9_and_later.html
Linux_BSD_Shellcode.pdf
OpenBSD FAQ - ChinaUnix Wiki.png
OpenBSD_Desktop_For_Windows_Users_By_Roy_Morris.html
OpenBSD_dns_server.pdf
OpenBSD_firewalls.pdf
OpenBSD_mail_server.pdf
OpenBSD_proxy_server.pdf
backup-with-dd-and-gzip.html
diskless.pdf
embedded_OpenBSD.pdf

download from http://code.google.com/p/mylibs/source/browse/#svn/trunk/manual/OpenBSD

No Comments 2008-09-26 22:56:45 by No.0023


共有文章169篇 第(4/9)页 首页 上一页 1 2 3 4 5 6 7 8 ... 下一页 末页