<!--{{{-->
<link rel='alternate' type='application/rss+xml' title='RSS' href='index.xml' />
<!--}}}-->
Background: #fff
Foreground: #000
PrimaryPale: #8cf
PrimaryLight: #18f
PrimaryMid: #04b
PrimaryDark: #014
SecondaryPale: #ffc
SecondaryLight: #fe8
SecondaryMid: #db4
SecondaryDark: #841
TertiaryPale: #eee
TertiaryLight: #ccc
TertiaryMid: #999
TertiaryDark: #666
Error: #f88
/*{{{*/
body {background:[[ColorPalette::Background]]; color:[[ColorPalette::Foreground]];}

a {color:[[ColorPalette::PrimaryMid]];}
a:hover {background-color:[[ColorPalette::PrimaryMid]]; color:[[ColorPalette::Background]];}
a img {border:0;}

h1,h2,h3,h4,h5,h6 {color:[[ColorPalette::SecondaryDark]]; background:transparent;}
h1 {border-bottom:2px solid [[ColorPalette::TertiaryLight]];}
h2,h3 {border-bottom:1px solid [[ColorPalette::TertiaryLight]];}

.button {color:[[ColorPalette::PrimaryDark]]; border:1px solid [[ColorPalette::Background]];}
.button:hover {color:[[ColorPalette::PrimaryDark]]; background:[[ColorPalette::SecondaryLight]]; border-color:[[ColorPalette::SecondaryMid]];}
.button:active {color:[[ColorPalette::Background]]; background:[[ColorPalette::SecondaryMid]]; border:1px solid [[ColorPalette::SecondaryDark]];}

.header {background:[[ColorPalette::PrimaryMid]];}
.headerShadow {color:[[ColorPalette::Foreground]];}
.headerShadow a {font-weight:normal; color:[[ColorPalette::Foreground]];}
.headerForeground {color:[[ColorPalette::Background]];}
.headerForeground a {font-weight:normal; color:[[ColorPalette::PrimaryPale]];}

.tabSelected{color:[[ColorPalette::PrimaryDark]];
	background:[[ColorPalette::TertiaryPale]];
	border-left:1px solid [[ColorPalette::TertiaryLight]];
	border-top:1px solid [[ColorPalette::TertiaryLight]];
	border-right:1px solid [[ColorPalette::TertiaryLight]];
}
.tabUnselected {color:[[ColorPalette::Background]]; background:[[ColorPalette::TertiaryMid]];}
.tabContents {color:[[ColorPalette::PrimaryDark]]; background:[[ColorPalette::TertiaryPale]]; border:1px solid [[ColorPalette::TertiaryLight]];}
.tabContents .button {border:0;}

#sidebar {}
#sidebarOptions input {border:1px solid [[ColorPalette::PrimaryMid]];}
#sidebarOptions .sliderPanel {background:[[ColorPalette::PrimaryPale]];}
#sidebarOptions .sliderPanel a {border:none;color:[[ColorPalette::PrimaryMid]];}
#sidebarOptions .sliderPanel a:hover {color:[[ColorPalette::Background]]; background:[[ColorPalette::PrimaryMid]];}
#sidebarOptions .sliderPanel a:active {color:[[ColorPalette::PrimaryMid]]; background:[[ColorPalette::Background]];}

.wizard {background:[[ColorPalette::PrimaryPale]]; border:1px solid [[ColorPalette::PrimaryMid]];}
.wizard h1 {color:[[ColorPalette::PrimaryDark]]; border:none;}
.wizard h2 {color:[[ColorPalette::Foreground]]; border:none;}
.wizardStep {background:[[ColorPalette::Background]]; color:[[ColorPalette::Foreground]];
	border:1px solid [[ColorPalette::PrimaryMid]];}
.wizardStep.wizardStepDone {background:[[ColorPalette::TertiaryLight]];}
.wizardFooter {background:[[ColorPalette::PrimaryPale]];}
.wizardFooter .status {background:[[ColorPalette::PrimaryDark]]; color:[[ColorPalette::Background]];}
.wizard .button {color:[[ColorPalette::Foreground]]; background:[[ColorPalette::SecondaryLight]]; border: 1px solid;
	border-color:[[ColorPalette::SecondaryPale]] [[ColorPalette::SecondaryDark]] [[ColorPalette::SecondaryDark]] [[ColorPalette::SecondaryPale]];}
.wizard .button:hover {color:[[ColorPalette::Foreground]]; background:[[ColorPalette::Background]];}
.wizard .button:active {color:[[ColorPalette::Background]]; background:[[ColorPalette::Foreground]]; border: 1px solid;
	border-color:[[ColorPalette::PrimaryDark]] [[ColorPalette::PrimaryPale]] [[ColorPalette::PrimaryPale]] [[ColorPalette::PrimaryDark]];}

.wizard .notChanged {background:transparent;}
.wizard .changedLocally {background:#80ff80;}
.wizard .changedServer {background:#8080ff;}
.wizard .changedBoth {background:#ff8080;}
.wizard .notFound {background:#ffff80;}
.wizard .putToServer {background:#ff80ff;}
.wizard .gotFromServer {background:#80ffff;}

#messageArea {border:1px solid [[ColorPalette::SecondaryMid]]; background:[[ColorPalette::SecondaryLight]]; color:[[ColorPalette::Foreground]];}
#messageArea .button {color:[[ColorPalette::PrimaryMid]]; background:[[ColorPalette::SecondaryPale]]; border:none;}

.popupTiddler {background:[[ColorPalette::TertiaryPale]]; border:2px solid [[ColorPalette::TertiaryMid]];}

.popup {background:[[ColorPalette::TertiaryPale]]; color:[[ColorPalette::TertiaryDark]]; border-left:1px solid [[ColorPalette::TertiaryMid]]; border-top:1px solid [[ColorPalette::TertiaryMid]]; border-right:2px solid [[ColorPalette::TertiaryDark]]; border-bottom:2px solid [[ColorPalette::TertiaryDark]];}
.popup hr {color:[[ColorPalette::PrimaryDark]]; background:[[ColorPalette::PrimaryDark]]; border-bottom:1px;}
.popup li.disabled {color:[[ColorPalette::TertiaryMid]];}
.popup li a, .popup li a:visited {color:[[ColorPalette::Foreground]]; border: none;}
.popup li a:hover {background:[[ColorPalette::SecondaryLight]]; color:[[ColorPalette::Foreground]]; border: none;}
.popup li a:active {background:[[ColorPalette::SecondaryPale]]; color:[[ColorPalette::Foreground]]; border: none;}
.popupHighlight {background:[[ColorPalette::Background]]; color:[[ColorPalette::Foreground]];}
.listBreak div {border-bottom:1px solid [[ColorPalette::TertiaryDark]];}

.tiddler .defaultCommand {font-weight:bold;}

.shadow .title {color:[[ColorPalette::TertiaryDark]];}

.title {color:[[ColorPalette::SecondaryDark]];}
.subtitle {color:[[ColorPalette::TertiaryDark]];}

.toolbar {color:[[ColorPalette::PrimaryMid]];}
.toolbar a {color:[[ColorPalette::TertiaryLight]];}
.selected .toolbar a {color:[[ColorPalette::TertiaryMid]];}
.selected .toolbar a:hover {color:[[ColorPalette::Foreground]];}

.tagging, .tagged {border:1px solid [[ColorPalette::TertiaryPale]]; background-color:[[ColorPalette::TertiaryPale]];}
.selected .tagging, .selected .tagged {background-color:[[ColorPalette::TertiaryLight]]; border:1px solid [[ColorPalette::TertiaryMid]];}
.tagging .listTitle, .tagged .listTitle {color:[[ColorPalette::PrimaryDark]];}
.tagging .button, .tagged .button {border:none;}

.footer {color:[[ColorPalette::TertiaryLight]];}
.selected .footer {color:[[ColorPalette::TertiaryMid]];}

.sparkline {background:[[ColorPalette::PrimaryPale]]; border:0;}
.sparktick {background:[[ColorPalette::PrimaryDark]];}

.error, .errorButton {color:[[ColorPalette::Foreground]]; background:[[ColorPalette::Error]];}
.warning {color:[[ColorPalette::Foreground]]; background:[[ColorPalette::SecondaryPale]];}
.lowlight {background:[[ColorPalette::TertiaryLight]];}

.zoomer {background:none; color:[[ColorPalette::TertiaryMid]]; border:3px solid [[ColorPalette::TertiaryMid]];}

.imageLink, #displayArea .imageLink {background:transparent;}

.annotation {background:[[ColorPalette::SecondaryLight]]; color:[[ColorPalette::Foreground]]; border:2px solid [[ColorPalette::SecondaryMid]];}

.viewer .listTitle {list-style-type:none; margin-left:-2em;}
.viewer .button {border:1px solid [[ColorPalette::SecondaryMid]];}
.viewer blockquote {border-left:3px solid [[ColorPalette::TertiaryDark]];}

.viewer table, table.twtable {border:2px solid [[ColorPalette::TertiaryDark]];}
.viewer th, .viewer thead td, .twtable th, .twtable thead td {background:[[ColorPalette::SecondaryMid]]; border:1px solid [[ColorPalette::TertiaryDark]]; color:[[ColorPalette::Background]];}
.viewer td, .viewer tr, .twtable td, .twtable tr {border:1px solid [[ColorPalette::TertiaryDark]];}

.viewer pre {border:1px solid [[ColorPalette::SecondaryLight]]; background:[[ColorPalette::SecondaryPale]];}
.viewer code {color:[[ColorPalette::SecondaryDark]];}
.viewer hr {border:0; border-top:dashed 1px [[ColorPalette::TertiaryDark]]; color:[[ColorPalette::TertiaryDark]];}

.highlight, .marked {background:[[ColorPalette::SecondaryLight]];}

.editor input {border:1px solid [[ColorPalette::PrimaryMid]];}
.editor textarea {border:1px solid [[ColorPalette::PrimaryMid]]; width:100%;}
.editorFooter {color:[[ColorPalette::TertiaryMid]];}

#backstageArea {background:[[ColorPalette::Foreground]]; color:[[ColorPalette::TertiaryMid]];}
#backstageArea a {background:[[ColorPalette::Foreground]]; color:[[ColorPalette::Background]]; border:none;}
#backstageArea a:hover {background:[[ColorPalette::SecondaryLight]]; color:[[ColorPalette::Foreground]]; }
#backstageArea a.backstageSelTab {background:[[ColorPalette::Background]]; color:[[ColorPalette::Foreground]];}
#backstageButton a {background:none; color:[[ColorPalette::Background]]; border:none;}
#backstageButton a:hover {background:[[ColorPalette::Foreground]]; color:[[ColorPalette::Background]]; border:none;}
#backstagePanel {background:[[ColorPalette::Background]]; border-color: [[ColorPalette::Background]] [[ColorPalette::TertiaryDark]] [[ColorPalette::TertiaryDark]] [[ColorPalette::TertiaryDark]];}
.backstagePanelFooter .button {border:none; color:[[ColorPalette::Background]];}
.backstagePanelFooter .button:hover {color:[[ColorPalette::Foreground]];}
#backstageCloak {background:[[ColorPalette::Foreground]]; opacity:0.6; filter:'alpha(opacity:60)';}
/*}}}*/
/*{{{*/
* html .tiddler {height:1%;}

body {font-size:.75em; font-family:arial,helvetica; margin:0; padding:0;}

h1,h2,h3,h4,h5,h6 {font-weight:bold; text-decoration:none;}
h1,h2,h3 {padding-bottom:1px; margin-top:1.2em;margin-bottom:0.3em;}
h4,h5,h6 {margin-top:1em;}
h1 {font-size:1.35em;}
h2 {font-size:1.25em;}
h3 {font-size:1.1em;}
h4 {font-size:1em;}
h5 {font-size:.9em;}

hr {height:1px;}

a {text-decoration:none;}

dt {font-weight:bold;}

ol {list-style-type:decimal;}
ol ol {list-style-type:lower-alpha;}
ol ol ol {list-style-type:lower-roman;}
ol ol ol ol {list-style-type:decimal;}
ol ol ol ol ol {list-style-type:lower-alpha;}
ol ol ol ol ol ol {list-style-type:lower-roman;}
ol ol ol ol ol ol ol {list-style-type:decimal;}

.txtOptionInput {width:11em;}

#contentWrapper .chkOptionInput {border:0;}

.externalLink {text-decoration:underline;}

.indent {margin-left:3em;}
.outdent {margin-left:3em; text-indent:-3em;}
code.escaped {white-space:nowrap;}

.tiddlyLinkExisting {font-weight:bold;}
.tiddlyLinkNonExisting {font-style:italic;}

/* the 'a' is required for IE, otherwise it renders the whole tiddler in bold */
a.tiddlyLinkNonExisting.shadow {font-weight:bold;}

#mainMenu .tiddlyLinkExisting,
	#mainMenu .tiddlyLinkNonExisting,
	#sidebarTabs .tiddlyLinkNonExisting {font-weight:normal; font-style:normal;}
#sidebarTabs .tiddlyLinkExisting {font-weight:bold; font-style:normal;}

.header {position:relative;}
.header a:hover {background:transparent;}
.headerShadow {position:relative; padding:4.5em 0em 1em 1em; left:-1px; top:-1px;}
.headerForeground {position:absolute; padding:4.5em 0em 1em 1em; left:0px; top:0px;}

.siteTitle {font-size:3em;}
.siteSubtitle {font-size:1.2em;}

#mainMenu {position:absolute; left:0; width:10em; text-align:right; line-height:1.6em; padding:1.5em 0.5em 0.5em 0.5em; font-size:1.1em;}

#sidebar {position:absolute; right:3px; width:16em; font-size:.9em;}
#sidebarOptions {padding-top:0.3em;}
#sidebarOptions a {margin:0em 0.2em; padding:0.2em 0.3em; display:block;}
#sidebarOptions input {margin:0.4em 0.5em;}
#sidebarOptions .sliderPanel {margin-left:1em; padding:0.5em; font-size:.85em;}
#sidebarOptions .sliderPanel a {font-weight:bold; display:inline; padding:0;}
#sidebarOptions .sliderPanel input {margin:0 0 .3em 0;}
#sidebarTabs .tabContents {width:15em; overflow:hidden;}

.wizard {padding:0.1em 1em 0em 2em;}
.wizard h1 {font-size:2em; font-weight:bold; background:none; padding:0em 0em 0em 0em; margin:0.4em 0em 0.2em 0em;}
.wizard h2 {font-size:1.2em; font-weight:bold; background:none; padding:0em 0em 0em 0em; margin:0.4em 0em 0.2em 0em;}
.wizardStep {padding:1em 1em 1em 1em;}
.wizard .button {margin:0.5em 0em 0em 0em; font-size:1.2em;}
.wizardFooter {padding:0.8em 0.4em 0.8em 0em;}
.wizardFooter .status {padding:0em 0.4em 0em 0.4em; margin-left:1em;}
.wizard .button {padding:0.1em 0.2em 0.1em 0.2em;}

#messageArea {position:fixed; top:2em; right:0em; margin:0.5em; padding:0.5em; z-index:2000; _position:absolute;}
.messageToolbar {display:block; text-align:right; padding:0.2em 0.2em 0.2em 0.2em;}
#messageArea a {text-decoration:underline;}

.tiddlerPopupButton {padding:0.2em 0.2em 0.2em 0.2em;}
.popupTiddler {position: absolute; z-index:300; padding:1em 1em 1em 1em; margin:0;}

.popup {position:absolute; z-index:300; font-size:.9em; padding:0; list-style:none; margin:0;}
.popup .popupMessage {padding:0.4em;}
.popup hr {display:block; height:1px; width:auto; padding:0; margin:0.2em 0em;}
.popup li.disabled {padding:0.4em;}
.popup li a {display:block; padding:0.4em; font-weight:normal; cursor:pointer;}
.listBreak {font-size:1px; line-height:1px;}
.listBreak div {margin:2px 0;}

.tabset {padding:1em 0em 0em 0.5em;}
.tab {margin:0em 0em 0em 0.25em; padding:2px;}
.tabContents {padding:0.5em;}
.tabContents ul, .tabContents ol {margin:0; padding:0;}
.txtMainTab .tabContents li {list-style:none;}
.tabContents li.listLink { margin-left:.75em;}

#contentWrapper {display:block;}
#splashScreen {display:none;}

#displayArea {margin:1em 17em 0em 14em;}

.toolbar {text-align:right; font-size:.9em;}

.tiddler {padding:1em 1em 0em 1em;}

.missing .viewer,.missing .title {font-style:italic;}

.title {font-size:1.6em; font-weight:bold;}

.missing .subtitle {display:none;}
.subtitle {font-size:1.1em;}

.tiddler .button {padding:0.2em 0.4em;}

.tagging {margin:0.5em 0.5em 0.5em 0; float:left; display:none;}
.isTag .tagging {display:block;}
.tagged {margin:0.5em; float:right;}
.tagging, .tagged {font-size:0.9em; padding:0.25em;}
.tagging ul, .tagged ul {list-style:none; margin:0.25em; padding:0;}
.tagClear {clear:both;}

.footer {font-size:.9em;}
.footer li {display:inline;}

.annotation {padding:0.5em; margin:0.5em;}

* html .viewer pre {width:99%; padding:0 0 1em 0;}
.viewer {line-height:1.4em; padding-top:0.5em;}
.viewer .button {margin:0em 0.25em; padding:0em 0.25em;}
.viewer blockquote {line-height:1.5em; padding-left:0.8em;margin-left:2.5em;}
.viewer ul, .viewer ol {margin-left:0.5em; padding-left:1.5em;}

.viewer table, table.twtable {border-collapse:collapse; margin:0.8em 1.0em;}
.viewer th, .viewer td, .viewer tr,.viewer caption,.twtable th, .twtable td, .twtable tr,.twtable caption {padding:3px;}
table.listView {font-size:0.85em; margin:0.8em 1.0em;}
table.listView th, table.listView td, table.listView tr {padding:0px 3px 0px 3px;}

.viewer pre {padding:0.5em; margin-left:0.5em; font-size:1.2em; line-height:1.4em; overflow:auto;}
.viewer code {font-size:1.2em; line-height:1.4em;}

.editor {font-size:1.1em;}
.editor input, .editor textarea {display:block; width:100%; font:inherit;}
.editorFooter {padding:0.25em 0em; font-size:.9em;}
.editorFooter .button {padding-top:0px; padding-bottom:0px;}

.fieldsetFix {border:0; padding:0; margin:1px 0px 1px 0px;}

.sparkline {line-height:1em;}
.sparktick {outline:0;}

.zoomer {font-size:1.1em; position:absolute; overflow:hidden;}
.zoomer div {padding:1em;}

* html #backstage {width:99%;}
* html #backstageArea {width:99%;}
#backstageArea {display:none; position:relative; overflow: hidden; z-index:150; padding:0.3em 0.5em 0.3em 0.5em;}
#backstageToolbar {position:relative;}
#backstageArea a {font-weight:bold; margin-left:0.5em; padding:0.3em 0.5em 0.3em 0.5em;}
#backstageButton {display:none; position:absolute; z-index:175; top:0em; right:0em;}
#backstageButton a {padding:0.1em 0.4em 0.1em 0.4em; margin:0.1em 0.1em 0.1em 0.1em;}
#backstage {position:relative; width:100%; z-index:50;}
#backstagePanel {display:none; z-index:100; position:absolute; width:90%; margin:0em 3em 0em 3em; padding:1em 1em 1em 1em;}
.backstagePanelFooter {padding-top:0.2em; float:right;}
.backstagePanelFooter a {padding:0.2em 0.4em 0.2em 0.4em;}
#backstageCloak {display:none; z-index:20; position:absolute; width:100%; height:100px;}

.whenBackstage {display:none;}
.backstageVisible .whenBackstage {display:block;}
/*}}}*/
/***
StyleSheet for use when a translation requires any css style changes.
This StyleSheet can be used directly by languages such as Chinese, Japanese and Korean which need larger font sizes.
***/
/*{{{*/
body {font-size:0.8em;}
#sidebarOptions {font-size:1.05em;}
#sidebarOptions a {font-style:normal;}
#sidebarOptions .sliderPanel {font-size:0.95em;}
.subtitle {font-size:0.8em;}
.viewer table.listView {font-size:0.95em;}
/*}}}*/
/*{{{*/
@media print {
#mainMenu, #sidebar, #messageArea, .toolbar, #backstageButton, #backstageArea {display: none ! important;}
#displayArea {margin: 1em 1em 0em 1em;}
/* Fixes a feature in Firefox 1.5.0.2 where print preview displays the noscript content */
noscript {display:none;}
}
/*}}}*/
<!--{{{-->
<div class='header' macro='gradient vert [[ColorPalette::PrimaryLight]] [[ColorPalette::PrimaryMid]]'>
<div class='headerShadow'>
<span class='siteTitle' refresh='content' tiddler='SiteTitle'></span>&nbsp;
<span class='siteSubtitle' refresh='content' tiddler='SiteSubtitle'></span>
</div>
<div class='headerForeground'>
<span class='siteTitle' refresh='content' tiddler='SiteTitle'></span>&nbsp;
<span class='siteSubtitle' refresh='content' tiddler='SiteSubtitle'></span>
</div>
</div>
<div id='mainMenu' refresh='content' tiddler='MainMenu'></div>
<div id='sidebar'>
<div id='sidebarOptions' refresh='content' tiddler='SideBarOptions'></div>
<div id='sidebarTabs' refresh='content' force='true' tiddler='SideBarTabs'></div>
</div>
<div id='displayArea'>
<div id='messageArea'></div>
<div id='tiddlerDisplay'></div>
</div>
<!--}}}-->
<!--{{{-->
<div class='toolbar' macro='toolbar [[ToolbarCommands::ViewToolbar]]'></div>
<div class='title' macro='view title'></div>
<div class='subtitle'><span macro='view modifier link'></span>, <span macro='view modified date'></span> (<span macro='message views.wikified.createdPrompt'></span> <span macro='view created date'></span>)</div>
<div class='tagging' macro='tagging'></div>
<div class='tagged' macro='tags'></div>
<div class='viewer' macro='view text wikified'></div>
<div class='tagClear'></div>
<!--}}}-->
<!--{{{-->
<div class='toolbar' macro='toolbar [[ToolbarCommands::EditToolbar]]'></div>
<div class='title' macro='view title'></div>
<div class='editor' macro='edit title'></div>
<div macro='annotations'></div>
<div class='editor' macro='edit text'></div>
<div class='editor' macro='edit tags'></div><div class='editorFooter'><span macro='message views.editor.tagPrompt'></span><span macro='tagChooser excludeLists'></span></div>
<!--}}}-->
To get started with this blank TiddlyWiki, you'll need to modify the following tiddlers:
* SiteTitle & SiteSubtitle: The title and subtitle of the site, as shown above (after saving, they will also appear in the browser title bar)
* MainMenu: The menu (usually on the left)
* DefaultTiddlers: Contains the names of the tiddlers that you want to appear when the TiddlyWiki is opened
You'll also need to enter your username for signing your edits: <<option txtUserName>>
These InterfaceOptions for customising TiddlyWiki are saved in your browser

Your username for signing your edits. Write it as a WikiWord (eg JoeBloggs)

<<option txtUserName>>
<<option chkSaveBackups>> SaveBackups
<<option chkAutoSave>> AutoSave
<<option chkRegExpSearch>> RegExpSearch
<<option chkCaseSensitiveSearch>> CaseSensitiveSearch
<<option chkAnimate>> EnableAnimations

----
Also see AdvancedOptions
<<importTiddlers>>
!!!i=i+1 i++ ++i的实现过程
计算机内部实现过程有别,详细如下:
i=i+1的过程相当:
>{{{  temp=i+1; i=temp;}}}
i++的过程相当:
>{{{  temp=i; i=temp+1; return temp;}}}
++i的过程最简单:
>{{{  i增1然后return i 的值,一步完成,没有给任何temp变量赋值:)}}}

!!!++操作的效率
i++;是一个右值.而++i是一个左值.而且''尽量去用++i'',因为对于类类型或大型的数据类型来做相关操作时会提高效率.
简单的说是右值是放在=(赋值运算符)右边的操作数.
而左值是可以放在其左边的操作数.
左值可以取地址,而右值不行.
>Ubuntu 32位内核默认开启了CONFIG_HIGHMEM4G,但PAE模式是关闭的,这样32位内核在系统配置4GB内存的时候会有1GB保留给内核虚拟空间,用户实际可用的只有3GB,而Ubuntu PAE内核使用的是CONFIG_HIGHMEM64G,能处理最多64GB内存。
*方法
安装server版内核(他应该是打开PAE的)
*命令
<code shell>
sudo apt-get install ubuntu-restricted-extras(网上很多教程是 linux-restricted-modules-server)
sudo apt-get install linux-headers-server 
sudo apt-get install linux-image-server linux-server 
</code>
//Shaozhi Ye , Ji-Rong Wen and Wei-Ying Ma //
//Department of Computer Science, University of California, Davis, CA, USA;//
//Microsoft Research Asia, Beijing, P.R.China//

''Time:'' Proceedings of the 10th Pacific-Asia Conference on Knowledge Discovery and Data Mining, Singapore, April ''2006''
!!!Abstract
This paper explores the correlations among ''several most important parameters'' in DDD and the impact of ''sampling ratio'' is of most interest
since it heavily affects the accuracy and scalability of DDD algorithms.
''Parameters:''
*similarity threshold
*precision/recall requirement
*sampling ratio  {{{   (most interest)}}}
*document size 

!!!Related Concept
*''adaptive sampling method''
>use dynamic sampling ratio for different document size with the constraint of given precision requirements. 
*''shingle''
>A contiguous subsequence in a document
*''false positive'' {{{?}}}
>hash collision

focus on the content similarity
!!!Prior Work
*''Shingle Based Algorithms''
>widely used in ''large scale DDD''
>''Border' Algorithm'':''O(N log (N/m))''(Broder et al., 1997) {{{ <m denotes the size of the main memory;N denotes the number of documents>}}}
>''Improvement:''sampling strategies proposed to reduce the ''number of shingles''  (//Refer to the paper in details//)
*''Term Based Algorithms''
>work well for ''small-scale'' IR systems and most of them also achieve good performance when used ''online''
>use ''individual terms'' (words) as the basic unit
>Many ''information retrieval'' (IR) techniques, especially feature selection, are used in these algorithms{{{   --->>more complex}}}

!!!Equations
*Document Similarity
>r(A,B) ={{{ (|S(A) ∩ S(B)|) / (|S(A)∪S(B)|)}}}
*Precision
>Precision={{{|P's ∩ Ps| / |P's|}}}
*Recall
>Recall = {{{|P's ∩ Ps| / |Ps|}}}
>>Given a dataset S, Ps denotes the duplicate document pairs detected by non-sampling DDD, and P's denotes the duplicate document pairs detected by sampling DDD
.
!!!Summary
*''Similarity Threshold''
>precision drops with the increase of similarity threshold, especially when the threshold is higher than 0.95. When high similarity threshold, greater than 0.95, is required, sampling ratio should be increased to achieve a good precision.
*''Sampling Ratio''
>precision drops with the decrease of sampling ratio, especially for small documents containing fewer than 500 words.When dealing with small documents, either similarity threshold should be decreased or sampling ratio should be raised.
*''Document Size''
>small documents are more sensitive to similarity threshold and sampling ratio than large documents. Sampling ratio can be decreased when dealing with large documents to reduce the shingles to compare.

!!!Adaptive Sampling Strategy
*''Basic idea'' 
>apply small sampling ratio to large documents and large sampling ratio to small documents
>对于''CBC模式''的AES加密,下面的代码decrypt后无法得到原始的data(输出乱码),具体原因见[[这个|http://groups.google.com/group/comp.lang.python/browse_thread/thread/d2a30ba90f4e7982?pli=1]]帖子,可以理解为加密过程中obj对象的状态会变化,导致直接用它来解密的话会失效
<code python>
from Crypto.Cipher import AES

PADDING = '\0'
pad_it = lambda s: s+(16 - len(s)%16)*PADDING
	
if __name__ == "__main__":
	key = '1234567890123456'
	data = 'qwertyuiopasdfgh'
	obj = AES.new(key, AES.MODE_CBC)
	crypt = obj.encrypt(data)
	print crypt
	recovery = obj.decrypt(crypt)  #有问题
	print recovery
</code>
>需要改成如下代码:
<code python>
from Crypto.Cipher import AES

PADDING = '\0'
pad_it = lambda s: s+(16 - len(s)%16)*PADDING	
if __name__ == "__main__":
	key = '1234567890123456'
	data = 'qwertyuiopasdfgh'
	obj = AES.new(key, AES.MODE_CBC)
	crypt = obj.encrypt(data)
	print crypt
	obj2 = AES.new(key, AES.MODE_CBC)
	recovery = obj2.decrypt(crypt)
	print recovery
</code>
>而''ECB''模式没有这个问题,因为他不是block chaining的
*日渐感觉博客作为学习记录的不足,零碎的知识需要系统、有机地管理、存储才有记录的价值。wiki以其得天独厚的''索引''、''检索''、''组织''、''共享''功能而特别适合学习的记录、资料的整理。特别是TiddlyWiki,__无需特别安装环境__,__无需数据库__,__方便携带__,特别适合我这种__个人知识管理__。
*--美中不足的是本身不提供通过网络同步功能,但有人已经hack出方法了,以后可以试试。不过只要本机有备份,在U盘中编辑,每天用TC同步一下就好了。--已经解决,在tiddlyspot注册个帐号,可以直接点击的''update''上传了。相关配置见[[这里|http://faq.tiddlyspot.com/]]
**目前由于浏览器安全策略的变化,在chrome和firefox中都无法import和upgrade了
*TiddlyWiki自己的编辑语法还是要熟悉一下,具体可以看[[TiddlyWiki说明书|http://web.nlhs.tyc.edu.tw/~lss/wiki/TiddlyWikiTutorialTW.html]],或者[[相关链接]]
*插件安装:导入对方的html文件即可,选择要安装的插件:见[[这里|http://tiddlyvault.tiddlyspot.com/]]和[[这里|http://www.tiddlytools.com/]]插件介绍
!!!Algorithm
[[心得]]
[[汉诺塔(tower of hanoi)]]
[[pascal三角(杨辉三角)]]
[[背包问题]]
[[字符串匹配]]
[[最小代价生成树]]
[[单源最短路径]]
[[装箱算法bin-packing]]
[[排序]]
[[寻找单个数]]
*''Books''
#Digraphs: Theory, Algorithms and Applications:[[相关讨论|http://bbs.sjtu.edu.cn/bbstcon?board=Algorithm&reid=1274717050]]
!!!Data Structure
*图
1、相关概念及其用处(自想):''邻接表''、''逆邻接表''、''邻接多重表''、''十字链表''
2、''DFS''、''BFS''遍历的思路(数据结构与算法交大版和Introduction to Algorithm分别有不同实现形式,但思路是一样的)
3、''最小代价生成树'':''prim''算法和''Kruscal''算法,一个是考虑''点'',一个是考虑''边'',由于算法复杂度不一样,使用情况也不一样;
4、''最短路径问题'':''Dijkstra''算法,实现、复杂度、使用情况和Prim算法差不多。
!!!框架、模板
[[STL容器和算法的选择]]
!!!密码
1、[[AES算法加密与解密]]
<html><font size=4 color=purple><b>This page is a collect of pages about records of my life</b></font></html>
*[[Junior(2ed)Extra Reading List]]
*[[Junior(2ed)OutLines]]
*[[Blogger和WordPress互相导入]]
[[wordpress2blogger|http://wordpress2blogger.appspot.com/]]
[[blogger2wordpress|http://blogger2wordpress.appspot.com/]]
[[livejournal2blogger|http://livejournal2blogger.appspot.com/]]
[[movabletype2blogger|http://movabletype2blogger.appspot.com/]]
[[google-blog-converters-appengine|http://code.google.com/p/google-blog-converters-appengine/]]
!会议
*罗伯特议事原则
''Reference:''[[here|http://c.chinaitlab.com/cckaifa/interface/200808/758701_4.html]]
1、任何类型都可以赋给void类型的,相反需要强制转换
2、C语言中,凡不加''返回类型''的,''都当作int类型''。所以函数如果没有返回值,那么应该显式声明为void类型的(有些编译器也能通过,如VC6.0,但建议一般都写上以统一)
3、若函数''没有参数'',那应显式地声明为void(若不声明,在C中若传任何参数给函数都不会报错,但这实际上是不对的)
4、按照ANSI标准,不能对''void指针'',进行任何''算法操作'';但按照GNU标准,void*的算法操作与char*的算法操作一样
5、如果函数参数是任意类型指针的,那应声明为void *类型
6、void不能用来表示真实的变量,它只是体现类型的''抽象'',故不能声明{{{void  a}}}
!!!向函数中传递指针和传递指针的引用的区别
*如果是传递指针,那么会先复制该指针,在函数内部使用的是复制后的指针,这个指针与原来的指针指向相同的地址,如果在函数内部将复制后的指针指向了另外的新的对象,那么不会影响原有的指针;
*但是对于传递指针应用,如果将传递进来的指针指向了新的对象,那么原始的指针也就指向了新的对象,这样就会造成内存泄漏,因为原来指针指向的地方已经不能再引用了,即使没有将传递进来的指针指向新的对象,而是在函数结束的时候释放了指针,那么在函数外部就不能再使用原有的指针了,因为原来的内存已经被释放
!!!指向类的成员的指针
指向数据成员的指针格式如下:
>{{{    <类型说明符> <类名>::*<指针名>}}}
指向成员函数的指针格式如下:
>{{{    <类型说明符> (<类名>::*<指针名>)(<参数表>)}}}

更详细的解释和例子见[[这里|http://www.cnblogs.com/netqer/archive/2008/10/20/1315396.html]]
!!!MySQL
*数据库中存的是中文,以MySQL默认的latin1为编码,将之导出,转换成UTF8,再以UTF8导入MySQL
>{{{(mysqldump -u root -plinux123 --default-character-set=latin1 crawlqzone | sed -e 's/CHARSET=latin1/CHARSET=utf8/g' -e "s/NAMES latin1/NAMES utf8/g" | gzip -9 > crawlqzone.2010_3_21.benjamin.utf8.sql.gz ) && (gunzip < crawlqzone.2010_3_21.benjamin.utf8.sql.gz | mysql -u root -plinux123 crawlqzone2)}}}
*[[MySQL命令行常用命令]]

!!!Shell
*处理大文件
>{{{grep -i "^a" filename.txt}}}
>>列出filename.txt中以字母a(包括A)开头的行
>{{{sed "s/ //g" filename.txt}}}
>>去掉filename.txt中所有的空格
>{{{grep -v "^SKYPE_ID" filename.txt}}}
>>显示不包括SKYPE_ID的行
>{{{grep -c "^$" filename.txt}}}
>>统计filename.txt中空行的数量
>{{{grep -c "$" filename.txt}}}
>>统计filename.txt一共有多少行
*{{{作者}}}:''Guido van Rossum''
*''{{{decimal}}}'':10进制浮点数,用于''准确表达精度''
*''{{{module}}}'':a logic way to physically organize and distinguish related pieces of Python code into individual files
*''{{{;}}}'':将几个命令连接放在一行
*''{{{built-ins}}}'':All built-ins are members of {{{__builtins__}}} module, which is automatically imported by the interpreter before programs are executed or {{{<<<}}} prompted
*''{{{_}}}''(underscore)
>''{{{_xxx}}}'':Do ''not'' import with ''from module import *''
>''{{{__xxx__}}}'':System-defined name
>''{{{__xxx}}}'':类的私有属性
*''{{{内存管理}}}''
**reference count增加的情况
***对象被创建(create)
***增加一个别名(alias)
***函数调用的参数(function call)
***加入序列中(Sequence)
**reference count减少的情况
***对象或别名被销毁(del)
***别名被赋于另外一个对象
***函数调用退出
***序列中被删除或者序列被销毁(del)
*''{{{python 对象}}}''
**''{{{type}}}''类型
***an object's set of ''inherent behaviors'' and ''characteristics'' is stored in object's ''type''
***the ''{{{type}}}'' type is mother of all types and default ''metaclass'' for all standard Python classes.
*''{{{Object Identity}}}''
**a ''is not'' b
**''id(''a'')'' ''=='' ''id(''b'')''
>>对于''整数''或者''字符串''(immutable),编译器可能会''缓存''这些对象,造成两次赋值(同样的值),它们的object identify是一样的
*''{{{Type Operators}}}'' and ''{{{Built-in Functions}}}''
**''{{{cmp}}}''(obj1, obj2)
**''{{{type}}}''(obj).{{{__name__}}}
**''{{{isinstance}}}''(obj1, obj2)
**''{{{str}}}''(obj), ''{{{repr}}}''(obj), ''{{{`}}}''obj''{{{`}}}'' operator
***''{{{repr}}}''(obj) is equal to ''{{{`}}}''obj''{{{`}}}''
***''{{{repr}}}''(obj) is Python-friendly(如直接给eval()运行) while ''{{{str}}}''(obj) is Human-friendly
***why need both  ''{{{repr}}}''(obj) and ''{{{`}}}''obj''{{{`}}}''? 
>>useful when ''passing executable objects'' like function and where ''different functions'' may be called depending on the data item.
*''{{{type factory function}}}''
>{{{list(), dict(), int()....}}}, behave like functions, actually ''class names'', when called, it actually ''initiating an instance'' of that type, like a factory
*''{{{除法}}}''
**Classic Division:
>1/2:返回''整数''0(floor division)
>1.0/2:返回''浮点数''0.5
**''{{{True Division}}}'':{{{from __future__ import division}}}
**''{{{Floor Division}}}'':''{{{//}}}''
*''{{{Bit Operator}}}''
>''Negative'' numbers are treated as their ''2's complement'' value
>Left or Right ''shift'' of N bits are equivalent to multiplication or division by ''(2**N)'' without overflow checking
>For longs, the bit operators use a "modified" form of 2's complement, acting as if the sign bit were extended infinitely to the left.
**优先级:{{{~, << and >>, &, ^, |}}}
*''{{{Built-in Number Function}}}''
**''coerce''(num1, num2)
**''divmod''(num1, num2)
**''round''(flt, ndig=0)
**''chr''(num)
**''unichr''(num)
**''ord''(chr)
*''{{{random}}}''
**''{{{randint}}}''(num1, num2)
**''{{{uniform}}}''(num1, num2):up-bound exclusive, return ''float''
**''{{{random}}}''():0.0~1.0, return ''float''
**''{{{choice}}}''(seq)
*String Concatenation
{{{
>>> f = urllib.urlopen('http://'  # protocol
... 'localhost'                   # hostname
... ':8000'                       # port
... '/cgi-bin/friends2.py')       # file
}}}
*String Format Operator
{{{
>>> 'There are %(howmany)d %(lang)s Quotation Symbols' % \
...     {'lang': 'Python', 'howmany': 3}
'There are 3 Python Quotation Symbols'
}}}
*String Template
{{{
>>> from string import Template
>>> s = Template('There are ${howmany} ${lang} Quotation Symbols')
>>>
>>> print s.substitute(lang='Python', howmany=3)
There are 3 Python Quotation Symbols
}}}
*Raw String Operator
{{{
>>> '\n'
'\n'
>>> print '\n'

>>> r'\n'
'\\n'
>>> print r'\n'
\n

>>> import re
>>> m = re.search('\\[rtfvn]', r'Hello World!\n')
>>> if m is not None: m.group()
...
>>> m = re.search(r'\\[rtfvn]', r'Hello World!\n')
>>> if m is not None: m.group()
...
'\\n'
}}}
*特殊字符和控制字符
|                  | !ASCII | !ASCII | !ASCII |
| //Decimal// | 0 | 65 | 255 |
| //Octal// | \000 | \101 | \177 |
| //Hex// | \x00 | \x41 | \xFF |
>''控制字符''的一个''作用''是:在''数据库''或者''网络数据流''中充当''限定符''(delimiter)。
*字典dict
**''dict''大小''比较''
>顺序:dict长度->Key大小(按照key的排序顺序比较)->若该''key对''相同则比较该''key对''对应的value值
**''hash()''
>可用来判断某个对象是否可以用作key
**//dict//.get(//key//, default=None)
>当不确定是否含有此//key//时可用该方法
**//dict//.setdefault(//key//, //value//)
>用途同get,不过它的效果是不存在的话直接插入该key-value对
*循环
**while....else...
*map()和filter()
*文件操作
**UNS
>当使用''U''标志打开文件时,所有行分隔符都被替换为''NEWLINE(\n)'';
>newlines保存每种换行格式的tuple
**writelines()
>''不会''自动加入行结束符
**分隔符(系统相关:''os''模块)
>linesep, sep, pathsep(如环境变量), curdir, pardir
**truncate(size=//file//.tell())
>将文件截取到size指定的位置
>默认截取到文件当前所读到的位置
*命令行参数
**sys.argv
**getopt模块(原始、简单)
**optparse模块(复杂选项)
*文件系统
**os.getcwd()
**os.chdir()
**os.listdir()
*持久化(序列化)
**''pickle''(cPickle),marshal
**anydbm,dbm...
**''shelve''
*错误和异常
<code python>
try:
    a = int(b)
    c = 1/a
except (ValueError, TypeError, ZeroDivisionError), reason:
    print "error reasion is ", reason
else:
    print "WaHa! No Error!"
finally:
    print "everything is ok"
</code>
>''except'',''finally''常用来''释放系统资源''(如文件操作符)
**with
>目前支持上下文协议的对象:file, decimal.Context, thread.LockType, threading.Lock...
**自定义异常(user-defined exception)
>参照[[官方文档|http://docs.python.org/library/exceptions.html#exceptions.Exception]]
>>All built-in, non-system-exiting exceptions are derived from this class. All user-defined exceptions should also be derived from this class.
**''sys.exc_info()''
>返回tuple:异常类、异常类的实例、跟踪记录对象
*函数与函数式编程
**函数调用完整语法
>>func(//positional_args//, //keyword_args//, *//tuple_grp_nonkw_args//, **//dict_grp_kw_args//)
**变长参数对象与函数式编程
**''函数''可以''被引用'',因此可以赋值、作为参数传递等等
**''偏函数应用''(''PFA'': Partial Function Application)
***提出的''动机''(motivation)
>>>可以理解为''部分实例化函数'',提供''函数模板''(部分参数已经指定)
***与默认参数的函数的区别
>>>每次调用偏函数都可以调用不同的参数组合(或许与''默认参数+不定长参数''等价)
***见P295的GUI例子
**''装饰器''
***提出的''动机''(motivation)
>>面向对象编程,静态类方法等问题,执行函数之前和之后的处理(清理)工作的需求,等等
***过程
###被装饰的函数作为参数传给装饰器
###装饰器(函数)返回一个''修改过的函数对象''
###将返回的函数对象''重新''赋给''原来的标识符''(''永久失去''对原始对象的访问)
***语法与例子
<code python>
def dec1(args):
    def wrappedFunc():
        print "wa ha ha"
        return func()
    return wappedFunc
def dec2:
    .......

@dec2
@dec1(args)
def func():
    ......
</code>
相当于
<code python>
def func():.......
func = dec2(dec1(args)(func))   //修改原来的函数对象,赋给原来的标识符
</code>
***应用
****引入日志;
****增加计时逻辑来检测性能;
****给函数加入事务的能力;
**''闭包''(closure)
***基本理念:根据传给函数的参数(或无参数)生成(并返回)一个函数或对象,这个函数或对象在该函数调用结束时仍存在(包括''自由变量'')
****闭包也是''函数'',不够携带了''额外的作用域''(作用域中的自由变量)
****闭包强调的''不是生命周期'',而是''运行环境''
***''自由变量''
****它定义在''外部''函数中(但''非全局变量'')但由''内部''函数引用或使用
****自由变量的引用存储在''单元对象''中,他是上层作用域结束后仍能存活的原因。它是独立的一块内存区域,故上层函数或对象的''栈空间''得以''释放''
***''用处''
****安装计算、隐藏状态、在函数对象和作用域中随意切换
****GUI或支持回调函数的事件驱动编程
**加强生成器
>>send(), close()
*''命名空间''
**加载顺序
>>内建名称空间 -> 全局名称空间 -> 局部名称空间
**查找顺序
>>局部名称空间 -> 全局名称空间 -> 内建名称空间
**{{{__buildin__}}}与{{{__buildins__}}}区别
>>参照[[官网|http://docs.python.org/library/{{{__builtin__}}}.html]],{{{__buildin__}}}是内置的模块,包含内建的对象(函数、异常等),而{{{__buildins__}}}是几乎每个模块都有的全局属性,他是{{{__buildin__}}}的超集
**无限制的名字空间
>>可以在''任何''(函数、类等)需要放置数据的地方获得命名空间,并放置数据
*''导入模块''
**模块被import时就被执行
**同样的模块即使import多次,也只load一次(第一次)
**从ZIP文件中导入模块:python将ZIP文件当作一个目录来处理
**''globals()''和''locals()''
**导入子包时需要在目录中加上{{{__init__.py}}}文件,用来初始化,可以为空
**默认是''绝对导入'';相对目录:用''{{{.}}}''表示当前目录,用''{{{..}}}''表示上一层目录,一次类推;
**阻止属性被{{{from module import *}}}导入:在不想导入的属性名称前加一个下滑下{{{_}}}
**''循环导入''问题
>>改变一个导入方式:只在需要导入的地方导入
*''执行环境''
**''Function''和''Method''的区别(另''BIF''和''BIM''的区别类似)
>>Method的''{{{__self__}}}''属性''指向''一个''Python对象'',Function的指向‘’None‘’。(从字面理解:Method<方法>属于某个对象,function只是某个''功能'')
**创建''可调用''的对象实例
>>对象实例:''obj'';可做如下调用:''obj()''
>>只需在类中实现''{{{__call__}}}''函数
**''代码对象''
***''函数(function)对象''是对''代码对象(code object)''的包装(wrapper),''方法(method)''是对''函数对象''的包装(wrapper)
***''代码对象''是执行环境的''核心''(核心代码),但它不是可调用(''callable'')的(它不含有任何''关于它执行环境的信息''),故需要上面这些''wrapper'',wrapper即callable(的对象)
***''代码对象''的真正''存在方式''是''字节码''
**‘’可执行对象‘’(''callable'')的''声明''
***''callable''
***''compile''
***''exec'':可用''文件对象''作为参数,此时类似''execfile()'',但是''execfile()''提供加入''全局和局部名称空间的集合''的参数
***''eval''
***''input'':等价于''eval(raw_input())''
**''模块作为脚本执行''
>>''python -c "...."''(命令行执行python语句)
>>''python -m CGIHTTPServer''(命令行执行模块)
**''执行非Python程序''
***''os.system()''
>>>输出到标准输出,对某些程序(如CGI程序)可能会有影响,故常与''不产生输出''的程序一起使用
***''os.popen()''
>>>system+''文件操作方式''
***''os.fork'', ''os.exec()'', ''os.wait()''
***''os.spawn'':''os.fork''+''os.exec()''
***''subprocess''模块:可替代os.system和os.popen

*''miscellaneous''
**''dir()''
>>没有参数时,return ''list'' of names in current ''local'' scope;相当于''locals().keys()''
一般采用‘'right-left‘’原则来解决:
>The right-left rule: Start reading the declaration from the innermost parentheses, go right, and then go left. 
>When you encounter parentheses, the direction should be reversed. Once everything in the parentheses
>has been parsed, jump out of it. Continue till the whole declaration has been parsed.
比较详细的解释和例子可以参考[[西邮wiki|http://xiyoulinux.org/wiki/index.php?title=%E6%B7%B1%E5%85%A5C%E8%AF%AD%E8%A8%80]]

补充:
根据西邮wiki上的这个例子:
>''int (*(*func)(int *p))[5];''
''解释:''func是个指针,指向一个函数,这个函数的参数是int类型的指针(p),它的返回值是个指针,指向的是有5个int元素的数组

可以推出:
>''void (*signal(int signo, void (*func)(int)))(int);''
''解释是:''signal是一个指针,指向一个函数,这个函数的一个参数是int,另一个参数是个函数指针(具体不解释了),signal指向的函数返回的是个指针,指针指向的是一个函数,函数的参数是int,返回值是void
[[About this]]
[[GettingStarted]]
//Vladislav Shkapenyuk Torsten Suel//

!!!Abstract
In this paper, we describe the design and implementation of a distributed web crawler that runs on a network of workstations. The crawler scales to (at least) several hundred pages per second, is resilient against system crashes and other events, and can be adapted to various crawling applications.
!!!Introduction
A crawler for a large search engine has to address two issues:
#It has to have a ''good crawling strategy'', i.e., a strategy for deciding which pages to download next;
#It needs to have a highly optimized system architecture that can ''download a large number of pages per second'' while being ''robust'' against crashes,''manageable'', and considerate of resources and web servers
!!!!Crawling Applications
*Breadth-First Crawler
*Recrawling Pages for Updates
*Focused Crawling
*Random Walking and Sampling
*Crawling the “Hidden Web”
!!!!Basic Crawler Structure
For simplicity, we separate our crawler design into two main components, referred to as ''crawling application'' and ''crawling system''.
''Crawling application:'' 
>Decides what page to request next given the current state and the previously crawled pages, and issues a stream of requests (URLs) to the crawling system.
''Crawling system:''
>''Download'' the requested pages and supplies them to the crawling application for analysis and storage. The crawling system is in charge of tasks such as ''robot exclusion'', ''speed control'', and ''DNS resolution'' that are common to most scenarios, while the application implements crawling strategies such as “breadth-first” or ”focused“
!!!!Requirements for a Crawler
*Flexibility
*Low Cost and High Performance
*Robustness
*Etiquette and Speed Control
*Manageability and Reconfigurability
!!!System Architecture
#''Small crawler configuration''  [img[Small crawler configuration|111.png]]
#'' Large configuration''  [img[ Large configuration|22.png]]
#'' Manager Data Structures''  [img[Manager Data Structures|33.png]]
!!!Comparison with Other Systems
''Mercator'' was written completely in Java, which gives flexibility through pluggable components
>One major difference to our system is that we try to completely avoid ''random I/O'', while Mercator uses ''caching'' to catch most of the random I/O, and a'' fast disk system'' to handle the still significant remaining accesses. An advantage of such a centralized system is that data can be ''directly parsed in memory'' and does not have to be written from disk as in our system.
*python是''动态''语言(不用显式声明数据类型),又是''强类型''语言([[强制类型定义|http://en.wikipedia.org/wiki/Strong_typing]]);
*并不是所有的模块都以.py结尾,进一步说,并不是所有模块都的源码都可以用,再进一步,这些模块是用C写的,如内置模块(sys等);
*''sys.path''是个''list''对象;
*Python中''“一切皆对象”'',即都有''属性''和''方法'';如所有函数都有一个内置的{{{__doc__}}}属性,返回源码定义的doc stirng;
*Python用{{{==}}}作比较,用{{{=}}}做赋值;但是Python不支持行内赋值;
*Python中''list''可以是''负值'';list的''分片'':''li[1:-1]''(第''二''个元素到''最后第二个'',第二个索引(-1)位置''不包含'')、''li[3:]''(第''四''个到''最后一个''),它返回的还是list;
*list的''添加函数'':
>''append''(末尾加''一个元素'')
>''extend''(末尾加一个list的''所有元素'')
>''区别''详见P33;
*list的''搜索函数'':
>{{{list.index("c")}}},返回位置;
>{{{"c" in li}}},返回''True''或''False''(大小写敏感);
*list的''删除函数'':
>''li.remove("c")'';
>''li.pop()''(弹出最后一个元素)
*''list''的''运算符'':{{{+=,+,*}}}:
*''连接字符串'':''list''的''join''操作,将list中的所有字符串连成一个,并用某一字符串做分割:{{{";".join(["aaa","bbb"])}}}  => {{{'aaa;bbb'}}}
*''分割字符串'':与join正好相反,但可接受第二个可选参数,表示分割的次数;
*''tuple''是不可变的list,它是常量,故可用来作为dictionary的key;tuple没有添加、删除、索引函数,但{{{''c'' in tp}}}仍然成立;tuple和list可''相互转换'';
*''dictionary''用''大括号'',list用''方括号'',tuple用''小括号'';
*定义一个''只含一个元素''的tuple时,在元素后面必须加个逗号(P42);
*字符串''之间''可以用''+''号连接,字符串和其他类型,如整数,不能用''+''连接,可以用''%s''格式化字符串;
*''and'',''or'':从左向右运算,当能判断真假是马上返回那个值,如对于''and'':
>如果布尔环境中,所有值都为真,那么整个式子为真,返回''最后一个值'';
>如果布尔环境中,某个值为假,那么整个式子为假,返回''第一个假值'';
*用and和or实现''bool?a:b''时,当不确定a是否为空时,尽量用{{{(x and [a] or [b])[0]}}},其他确定a非空时,可简化为{{{x and a or b}}};
>另,python2.5及以上提供了语法支持
<code python>
a if X else b
</code>
主要是要设置xmx参数,在Project中单独设置:
选中被运行的类,点击菜单''‘run->run...’'',选择(x)=Argument标签页下的''vm arguments''框里,输入''-Xmx800m'', 保存运行。

参照:[[问题6:内存不足 java.lang.OutOfMemoryError: Java heap space|http://hi.baidu.com/xhero2008/blog/item/20b4fe1f95f602f0e1fe0b5b.html/cmtid/655ab4a141a3f3864610647e]]
*解决方案
按照[[这里|http://empc.blog.hexun.com/52848017_d.html]]说的去掉''eclipse.ini''文件中''Xmx512m''的设置就好了

另:
*Eclipse.ini配置Sample
>[[Eclipse Wiki|http://wiki.eclipse.org/Eclipse.ini]]
*Eclipse的参数选项设置
>[[Eclipse的文档|http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/misc/runtime-options.html]]
*JVM的参数设置选项
>[[Oracle的文档|http://publib.boulder.ibm.com/infocenter/wasinfo/v4r0/index.jsp?topic=/com.ibm.websphere.v4.doc/olt_content/debugger/ref/rbcjvmar.htm]]
//George Forman  Hewlett-Packard Labs  1501 Page Mill Rd. MS 1143  Palo Alto, CA 94304 USA  george.forman@hp.com  
Kave Eshghi      Hewlett-Packard Labs   1501 Page Mill Rd. MS 1143  Palo Alto, CA 94304 USA  kave.eshghi@hp.com
Stephane Chiocchetti  Hewlett-Packard France  1 ave Du Canada, MS U215   91947 Courtaboeuf, France   stephane.chiocchetti@hp.com//

''Time:''KDD’05, August 21–24, 2005, Chicago, Illinois, USA. Copyright 2005 ACM 1-59593-135-X/05/0008 ...$5.00.

!!!ABSTRACT
It is based on chunk-ing the byte stream to find unique signatures that may be shared in multiple files. An analysis of the file-chunk graph yields clusters of related files. An optional bipartite graph partitioning algorithm can be applied to greatly increase scalability.

!!!Framework
>Break up each file into a ''sequence of chunks'' using a content-based chunking algorithm. 
>>Compute the ''hash of each chunk''. Thus each file is now represented by a list of hashes. 
>>>''Find those files'' that share chunk hashes, reporting only those whose intersection is above some threshold

!!!!File Similarity Algorithm
#For each file in the repository, ''break its content into chunks'' and for each chunk, record its byte length and its ''hash code'';
#(Optional step for scalability) ''Prune and partition'' the above metadata into independent sub-problems, each small enough to fit in memory.
#Load the file-chunk metadata into memory, constructing a bipartite graph with an edge between a file vertex and a chunk vertex i the chunk occurs in the file.
#Construct a separate ''file-file similarity graph'';
#Output the file-file similarity pairs as desired. (Use the well-known ''union-find algorithm'' to determine clusters of interconnected files)

!!!!Bipartite Partitioning
#Have the file-chunk metadata stored in a file format that contains the ''chunk hash code'' and the'' filename'' on each line
#Perform a ''disk-based sort'' on this data, At the end of this step, all the files that refer to a given chunk will be in ''adjacent lines'' in the file
#Perform the highly efficient ''union-find algorithm'' on a graph where each file is represented by a vertex
#For connected components contain only a ''single file'', and these can be immediately ''discarded'' as not being similar to any other files
#(Optional) A standard ''bin-packing algorithm'' can be used to gather together'' multiple connected-components'' that can fit in memory all at once
#Linearly ''scan the file-chunk metadata'' and output its lines into ''distinct sub-problem files'' by which partition the file has been assigned by the connected-components or optional bin-packing

!!!Some Problems
#For Bipartite Partitioning, the graph could not be partitioned. Because of one or a few chunks that represent a ubiquitous header in all the files
#the output can often include clusters of files that are similar simply because they contain a large template in common(''template similarity'')
To get started with this blank TiddlyWiki, you'll need to modify the following tiddlers:
* SiteTitle & SiteSubtitle: The title and subtitle of the site, as shown above (after saving, they will also appear in the browser title bar)
* MainMenu: The menu (usually on the left)
* DefaultTiddlers: Contains the names of the tiddlers that you want to appear when the TiddlyWiki is opened
You'll also need to enter your username for signing your edits: <<option txtUserName>>
From[[Ubuntu Geek|http://www.ubuntugeek.com/howtorecover-your-username-and-passwordfix-grub-21-error-in-ubuntu.html]]

!!Recovering Your forgotten username and password

If You just installed Ubuntu and forgot what password you selected during the installation process or one of your friend gave you ubuntu computer without giving username and password.This tutorial will help you to recover username and password

1) Turn on your computer, and as soon as you the Press Esc to enter grub message, press the escape key.

2) Select the option that says (recovery mode).

3) Your PC will boot into a shell. Once you get a command prompt, type “''passwd username''” where the username is your username. If you can’t remember your username, then you can type “''ls /home''” which should bring it up.

4) Enter a new password when prompted, and again when prompted again Type “''shutdown -r now''” to reboot your system,

That’s it. You should now be able to login with your new password.

!!Fix Grub 21 Error in Ubuntu

Problem

I’ve just tried installing Ubuntu but when it restert for the first time, GRUB returns an Error 21. I know this means that it can’t find the grub.conf file, but I don’t know how to fix this. I used Windows XP’s Recovery Console to get back into XP, but I can’t access the GRUB files.

Solution
1. Boot your computer up with Ubuntu CD

2. Open a terminal window or switch to a tty.

3. Go SuperUser (that is, type “sudo -s”). Enter root passwords as necessary.

4. Type “''grub''”

5. Type “''find /boot/grub/stage1''″. You’ll get a response like “''(hd0,1)''”.

Use whatever your computer spits out for the following lines.

6. Type “''root (hd0,1)''”, or whatever your hard disk + boot partition numbers are for Ubuntu.

7. Type “''setup (hd0)''”, to install GRUB to MBR, or “''setup (hd0,1)''” or whatever your hard disk + partition nr is, to install GRUB to a partition.

8. Quit grub by typing “''quit''”.

9. Reboot and remove the bootable CD.

Note:- In the above procedure hd0,1 is an example it might be different in your case.
!!!一般使用
#''输入''
>''java.util.Scanner''
>''参数:''String(文件名),File对象,InputStream对象,Reader对象(实现了Readable接口)
#''输出''
>''java.io.PrintWriter''
>''参数:''String(文件名),File对象,OutputStream对象,Writer对象
>它默认是有''缓存''的,故直接以String作为参数时,IO操作也是有buffer的;
#''tips'':
>1. 输出时尽量将要输出的东西''转换成String'',再一起输出;
>2. 他们的优点是:''可视化'',即打开文件即可查看内容;
!!!跨平台
#DataInputStream和DataOutputStream配对,写入字符串用writeUTF,读出的时候用readUTF,保证能读出,无论平台如何不同。
#''tips''
>1. 还有writeDouble及类似的方法,真的是写“''data''”;
>2. 由于采用JAVA''自己''的UTF编码,如字符串长度保存在字符串编码的前两个字节中,直接打开文件有可能是乱码;
!!!web
*拼接合成头像
##效果1,粉丝墙,见[[微博粉丝墙|http://fanswall.sinaapp.com/]]
###用微博账号登陆,获取粉丝的头像,拼接成特定尺寸即可
##效果2,参照[[这里|http://weibo.com/2359446855/xqo1c3Tt1]],前景是一张主照片(大照片),背景是n张小照片(可以是大照片缩放)
###大照片来源:要求用户上传(因为对像素有要求)
###小照片来源:可以要求用户上传,也可以让用户用微博账号登陆,获取其好友头像
###算法:
####得到大照片的尺寸S
####根据S,拼接小照片照片P
#####resize到一定大小(可能以人眼舒服为准——即固定大小)
#####确定每行要用的照片数
#####确保第一轮每张照片都用一次,然后不够的再''随机''挑照片填满
####将自己的大照片和用小照片拼接后的大照片进行合并(每个像素的值为两者的像素求平均?)
##效果3,参照微博应用[[粉给面子|http://weibo.com/app/detail/5epHtj]],即以某张图片(如博主头像)为模板,用n张小图片直接拼起来,通过挑选小图片的颜色来模拟模板的图案:
###该应用的效果还过得去,但感觉还是不是很美观,可以提高:
####每张小图片不是原色拼接上去,而是做一些平滑,或者和模板做一下均衡(如像素值求平均)
####或许也可以归结到效果2的问题,即用博主的小头像做前景(效果2和3的唯一区别就是前景图的大小):
#####确定目标图像大小(如500*500)
#####生成前景图片:将博主图片拉伸至目标大小
#####剩下参考效果2的算法
*用gapp engine建一个类似--http://gist.github.com--(更好的例子是代码发芽网)的网站,用来''贴代码''
*做一个''Gallery网站''(比如wordpress主题Gallery),可以参考帕兰印象[[这篇文章|http://paranimage.com/over-60-css-gallery-gallery-description-title-of/]]提到的网站做,也可以直接用[[这篇文章|http://paranimage.com/16-free-to-pay-wordpress-theme-download/]]提到的wordpress的CSS Gallery主题直接弄。再有[[这里|http://paranimage.com/27-open-source-image-manager/]]有一堆开源相册管理系统
*资源:真要做web开发时,参考[[这里|http://www.1stwebdesigner.com/resources/250-rss-feeds-for-every-graphic-web-designers-and-bloggers-to-subscribe-at/]]的blog资源。
*用GreaseMonkey做一个AlwaysSF的脚本,用来在留言显示的时候自己的留言总是SF
*做一个网站:用一个网页爬虫抓取相关信息,用Tokyo Cabinet保存,进行简单的处理,输出成网站。见这个[[视频|http://you.video.sina.com.cn/pg/topicdetail/topicPlay.php?tid=3421652&uid=1267293610&t=1#24265984]]中的介绍,他的代码在[[这里|http://github.com/hexuotzo/khufu/tree/5107c4ebc4848a27ab44c44ea9adbd9a13d75f0f]]
**或者就是个简单的新闻、图片网站,抓取各网站或者用户推荐的某一方面内容。见[[这里|http://www.douban.com/group/topic/7348717/]]
*在线拼音输入法,具体例子可见[[这里|http://www.imallen.com/pinyin/]]
*通过RSS将博客文章做成电子书:国外的例子见天涯海阁的[[介绍|http://www.web20share.com/2009/10/zinepal.html]]
>目标:支持中文,支持feedsky和FeedBurner
*博客爬虫(并在自己网站上建立镜像)
**结构
***url feeder:用于分析分析页面,制定需要爬取的url规则,输出需要爬取的URL
***crawler:多线程+压缩传输+注意内存
>>参考:simplecd作者的[[使用python爬虫抓站的一些技巧总结:进阶篇|http://obmem.info/?p=753]]
***UI
***UI山寨工具:文章见[[山寨其他网站UI的一般性工具|http://obmem.info/?p=760]],代码[[这里|http://fayaa.com/code/view/15377/]]
**特性
***支持增量:建立''索引''(文章url),或者爬取RSS
***支持参数配置:UI上配置,如代理(亦可自动切换),抓取间隔等等
**候选网站
***52NLP
***simplecd的[[作者|http://obmem.info/?tag=python]],
*人人spider
>发布博客模块(登陆+POST)
>自动踩空间机(登陆+访问某人页面)
>抓取校内某人的所有信息(个人资料、日志、状态、分享)
>校内用户设置访问权限可能是一个需要找出和绕过的地方
*类似[[Daily Todo|http://www.dailytodo.org]],但是提供轻重和缓急两个维度
*Google App Engine 
**抓取有意思的内容,如[[糗事百科|http://www.qiushibaike.com]],定时推送到肉的手机上(可放在Google App Engine 上实现定时功能)
**模仿[[ohLife|http://ohlife.com/]],定时向邮箱发一封邮件,内容为Blogger邮件发布文章的邮箱地址,回复即可记录每天心情、生活
**搞个自动跟新的网站IPv6地址文件,用于机器的代理自动配置文件调用(有V6地址的就不用挂代理了)
**NLTK的在线服务,参照[[这里|http://text-processing.com/demo/]]
*--在网页或者Blogger上放个计时器,20091130-now--
*类似玩聚SR,定制自己的推荐系统
**郑钧的思路
***《[[来,做一个社会化推荐引擎|http://www.cnblogs.com/zhengyun_ustc/archive/2008/12/22/ju690_sr.html]]》
***《[[一个想法从构思到实现只需7天|http://www.cnblogs.com/zhengyun_ustc/archive/2011/02/05/aboutidea.html]]》
***[[郑钧的博客文章|http://www.cnblogs.com/zhengyun_ustc/category/91013.html]]
***[[利用新浪微博API的Search接口做微博锐推榜|http://www.cnblogs.com/zhengyun_ustc/archive/2010/10/08/tBoard.html]]
**[[基于 Apache Mahout 构建社会化推荐引擎|http://www.ibm.com/developerworks/cn/java/j-lo-mahout/]]
*微博timeline信息重叠度分析与展示
**协助用户移除粉丝
**去重复信息,提高信息获取效率
*Phone Number to Words
**参照编程之美3.2
*github上参与项目
**如开源数据挖掘框架:[[pattern|http://www.clips.ua.ac.be/pages/pattern-en]]
!!!programming
*给DDD些一个前端,用python,或者直接CPP
*熟悉Unix Environment Programming,参考《卓有成效的程序员》,做一个''懒惰''、''傲慢''、''急躁''的程序员
*每日一句禅语(手机或电脑),禅语集来自[[这里|http://docs.google.com/Doc?docid=0AXp8ETHQRmArZGc1OTVxczZfMjc1Y3BjNzc2aGY&hl=en]]。或者是人生感悟之类的,如[[这里|http://docs.google.com/Doc?docid=0AXp8ETHQRmArZGc1OTVxczZfMzI4ZGs2cmJoYzc&hl=en]]
*Constraints Programming
>介绍:http://www.google.com.hk/search?sourceid=chrome&ie=UTF-8&q=constraints+programming
>Google的工具:https://code.google.com/p/or-tools/wiki/Welcome
*构建自己的工具库(各种语言版本):
**''profile''
**''Transcode''
**''common data structure''
*''SkyDrive Manager''
>因为它不更新了,而且最新版也无法登陆了,故参照[[SkyDrive Manager|http://jinnsblog.blogspot.com/2009/08/skydrive-manager-file-downloader.html]]的界面,开发一个新的
*解数独问题
**参考[[Solving Every Sudoku Puzzle|http://norvig.com/sudoku.html]],用Python
!!!Mobile APP
*语音日记
**单纯用语音所谓日记的缺点是:存储量大,检索不方便,查看不直观
**feature:语音识别(自动语音转文字),自动情感分类,加入图片
!!!语言学习
*用新语言来实现算法,既练习新语言,又复习算法
!!!思维体系
*工具:[[XMind|http://www.xmind.net]]
*例子:http://www.xmind.net/share/kenny_yuan/interview-bible/
!!!Algorithm
*货郎担(TSP)问题:很强大,很有用的算法,相信做map会用到不少这类算法。详见Delicious的tag(货郎担或TSP)
*Suffix Tree:字符串操作方面的算法发展到现在确实很强大,suffix tree就是其中一个,能解决不少问题。参照[[维基百科|http://en.wikipedia.org/wiki/Suffix_tree]]的资源以及硬盘上整理的论文即可;看到这个算法的缘由是做USACO上的一道题目,看[[网上的讨论|http://compsci.ca/v3/viewtopic.php?t=21923]]了解到的
!!!Love
Love letter:[[信纸完全折法|http://photo.renren.com/photo/261085754/album-359423184]]
!!!其他
*简历
**对于skills描述,可以以标签云或类似''微博关键字''的形式
**一些链接可以用二维码,如github的地址
参考[[python与java的链接嵌入互调|http://beijixuexiong.springnote.com/pages/2872534.xhtml]]
!!!Jython
所有资源(教程、文档、例子):[[Jython Documentation and Learning|http://wiki.python.org/jython/DocumentationAndEducation]]
@@bgcolor(lightgreen):主要有三个选择:''DOM'', ''SAX'' and ''StAX''@@,见StackOverflow上的[[讨论|http://stackoverflow.com/questions/2446280/what-is-the-fastest-method-to-parse-xml]]
三篇介绍文章:
*[[Java API for XML Parsing(JAXP)演进[多图]|http://dev.firnow.com/course/3_program/java/javaxl/20100628/227641.html]]
*[[ JAXP(Java API for XML Parsing) |http://blog.csdn.net/sukyle/archive/2009/05/18/4199459.aspx]]
*IBM的文档:[[使用 SAX 处理 XML 文档|http://www.ibm.com/developerworks/cn/xml/x-saxhandle/index.html]]
>对于SAX,其中的characters(char[] ch, int start, int length)函数,每次调用,参数ch的长度是有限的,所以可能content被分割成几部分,通过多次调用characters函数累加ch中需要的数据来得到,如上面IBM文档中程序的StringBuffer。

注:例子中依赖的解析包是xerces(即XMLReader所依赖的''org.apache.xerces.parsers.SAXParser''),在[[Apache主页|http://xerces.apache.org/]]下载,将压缩包中的''xercesImpl.jar''包导入项目即可。

@@bgcolor(lightgreen):其他开源项目@@
*[[apache common configuration|http://commons.apache.org/configuration/]]
>[[使用apache common configuration读取配置文件或修改配置文件|http://www.suneca.com/article.asp?id=9]]

@@bgcolor(lightgreen):总结@@
|!需求|!选择|
| 读写XML配置文件 | apache common configuration |
| 解析XML内容(包括属性等) | SAX(可以用Properties类来保存得到的Attribute) |
| 解析超大XML文件 | SAX |
*基本的''查找''、''提取''、''替换''、''分割''操作见[[这里|http://java.chinaitlab.com/advance/350770.html]]
@@color(blue):注意@@:
提取操作的典型代码可以是这样的:
<code Java>
Pattern p = Pattern.compile("<code>(.+?)</code>");
Matcher m = p.matcher("<code>xxxxxxxxo\noooooooooooo</code>");
while(m.find()){
    for(int i=0; i<m.groupCount(); i++)
	System.out.println(m.group(i+1));
}
</code>
>每次调用''m.find()''程序会在剩下的字符串中查找''pattern'';
>''m.group()''和''m.group(0)''相同,代表匹配''@@color(red):整个@@''pattern的字符串;
>''m.group(i)'',代表匹配第i个括号的字符串。其中i∈[1:groupCount()],group是指pattern中括号包含的内容
*Greedy, Reluctant and Possessive
>这几个模式都是针对数量词的,如{{{?、+、*}}}、{{{{m,n}}}},参考[[JDK文档|http://download.oracle.com/docs/cd/E17476_01/javase/1.5.0/docs/api/index.html]]和[[Pattern Greedy, Reluctant, and Possessive 扫盲|http://www.javaeye.com/topic/690617]]
>>Greedy: 整个字符串开始匹配,然后慢慢的backs off,这样就能得到最大匹配串 
>>Reluctant: 从字符串的最开始开始匹配,慢慢的增加,所以匹配到的是最小字串 
>>Possessive: greeedy + no backs off,相当于整个字符串都塞进来看,结果.*就匹配了所有串

参考:
*[[regular-expressions.info|http://www.regular-expressions.info/tutorial.html]]
*《Computer Systems: A Progammer's Perspective》
*CPP:
**《CSAPP》
**《The C Programming Language》
**《Accelerated C++》 (if has time)
**《The C++ Programming Language》(if has more time)
*《你的灯亮着吗?》
*Algorithm
**《%教科书%》
**《Introduction To Algorithm, 2ed Edition》
**……(get more on [[douban|http://www.douban.com]])
Type the text for 'Junior(2ed)OutLine'
*吸取大三上的教训:
##事倍功半,方法欠佳,没能抓住课程的特点
##要求不严格,目标不明确,得过且过
##计划性还不强,没有timestone
##心浮气躁
*需要保持:
##与同学多交流、合作
##学习时间增加了
*期望:
##保证分数的基础上,学好课程的核心东西。
##与时间为友,利用时间下脚料,勤思考、做笔记、多实践,不断审视自己花的时间是否值得
##养成良好的习惯,让理性占上风
##提升职业素养
##与实验室老师有一定接触,开始物色实习对象
*具体实施:(//总方针//: ''以分数为先决条件,课程为主线,附带学习巩固Java、CPP/C、算法'')
##每门课程孰轻孰重、孰难孰易,要花的时间孰多孰少都要心中有数
##每门课都有自己的学习、理解目标,在学的时候至少都要理解
##每个阶段、每个任务都应有timestone
<html><font size=4 color=purple><b>About this: A collect of records about my road of Linux.</b></font></html>
!!!Linux Kernel
*[[内核中针对proc文件系统的编程函数总结]]
*[[32位Ubuntu支持超过4G内存的方法]]
!!!Bash
*[[grep命令]]
*[[如何查找命令的源码]]
*[[重新(Reload)加载Bash环境变量]]
*[[ubuntu上对apt/bash加上代理(proxy)]]
!!!系统安装与配置
*[[硬盘安装Linux]]
*[[网络安装Linux]]
*[[用fstab挂载分区]]
*[[挂载大于2T硬盘]]
*[[Howto:Recover your username and password/Fix Grub 21 Error in Ubuntu]]
*[[配置vsftpd]]
*[[硬盘分区]]
!!!系统管理
*[[实时同步小文件]]
*[[Windows和Linux共享文件]]
[[Software]]中的Linux部分
/***
|''Name:''|LoadRemoteFileThroughProxy (previous LoadRemoteFileHijack)|
|''Description:''|When the TiddlyWiki file is located on the web (view over http) the content of [[SiteProxy]] tiddler is added in front of the file url. If [[SiteProxy]] does not exist "/proxy/" is added. |
|''Version:''|1.1.0|
|''Date:''|mar 17, 2007|
|''Source:''|http://tiddlywiki.bidix.info/#LoadRemoteFileHijack|
|''Author:''|BidiX (BidiX (at) bidix (dot) info)|
|''License:''|[[BSD open source license|http://tiddlywiki.bidix.info/#%5B%5BBSD%20open%20source%20license%5D%5D ]]|
|''~CoreVersion:''|2.2.0|
***/
//{{{
version.extensions.LoadRemoteFileThroughProxy = {
 major: 1, minor: 1, revision: 0, 
 date: new Date("mar 17, 2007"), 
 source: "http://tiddlywiki.bidix.info/#LoadRemoteFileThroughProxy"};

if (!window.bidix) window.bidix = {}; // bidix namespace
if (!bidix.core) bidix.core = {};

bidix.core.loadRemoteFile = loadRemoteFile;
loadRemoteFile = function(url,callback,params)
{
 if ((document.location.toString().substr(0,4) == "http") && (url.substr(0,4) == "http")){ 
 url = store.getTiddlerText("SiteProxy", "/proxy/") + url;
 }
 return bidix.core.loadRemoteFile(url,callback,params);
}
//}}}
!Catalog
[[Algorithm&DS]]
[[code]]
[[Inspiration]]
[[Linux]]
[[OS]]
[[Project]]
[[Research]]
[[Software]]
[[WebApp]]
[[Others]]
!About Tiddly
[[About this]]
[[GettingStarted]]
@@color(blue):Version@@ @@<<version>>@@
**{{{mysql -h hostname -u root -p}}}
**mysql>{{{create database [databasename];}}}
**mysql>{{{show databases;}}}
**mysql>{{{use [db name];}}}
**mysql>{{{show databases;}}}
**mysql>{{{show tables;}}}
**mysql>{{{describe [table name];}}}<//show structure of a database//>
**mysql>{{{drop database [database name];}}}<//delete a database//>
**mysql>{{{drop table [table name];}}}
**mysql>{{{SELECT * FROM [table name] WHERE name != "Bob" AND phone_number = '3444444' order by phone_number;}}}
**mysql>{{{SELECT * FROM [table name] WHERE name like "Bob%" AND phone_number = '3444444' limit 1,5;}}}<//limit to records 1 through 5.//>
**mysql>{{{SELECT * FROM [table name] WHERE rec RLIKE "^a";}}}<//Use "REGEXP BINARY" to force case-sensitivity. This finds any record beginning with a.//>
**mysql>{{{SELECT DISTINCT [column name] FROM [table name];}}}
**mysql>{{{SELECT [col1],[col2] FROM [table name] ORDER BY [col2] DESC;}}}
**mysql>{{{SELECT COUNT(*) FROM [table name];}}}<{{{SUM}}}>
**Creating a new user. Login as root. Switch to the MySQL db. Make the user. Update privs.
>>mysql>{{{use mysql;}}}
>>mysql>{{{INSERT INTO user (Host,User,Password) VALUES('%','username',PASSWORD('password'));}}}
>>mysql>{{{flush privileges;}}}
**{{{mysqladmin -u username -h hostname.blah.org -p password 'new-password'}}}<//Change a users password from unix shell.//>
**Change a users password from MySQL prompt. Login as root. Set the password. Update privs.
>>mysql>{{{SET PASSWORD FOR 'user'@'hostname' = PASSWORD('passwordhere');}}}
>>mysql>{{{flush privileges;}}}
**{{{#mysqladmin -u root password newpassword}}} <//Set a root password if there is on root password.//>
**Allow the user "bob" to connect to the server from localhost using the password "passwd". Login as root. Switch to the MySQL db. Give privs. Update privs.
>>mysql>{{{use mysql}}}
>>mysql>{{{grant usage on *.* to bob@localhost identified by 'passwd';}}}
>>mysql>{{{flush privileges;}}}
**mysql>{{{UPDATE [table name] SET Select_priv = 'Y',Insert_priv = 'Y',Update_priv = 'Y' where [field name] = 'user';}}}
**mysql>{{{alter table [table name] drop column [column name];}}}<//delete a column//>
**mysql>{{{alter table [table name] add column [new column name] varchar (20);}}}
**mysql>{{{alter table [table name] change [old column name] [new column name] varchar (50);}}}
**mysql>{{{alter table [table name] add unique ([column name]);}}}
**mysql>{{{alter table [table name] modify [column name] VARCHAR(3);}}}
**mysql>{{{alter table [table name] drop index [colmn name];}}}
**Load a CSV file into a table.
>>mysql>{{{LOAD DATA INFILE '/tmp/filename.csv' replace INTO TABLE [table name] FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n' (field1,field2,field3);}}}
**mysql>{{{mysqldump -c -u username -ppassword databasename tablename > /tmp/databasename.tablename.sql}}}
*[[不同文件系统的文件大小及分区大小限制]]
*[[分页 分段 缺页的通俗解释]]
Dennis Fetterly   Microsoft Research    1065 La Avenida     Mountain View, CA 94043     fetterly@microsoft.com
Mark Manasse   Microsoft Research    1065 La Avenida     Mountain View, CA 94043     manasse@microsoft.com
Marc Najork       Microsoft Research    1065 La Avenida     Mountain View, CA 94043     najork@microsoft.com

!!!Abstract
We found that ''29.2%'' of all web pages are ''very similar'' to other pages, and that ''22.2%'' are ''virtually identical'' to other pages.We also found that clusters of near-duplicate documents are ''fairly stable'': Two documents that are near-duplicates of one another are very likely to still be near-duplicates 10 weeks later.

!!!Concepts
''Similarity of two documents''
>number of distinct shingles appearing in both documents divided by total number of distinct shingles

!!!Experimental Framework
>Crawled HTML Documents
>>Remove HTML Tags, get pure text
>>>Segment into 5-word shingles
>>>>Compute 64-bit checksum of each shingle(get ''pre-image''), using ''Robin's fingerprinting algorithm''
>>>>>Apply 84 one-one function to each pre-image, get pre-images' ''images''
>>>>>>For each ''function'', get the ''pre-images'' whose image is numerically smallest; Thus get 84 pre-images.({{{Sampling}}})
>>>>>>>Get 6 ''supershingles''(supershingle represents the concatenation of 14 adjacent pre-images)
>>>>>>>>To each document, concatenate all pairs of distinct supershingles, thus getting 6 choose 2(15) ''megashingles''
>>>>>>>>>Using ''hashtable'', get <megashingles ,DocumentID>
>>>>>>>>>>Maintain cluster, build Union-Find data structure.
[[Book]]
[[Blog]]
[[Commands]]
[[Wiki]]
[[数据库大作业]]
[[Tokyo Cabinet数据库]]
[[笔&面试题]]
[[Word长篇文档排版技巧]]
[[iTouch指南]]
[[液晶电视(带网络功能)备选]]
/***
|''Name:''|PasswordOptionPlugin|
|''Description:''|Extends TiddlyWiki options with non encrypted password option.|
|''Version:''|1.0.2|
|''Date:''|Apr 19, 2007|
|''Source:''|http://tiddlywiki.bidix.info/#PasswordOptionPlugin|
|''Author:''|BidiX (BidiX (at) bidix (dot) info)|
|''License:''|[[BSD open source license|http://tiddlywiki.bidix.info/#%5B%5BBSD%20open%20source%20license%5D%5D ]]|
|''~CoreVersion:''|2.2.0 (Beta 5)|
***/
//{{{
version.extensions.PasswordOptionPlugin = {
	major: 1, minor: 0, revision: 2, 
	date: new Date("Apr 19, 2007"),
	source: 'http://tiddlywiki.bidix.info/#PasswordOptionPlugin',
	author: 'BidiX (BidiX (at) bidix (dot) info',
	license: '[[BSD open source license|http://tiddlywiki.bidix.info/#%5B%5BBSD%20open%20source%20license%5D%5D]]',
	coreVersion: '2.2.0 (Beta 5)'
};

config.macros.option.passwordCheckboxLabel = "Save this password on this computer";
config.macros.option.passwordInputType = "password"; // password | text
setStylesheet(".pasOptionInput {width: 11em;}\n","passwordInputTypeStyle");

merge(config.macros.option.types, {
	'pas': {
		elementType: "input",
		valueField: "value",
		eventName: "onkeyup",
		className: "pasOptionInput",
		typeValue: config.macros.option.passwordInputType,
		create: function(place,type,opt,className,desc) {
			// password field
			config.macros.option.genericCreate(place,'pas',opt,className,desc);
			// checkbox linked with this password "save this password on this computer"
			config.macros.option.genericCreate(place,'chk','chk'+opt,className,desc);			
			// text savePasswordCheckboxLabel
			place.appendChild(document.createTextNode(config.macros.option.passwordCheckboxLabel));
		},
		onChange: config.macros.option.genericOnChange
	}
});

merge(config.optionHandlers['chk'], {
	get: function(name) {
		// is there an option linked with this chk ?
		var opt = name.substr(3);
		if (config.options[opt]) 
			saveOptionCookie(opt);
		return config.options[name] ? "true" : "false";
	}
});

merge(config.optionHandlers, {
	'pas': {
 		get: function(name) {
			if (config.options["chk"+name]) {
				return encodeCookie(config.options[name].toString());
			} else {
				return "";
			}
		},
		set: function(name,value) {config.options[name] = decodeCookie(value);}
	}
});

// need to reload options to load passwordOptions
loadOptionsCookie();

/*
if (!config.options['pasPassword'])
	config.options['pasPassword'] = '';

merge(config.optionsDesc,{
		pasPassword: "Test password"
	});
*/
//}}}
!!!zhaoren.me
!!!!MySQL与的Django中文配置
编码要统一,由于Django默认是UTF8,所以MySQL最好也都统一成UTF8
1,MySQL配置
#在''建立数据库之前'',配置MySQL的配置文件,参考:[[这里|http://xanderzhang.javaeye.com/blog/465545]],搜索其中的utf8配置项进行配置
#建立数据库(可用Django的''syncdb''命令自动创建)
#进入MySQL命令行,用命令:{{{SHOW VARIABLES LIKE "chara%"}}}来查看编码,正常应该是除了一个为''binary''以外,其他都是''utf8'';用命令{{{SHOW VARIABLES LIKE "colla%"}}}查看collation信息
>如果有以后数据,那么参考[[这里|http://blog.jxwmw.cn/u/2/archives/2008/2805.html]]和[[这里|http://blog.chinaunix.net/u2/88611/showart_2079839.html]]

2,Django配置
#参照上面那篇[[文章|http://xanderzhang.javaeye.com/blog/465545]],主要设置DEFAULT_CHARSET
!!!!sqlalchemy中文问题
参考[[这篇|http://firefish.blog.51cto.com/298258/112794]]文章,只需''传递参数(charset=utf8)即可''
>{{{create_engine('mysql://uid:pwd@localhost/mydb?charset=utf8', echo=True)}}}

!!!52Pai
!!!!flickr照片上传器
源码:[[这里|http://code.google.com/p/teloon-works/source/browse/trunk/python/picuploadflickr.py]]
编码可能涉及的库:
>ClientCookie 用来结果Cookies交接的问题(如从HOST为.yahoo.com跳到.flickr.com)
>ClientForm 用来提交Form
>BeautifulSoup
''参考文献'':
>[[康爷的博客|http://kangye.org/get-started-with-flickr-api]]
>[[Flickr API官方文档|http://www.flickr.com/services/api/]]
>[[申请Flickr API key的地址|http://www.flickr.com/services/api/keys/apply/]]
>[[Flickr Authentication API使用的官方介绍|http://www.flickr.com/services/api/auth.spec.html]]
>[[Flickr API的Python类库|http://www.stuvel.eu/projects/flickrapi]]
!!!!Image Resizer 4 Mobile Phone
源码在GoogleCode上:[[传送门|http://code.google.com/p/teloon-works/source/browse/trunk/java/ImageResizer/JPGResizer.java]]
基本思路:
#用JPEGDecoder读取jpg的头信息以及像素矩阵:[[传送门|http://blog.csdn.net/hunhun1981/archive/2008/04/10/2276086.aspx]],亦可用''com.sun.image.codec.jpeg.JPEGImageDecoder'',但未尝试
#用最邻近插值算法和双线性内插值算法缩小图像,生成新的像素矩阵:[[传送门1|http://blog.csdn.net/qiqi5521/archive/2008/03/22/2207562.aspx]],[[传送门2|http://blog.csdn.net/alucardpj/archive/2005/12/08/547045.aspx]], [[传送门3|http://school.ogdev.net/ArticleShow.asp?id=5740&categoryid=5]]
#用如下方法生成JPEG图像:
**以像素矩阵为参数构造MemoryImageSource对象mi
**生成Image对象
>{{{im = mi.createImage(mi);}}}
**生成BufferedImage对象
>{{{BufferedImage bi = new BufferedImage(outputWidth, outputHeight, BufferedImage.TYPE_INT_RGB);}}}
**写入Image对象im:
>{{{Graphics2D biContext = bi.createGraphics();}}}
>{{{biContext.drawImage(outputImage, 0, 0, null);}}}
**Encoding:
>>{{{// Note that additional drawing such as watermarks or logos can be placed here.}}}
>>{{{// com.sun.image.codec.jpeg package is included in sun and ibm sdk 1.3}}}
>{{{JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(outputStream);}}}
>>{{{// The default quality is 0.75.}}}
>{{{JPEGEncodeParam jep = JPEGCodec.getDefaultJPEGEncodeParam(bi);}}}
>{{{jep.setQuality(outputQuality, true);}}}
>{{{encoder.encode(bi, jep);}}}
>>{{{// encoder.encode( bi );}}}
>{{{outputStream.flush();}}}

参考:
*[[Java数字图像处理常用算法|http://pengxiao.blog.ccidnet.com/blog-htm-do-showone-uid-64111-type-blog-itemid-202105.html]]
*[[ 图形图像处理-之-高质量的快速的图像缩放系列|http://blog.csdn.net/housisong/category/325273.aspx?PageNumber=2]]
*[[用java保存位图文件|http://blog.sina.com.cn/s/blog_4ee74fe201000dht.html?retcode=0]]

!!!版本管理
!!!!git
教程:
#简明教程:[[这里|http://blog.interlinked.org/tutorials/git.html]]和[[Linux kernel|http://www.kernel.org/pub/software/scm/git/docs/gittutorial.html]]
#[[git&github on windows|http://kylecordes.com/2008/04/30/git-windows-go]]
#[[看日记学git|http://roclinux.cn/?p=178]]
*原理流程
[img[http://blog.interlinked.org/static/images/git/high-level-commands.png]]
!!!!SVN
培训教程:[[从VSS到SVN|http://lilyonwind.spaces.live.com/blog/cns!74592F9522995EEF!231.entry]]
[[学习PyQt之资料收集篇|http://vvonderblog.appspot.com/2009/12/22/learning-pyqt-about-resources.html]]
[[pyqt编写的程序如何发布|http://blog.linjunhalida.com/tag/python-pyqt/]]

*@@bgcolor(lightblue):实例@@
**[[PyQt编写Google翻译客户端程序|http://vvonderblog.appspot.com/2009/12/23/pyqt-google-translate-client.html]]
**[[PyQt4 编程简介与实例|http://pyqt-doc-cn.googlecode.com/svn/trunk/Introduction_to_PyQT4/doc/r54/index.html]]
**PyQt界面与事件分离:[[在Eric4下用PyQt4编写Python的图形界面程序|http://hi.baidu.com/runningon/blog/item/115662279ff36a06918f9d0b.html]]
*{{{import code;code.interact(local=locals())}}}
*{{{import pdb;pdb.set_trace()}}}
>抑或{{{ipdb}}},更好地彩色显示
*{{{import logging;logging.basicConfig(level=...);logging.debug("...")}}}
<code python>
#获得断点的信息
import logging
log = logging.getLogger('')  # generic channel ''
log.debug('blah')            # path and line number reported correctly
...
</code>
*IDLE、Pydev都有debugger

参考1:[[Python Debugging Techniques|http://aymanh.com/python-debugging-techniques]]
!!!小文件,不考虑性能
可以使用[[BeautifulSoup|http://stackoverflow.com/questions/1922032/parsing-html-in-python-lxml-or-beautifulsoup-which-of-these-is-better-for-what]],它接口比较清晰明了。
!!!较大文件,考虑性能
看[[这里|http://blog.ianbicking.org/2008/03/30/python-html-parser-performance/]]的性能比较,lxml有绝对的优势,不过没用过。也[[有人说|http://stackoverflow.com/questions/1922032/parsing-html-in-python-lxml-or-beautifulsoup-which-of-these-is-better-for-what]]BeautifulSoup不再维护了,而且lxml也提供了BS的接口形式(lxml.soupparser),有空可以试试。但貌似它也是要将文件载入内存的,待证实。
!!!极大文件,考虑性能
需要顺序遍历文件,选择cElementTree,详见这里的讨论:[[What is the fastest way to parse large XML docs in Python?|http://stackoverflow.com/questions/324214/what-is-the-fastest-way-to-parse-large-xml-docs-in-python]]。从[[Benchmark|http://effbot.org/zone/celementtree.htm#benchmarks]]来看,性能很不错。测试来看,肯定是顺序遍历的,因为对一个2.5G的XML文件操作表示压力不大。
*相关资源
>元素遍历的例子:[[官网|http://effbot.org/zone/element-iterparse.htm]]
>官方的一些文档:[[这里|http://effbot.org/zone/element-index.htm#documentation]]
>一些元素操作的API:[[好用的python cElementTree|http://blog.csdn.net/gisocean/archive/2007/12/08/1924580.aspx]]
*缺点
>容错性较差,在遇到一些特殊字符时容易出错(如邱博的百度知道语料line 2258, column 28)
*[[python-excel|http://www.python-excel.org/]]
**‘’例子‘’见[[Read Excel files from Python|http://scienceoss.com/read-excel-files-from-python/]]
**‘’缺点‘’是不能处理xlsx
*[[openpyxl|http://ericgazoni.wordpress.com/2010/04/10/openpyxl-python-xlsx/]]
**用于写xlsx,这篇文章中提到了已有的一些读xlsx的方法
*使用''pywin32''
**他能''读写xlsx''
**见介绍:[[Python Excel Mini Cookbook|http://www.pythonexcels.com/2009/10/python-excel-mini-cookbook/]]
*遍历文件树
>os.walk
>>参考[[这里|http://blog.csdn.net/foyuan/archive/2007/07/28/1713659.aspx]]
*文件以及目录操作
>参考[[这里|http://www.phpfans.net/article/htmls/201004/Mjg0MDAy.html]]
*读取文件
**读取所有或指定字节数
>>read(), read(N)
**按行读取
>>readline(), readlines()
>>>更有效率的生成器:{{{(l for l in open('xxx.txt', 'r'))}}}
*遍历目录
>''os.walk''
>>返回类似'' [('C:\\",['System','Program','Windows','Temp'],['sys.page','a.txt']),...] ''
**参考[[这里|http://blog.csdn.net/foyuan/archive/2007/07/28/1713659.aspx]]
**其他包括''拷贝''、''删除''、''移动''、''重命名''、''文件名切割''、''扩展名切割''等等见[[Python 操作文件及目录|http://www.91linux.com/html/article/program/python/20100414/19191.html]]
*Python读取文件内容
>读取全部内容、按行、按字节、生成器等,见[[Python读取文件|http://book.51cto.com/art/201005/198283.htm]]和[[如何让我读一次两行从文件中使用Python|http://audbel.com/0/9927561]]
{{{
	for line in (l for l in open("D:/work/torte.vim", 'r')):
	...print line
}}}
!!!访问MySQL
MySQLdb模块:[[Writing MySQL Scripts with Python DB-API|http://www.kitebird.com/articles/pydbapi.html]]
*问题
**默认它是全读进内存,在大数据的情况下如何一行行读?
>解决:默认其实是Client模式(见[[文档|http://mysql-python.sourceforge.net/MySQLdb-1.2.2/public/MySQLdb.cursors-module.html]]),即将结果保存在Client端,可以通过设置cursor参数保存在Server端,见StackOverflow的讨论[[How to get a row-by-row MySQL ResultSet in python|http://stackoverflow.com/questions/337479]]
!!!访问oracle
*''cx_Oracle''+''Oracle Instant Client''
**ziclix:[[Python在Windows下如何连接Oracle数据库|http://star-word.appspot.com/2010/09/11/python_window_oracle_library.html]]
>问题:出现{{{Unable to acquire Oracle environment handle}}}错误,暂无解决方案。可能''完全安装''Oracle可行,但''未尝试''
*''Jython''+''ojdbc''
**教程:[[使用Jython连接Oracle |http://zrmeng.itpub.net/post/4141/18365]]
>安装jython,下载oracle instant client
>需要两个包:''zxJDBC.JAR''和''ojdbc*.jar'',他们分别在''jython.jar''和instant client中的''ojdbc6.jar'',将这两个包加入''CLASSPATH''即可
>将下面代码存为test.py,运行jython test.py即可
<code python>
from com.ziclix.python.sql import zxJDBC
d,u,p,v="jdbc:oracle:thin:@172.16.5.15:1521:abc","username","password","oracle.jdbc.driver.OracleDriver"
db=zxJDBC.connect(d,u,p,v)
c=db.cursor()
c.execute("select 'aaa' from dual")
for a in c.fetchall():
  print a
c.close
db.close
</code>
**''DriverManager'':直接当作java来写,参照[[java访问oracle|http://www.programfan.com/article/2843.html]]
<code python>
    driver = "oracle.jdbc.driver.OracleDriver"
    url = "jdbc:oracle:thin:@10.141.200.199:1522:orcl"
    db = DriverManager.getConnection(url, 'system', 'admin')
    st = db.prepareStatement("select * from ILLEGAL_DOC")
    res = st.executeQuery()
</code>
!!Parse Tree
@@bgcolor(red): Tools@@
*''Stanford Parser''
#以多种[[Treebank|http://en.wikipedia.org/wiki/Treebank]]的形式''输出'',单独遍历树的内容在''{{{edu.stanford.nlp.trees.Tree}}}''
#若要''读取Treebank'',则可参照''{{{edu.stanford.nlp.trees,PennTreeReader}}}''的方式,一篇[[博客说明|http://blog.outerthoughts.com/2007/06/laying-out-penn-treebank-output-of-stanford-parser/]]
*''图形化输出''
#''Graphviz''(Java)
>见博客[[visualizing-citeulike-collections|http://blog.outerthoughts.com/2009/01/visualizing-citeulike-collections/]]和[[laying-out-penn-treebank-output-of-stanford-parser|http://blog.outerthoughts.com/2007/06/laying-out-penn-treebank-output-of-stanford-parser/]]提到的

[[评价标准(Evaluation)]]


!!语料库
*''英文''
#''[[WordNet|http://wordnet.princeton.edu/]]''® is a large lexical database of English,developed under the direction of George A. Miller. Nouns, verbs, adjectives and adverbs are grouped into sets of cognitive synonyms (synsets).

!!Papers
*''Duplicate Document Detection''
[[Finding Similar Files in Large Document Repositories]]
[[Design and Implementation of a High-Performance Distributed Web Crawler]]
[[A systematic study on parameter correlations in large scale duplicate document detection]]
[[On the Evolution of Clusters of Near-DuplicateWeb Pages]]
[[Using Bloom Filters to Refine Web Search Results]]
[[一种基于LCS 的相似网页检测算法]]
[[unassorted]]
Here is an incomplete list of some excellent TiddlyWiki resource pages. If you want to be listed here, just email me at "jim at barr dot net" and I will gladly add your site!

|[[TiddlyWiki|http://TiddlyWiki.com]] |Jeremy Ruston's official home of TiddlyWiki |
|[[TiddlyForge|http://www.tiddlyforge.net]] |A news and Plugin/macro resource site from Devon Jones |
|[[Monkey Pirate TiddlyWiki|http://simonbaird.com/mptw/]] |Simon Baird's excellent [[TagglyTagging|http://simonbaird.com/mptw1/#TagglyTagging]] site |
|[[TiddlyTools|http://www.elsdesign.com/tiddlywiki/tiddlytools.html]] |ELS Design Studios' Tools page featuring lots of excellent Plugins |
|[[Tutorial|http://www.blogjones.com/TiddlyWikiTutorial.html]] |A hands-on Tutorial|
|[[Overview|http://euicho.com/index.php?p=123]] |A great overview of TiddlyWiki by Euicho|
|[[TiddlyWikiTips|http://TiddlyWikiTips.com]] |TiddlyWiki Tips Resource (This site!) |
|[[zRenard's TiddlyWiki Tips|http://www.zrenard.com/tiddlywiki/]] |Some Tips, Tools, and Styles for TiddlyWiki |
|[[TiddlyWiki discussion forum|http://groups.google.com/group/TiddlyWiki]] |A Google Group devoted to all things TiddlyWiki |
|[[Developer discussion forum|http://groups.google.com/group/TiddlyWikiDev]] |A Google Group focusing on TiddlyWiki development |
|[[TiddlyWikiRequests|http://groups.google.com/group/TiddlyWikiRequests?lnk=li]] |A Google Group managing feature request discussions |
*''adapter''
**''stack''
>可用deque(默认)、vector、list实现
**''queue''
>可用deque(默认)、list实现
**''priority_queue''
>可用vector(默认)、deque、最大(小)化堆

*''priority_queue的内部排序''
priority_queue默认是按最大化堆排列的,所以如果用默认的less比较函数(或者functor),pop操作出来的是值最大的元素(即堆的根节点),相反如果显式地传入greater(STL提供)函数或者自定义的greater比较函数(或functor),则是按照最小堆排列的,pop出来的是最小值。
''注:'' 如果要自己制定比较函数(或Functor),那么必须是''3个参数'',即''第二个''必须指定用什么容器实现优先队列;

见代码:
<code c>
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

class mycomparison
{
  bool reverse;
public:
  mycomparison(const bool& revparam=false)
    {reverse=revparam;}
  bool operator() (const int& lhs, const int&rhs) const
  {
    if (reverse) return (lhs>rhs);
    else return (lhs<rhs);
  }
};

int main ()
{
  // using mycomparison:
  priority_queue< int, ''vector<int>'', mycomparison > fourth(mycomparison(false));

  fourth.push(10);
  fourth.push(60);
  fourth.push(50);
  fourth.push(20);
  for(int i=0; i<4; ++i){
	cout << fourth.top() << " ";
	fourth.pop();
}

  return 0;
}
</code>

输出:
>10 20 50 60
如果把true改成false就是默认的less比较,输出“60 50 20 10”

*''容器中的begin和front''
两者都是指向容器的第一个元素,不同的在于begin返回的是迭代器,需要进一步用指针操作符才能得到元素,而front直接返回元素,可以对元素进行+1,-1操作等等。详见cplusplus文档

*''list中的merge操作的过程''
如下官方解释:
>The merging is performed using two iterators: one to iterate through x and another one to keep the insertion point in the list object; During the iteration of x, if the current element in x compares less than the element at the current insertion point in the list object, the element is removed from x and inserted into that location, otherwise the insertion point is advanced. This operation is repeated until either end is reached, in which moment the remaining elements of x (if any) are moved to the end of the list object and the function returns (this last operation is performed in constant time).
总之是有两个''单向''的指针,是一直往前的,找到位置就插入(并删除本身),直到结束

*''list的remove_if函数''
以Predicate类为参数,它他也是个functor,重载()操作符;或者也可以用比较函数为参数,不过只要返回bool就好了,不管是<还是>还是==,因为它只是作为一个条件存在。详见[[这里|http://www.cplusplus.com/reference/stl/list/remove_if/]]
也可以用STL的not_euqal_to<int>(),less<int>()操作等,需要的只是把这些操作的第二个参数固定(或者说绑定),用的函数是bind2nd()。详见[[cplusplus|http://www.cplusplus.com/reference/std/functional/bind2nd/]]

*''STL内部各种算法、结构的实现''
#''stable_sort''是稳定的排序,因为他是用merge sort实现的
#''sort''在n<10的时候也是稳定的,因为这时是插入排序
#''set''通常是红-黑树实现,这样查找、插入、删除的代价都是O(log(n))的
#''stack''默认是用deque来实现,但在初始化的时候可以指定为vector或list
#''queue''默认也是用deque来实现,但在初始化的时候可以指定为list(''不能使vector'',因为无法pop_front)

*''一些容易忘记的函数''
1,''排序''
>''partial_sort''、''partial_sort_copy''、''partition''
2,''deque''
>''merge''、''insert(pos, size, value)''
3,''list''
>''splice''、''remove_if(bind2nd(not_equal_to<int>(), value))''
4, ''deque''
>''erase''、''insert''、双端操作及取值
5, ''bitset''
>''constructor'', ''set'',''any'',''none'',''flip'', ''operator[]'',
容器中insert操作是拷贝对象的,当容器的元素较大时,会引起效率问题,这时要用指针。
STL中默认的是aotu_ptr,是一个智能指针,他会帮你管理内存,但是它不是完美的,在容器中的一个重大问题就是会产生指针所有权转移的问题,这也是C++标准强烈反对在容器中使用auto_ptr的原因。所以要用更智能的指针才行。
选择时首先要考虑是否胜任,其次考虑效率。具体没有研究过,可以参考Effective STL和[[这里|http://www.cppblog.com/expter/archive/2009/03/29/78270.aspx]],暂时用的是boost的[[shared_ptr|http://www.boost.org/doc/libs/1_39_0/libs/smart_ptr/shared_ptr.htm]]

具体讨论见YSSY C板版主的[[解释|http://bbs.sjtu.edu.cn/bbstcon,board,C,reid,1251073759.html]]
|!需求|!选择|
|''自排序''的容器|set、map|
|''随机''访问|vector、deque|
|内部''删除''|考虑效率:list自带的erase(itr)和remove、remove_if<删除全部>;不考虑效率:vector+自带的erase(itr)或remove<删除全部>|
|内部''插入''|deque,list,vector|
|双端''插入''、''删除''|deque,list,queue|
|FILO|stack|
|''查找''单个|1,  map,set的find<键查找>;2,  ''find,find_if''<algorithm>|
|''查找''"子串"|''search,find_end''<algorithm>|
|''查找''"子串"中的一个|''find_first_of''<algorithm>|
''注'':list的iterator不支持算术运算(但是++还是被重载的),也不支持关系运算;算术运算可以用advance函数来弥补,但''当心越界''!
Wiki as fun; Wiki as note; Wiki as study
Teloon's TiddlyWiki
[[foobar显示歌词心得]]
[[使用Bookmarklet+Google CSE提升搜索效率]]
[[VNC Server配置]]
[[数据恢复软件]]
[[转录软件(语音识别)]]

!!!Linux
*''Kodos'' 是一个用于创建、测试、及调试正则表达式的图形化工具。因 Kodos 使用的正则表达式引擎是基于 PCRE 标准实现的,所以除了 Python 外,Kodos 也可被用于 Perl、PHP 等其他程序语言。(Win平台也有)
*[[wine指南]]
*[[一次安装闭源的“解码器、flashplayer、java虚拟机、微软字体”]]
*[[播放器可以解码、但停止不动的解决方案]]

!!!VIM
*[[vim配置]]
*[[vim命令]]
*[[VIM多标签切换]]

!!!智能手机
!!!!S60
[[塞班木马专杀|http://bbs.dospy.com/thread-5825635-1-1.html]](在线检测平台:[[here|http://cha.dospy.com/]])
#系统目录查看:''X-plore''
#系统进程查看:''易安信'',''掌中任务''
#十大流氓软件:
##手机无贼CellGuard3
##商务管家
##手机商务助手
##美通无线音乐播放器 mTunes
##主题管家SkinManager
##吾主题
##拇指精灵Findia
##迷迷之音
##手机大头 Datuu/旅行通/掌影无限/网络加速/万花筒

!!!程序开发
[[推荐安装的软件]]
[[Eclipse:''failed to create the java virtual machine''错误]]
[[Eclipse:''Exception in thread "main" java.lang.OutOfMemoryError: Java heap space''错误]]
[[StyleSheetSyntaxHighlighter]]
/***
StyleSheet for ~SyntaxHighlighter
***/

/*{{{*/
.dp-highlighter
{
	font-family: "Consolas", "Courier New", Courier, mono, serif;
	font-size: 12px;
	background-color: #E7E5DC;
	width: 99%;
	overflow: auto;
	margin: 18px 0 18px 0 !important;
	padding-top: 1px; /* adds a little border on top when controls are hidden */
}

/* clear styles */
.dp-highlighter ol,
.dp-highlighter ol li,
.dp-highlighter ol li span 
{
	margin: 0;
	padding: 0;
	border: none;
}

.dp-highlighter a,
.dp-highlighter a:hover
{
	background: none;
	border: none;
	padding: 0;
	margin: 0;
}

.dp-highlighter .bar
{
	padding-left: 45px;
}

.dp-highlighter.collapsed .bar,
.dp-highlighter.nogutter .bar
{
	padding-left: 0px;
}

.dp-highlighter ol
{
	list-style: decimal; /* for ie */
	background-color: #fff;
	margin: 0px 0px 1px 45px !important; /* 1px bottom margin seems to fix occasional Firefox scrolling */
	padding: 0px;
	color: #5C5C5C;
}

.dp-highlighter.nogutter ol,
.dp-highlighter.nogutter ol li
{
	list-style: none !important;
	margin-left: 0px !important;
}

.dp-highlighter ol li,
.dp-highlighter .columns div
{
	list-style: decimal-leading-zero; /* better look for others, override cascade from OL */
	list-style-position: outside !important;
	border-left: 3px solid #6CE26C;
	background-color: #F8F8F8;
	color: #5C5C5C;
	padding: 0 3px 0 10px !important;
	margin: 0 !important;
	line-height: 14px;
}

.dp-highlighter.nogutter ol li,
.dp-highlighter.nogutter .columns div
{
	border: 0;
}

.dp-highlighter .columns
{
	background-color: #F8F8F8;
	color: gray;
	overflow: hidden;
	width: 100%;
}

.dp-highlighter .columns div
{
	padding-bottom: 5px;
}

.dp-highlighter ol li.alt
{
	background-color: #FFF;
	color: inherit;
}

.dp-highlighter ol li span
{
	color: black;
	background-color: inherit;
}

/* Adjust some properties when collapsed */

.dp-highlighter.collapsed ol
{
	margin: 0px;
}

.dp-highlighter.collapsed ol li
{
	display: none;
}

/* Additional modifications when in print-view */

.dp-highlighter.printing
{
	border: none;
}

.dp-highlighter.printing .tools
{
	display: none !important;
}

.dp-highlighter.printing li
{
	display: list-item !important;
}

/* Styles for the tools */

.dp-highlighter .tools
{
	padding: 3px 8px 3px 10px;
	font: 9px Verdana, Geneva, Arial, Helvetica, sans-serif;
	color: silver;
	background-color: #f8f8f8;
	padding-bottom: 10px;
	border-left: 3px solid #6CE26C;
}

.dp-highlighter.nogutter .tools
{
	border-left: 0;
}

.dp-highlighter.collapsed .tools
{
	border-bottom: 0;
}

.dp-highlighter .tools a
{
	font-size: 9px;
	color: #a0a0a0;
	background-color: inherit;
	text-decoration: none;
	margin-right: 10px;
}

.dp-highlighter .tools a:hover
{
	color: red;
	background-color: inherit;
	text-decoration: underline;
}

/* About dialog styles */

.dp-about { background-color: #fff; color: #333; margin: 0px; padding: 0px; }
.dp-about table { width: 100%; height: 100%; font-size: 11px; font-family: Tahoma, Verdana, Arial, sans-serif !important; }
.dp-about td { padding: 10px; vertical-align: top; }
.dp-about .copy { border-bottom: 1px solid #ACA899; height: 95%; }
.dp-about .title { color: red; background-color: inherit; font-weight: bold; }
.dp-about .para { margin: 0 0 4px 0; }
.dp-about .footer { background-color: #ECEADB; color: #333; border-top: 1px solid #fff; text-align: right; }
.dp-about .close { font-size: 11px; font-family: Tahoma, Verdana, Arial, sans-serif !important; background-color: #ECEADB; color: #333; width: 60px; height: 22px; }

/* Language specific styles */

.dp-highlighter .comment, .dp-highlighter .comments { color: #008200; background-color: inherit; }
.dp-highlighter .string { color: blue; background-color: inherit; }
.dp-highlighter .keyword { color: #069; font-weight: bold; background-color: inherit; }
.dp-highlighter .preprocessor { color: gray; background-color: inherit; }

/*}}}*/
/***
!Metadata:
|''Name:''|SyntaxHighlighterPlugin|
|''Description:''|Code Syntax Highlighter Plugin for TiddlyWiki.|
|''Version:''|1.1.3|
|''Date:''|Oct 24, 2008|
|''Source:''|http://www.coolcode.cn/show-310-1.html|
|''Author:''|Ma Bingyao (andot (at) ujn (dot) edu (dot) cn)|
|''License:''|[[GNU Lesser General Public License|http://www.gnu.org/licenses/lgpl.txt]]|
|''~CoreVersion:''|2.4.1|
|''Browser:''|Firefox 1.5+; InternetExplorer 6.0; Safari; Opera; Chrome; etc.|

!Syntax:
{{{
<code options>
codes
</code>
}}}

!Examples:
{{{
<code java>
public class HelloWorld {
    public static void main(String args[]) {
        System.out.println("HelloWorld!");
    }
}
</code>
}}}

!Revision History:
|''Version''|''Date''|''Note''|
|1.1.2|Oct 15, 2008|Optimize Highlight|
|1.0.0|Oct 13, 2008|Initial release|

!Code section:
***/
//{{{
var dp={sh:{Toolbar:{},Utils:{},RegexLib:{},Brushes:{},Strings:{AboutDialog:"<html><head><title>About...</title></head><body class=\"dp-about\"><table cellspacing=\"0\"><tr><td class=\"copy\"><p class=\"title\">dp.SyntaxHighlighter</div><div class=\"para\">Version: {V}</p><p><a href=\"http://www.dreamprojections.com/syntaxhighlighter/?ref=about\" target=\"_blank\">http://www.dreamprojections.com/syntaxhighlighter</a></p>&copy;2004-2007 Alex Gorbatchev.</td></tr><tr><td class=\"footer\"><input type=\"button\" class=\"close\" value=\"OK\" onClick=\"window.close()\"/></td></tr></table></body></html>"},ClipboardSwf:null,Version:"1.5.1"}};dp.SyntaxHighlighter=dp.sh;dp.sh.Toolbar.Commands={ExpandSource:{label:"+ expand source",check:function($){return $.collapse},func:function($,_){$.parentNode.removeChild($);_.div.className=_.div.className.replace("collapsed","")}},ViewSource:{label:"view plain",func:function($,_){var A=dp.sh.Utils.FixForBlogger(_.originalCode).replace(/</g,"&lt;"),B=window.open("","_blank","width=750, height=400, location=0, resizable=1, menubar=0, scrollbars=0");B.document.write("<textarea style=\"width:99%;height:99%\">"+A+"</textarea>");B.document.close()}},CopyToClipboard:{label:"copy to clipboard",check:function(){return window.clipboardData!=null||dp.sh.ClipboardSwf!=null},func:function($,A){var B=dp.sh.Utils.FixForBlogger(A.originalCode).replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&");if(window.clipboardData)window.clipboardData.setData("text",B);else if(dp.sh.ClipboardSwf!=null){var _=A.flashCopier;if(_==null){_=document.createElement("div");A.flashCopier=_;A.div.appendChild(_)}_.innerHTML="<embed src=\""+dp.sh.ClipboardSwf+"\" FlashVars=\"clipboard="+encodeURIComponent(B)+"\" width=\"0\" height=\"0\" type=\"application/x-shockwave-flash\"></embed>"}alert("The code is in your clipboard now")}},PrintSource:{label:"print",func:function($,B){var _=document.createElement("IFRAME"),A=null;_.style.cssText="position:absolute;width:0px;height:0px;left:-500px;top:-500px;";document.body.appendChild(_);A=_.contentWindow.document;dp.sh.Utils.CopyStyles(A,window.document);A.write("<div class=\""+B.div.className.replace("collapsed","")+" printing\">"+B.div.innerHTML+"</div>");A.close();_.contentWindow.focus();_.contentWindow.print();alert("Printing...");document.body.removeChild(_)}},About:{label:"?",func:function(_){var A=window.open("","_blank","dialog,width=300,height=150,scrollbars=0"),$=A.document;dp.sh.Utils.CopyStyles($,window.document);$.write(dp.sh.Strings.AboutDialog.replace("{V}",dp.sh.Version));$.close();A.focus()}}};dp.sh.Toolbar.Create=function(B){var A=document.createElement("DIV");A.className="tools";for(var _ in dp.sh.Toolbar.Commands){var $=dp.sh.Toolbar.Commands[_];if($.check!=null&&!$.check(B))continue;A.innerHTML+="<a href=\"#\" onclick=\"dp.sh.Toolbar.Command('"+_+"',this);return false;\">"+$.label+"</a>"}return A};dp.sh.Toolbar.Command=function(_,$){var A=$;while(A!=null&&A.className.indexOf("dp-highlighter")==-1)A=A.parentNode;if(A!=null)dp.sh.Toolbar.Commands[_].func($,A.highlighter)};dp.sh.Utils.CopyStyles=function(A,_){var $=_.getElementsByTagName("link");for(var B=0;B<$.length;B++)if($[B].rel.toLowerCase()=="stylesheet")A.write("<link type=\"text/css\" rel=\"stylesheet\" href=\""+$[B].href+"\"></link>")};dp.sh.Utils.FixForBlogger=function($){return(dp.sh.isBloggerMode==true)?$.replace(/<br\s*\/?>|&lt;br\s*\/?&gt;/gi,"\n"):$};dp.sh.RegexLib={MultiLineCComments:new RegExp("/\\*[\\s\\S]*?\\*/","gm"),SingleLineCComments:new RegExp("//.*$","gm"),SingleLinePerlComments:new RegExp("#.*$","gm"),DoubleQuotedString:new RegExp("\"(?:\\.|(\\\\\\\")|[^\\\"\"\\n])*\"","g"),SingleQuotedString:new RegExp("'(?:\\.|(\\\\\\')|[^\\''\\n])*'","g")};dp.sh.Match=function(_,$,A){this.value=_;this.index=$;this.length=_.length;this.css=A};dp.sh.Highlighter=function(){this.noGutter=false;this.addControls=true;this.collapse=false;this.tabsToSpaces=true;this.wrapColumn=80;this.showColumns=true};dp.sh.Highlighter.SortCallback=function($,_){if($.index<_.index)return-1;else if($.index>_.index)return 1;else if($.length<_.length)return-1;else if($.length>_.length)return 1;return 0};dp.sh.Highlighter.prototype.CreateElement=function(_){var $=document.createElement(_);$.highlighter=this;return $};dp.sh.Highlighter.prototype.GetMatches=function(_,B){var $=0,A=null;while((A=_.exec(this.code))!=null)this.matches[this.matches.length]=new dp.sh.Match(A[0],A.index,B)};dp.sh.Highlighter.prototype.AddBit=function($,A){if($==null||$.length==0)return;var C=this.CreateElement("SPAN");$=$.replace(/ /g,"&nbsp;");$=$.replace(/</g,"&lt;");$=$.replace(/\n/gm,"&nbsp;<br>");if(A!=null){if((/br/gi).test($)){var _=$.split("&nbsp;<br>");for(var B=0;B<_.length;B++){C=this.CreateElement("SPAN");C.className=A;C.innerHTML=_[B];this.div.appendChild(C);if(B+1<_.length)this.div.appendChild(this.CreateElement("BR"))}}else{C.className=A;C.innerHTML=$;this.div.appendChild(C)}}else{C.innerHTML=$;this.div.appendChild(C)}};dp.sh.Highlighter.prototype.IsInside=function(_){if(_==null||_.length==0)return false;for(var A=0;A<this.matches.length;A++){var $=this.matches[A];if($==null)continue;if((_.index>$.index)&&(_.index<$.index+$.length))return true}return false};dp.sh.Highlighter.prototype.ProcessRegexList=function(){for(var $=0;$<this.regexList.length;$++)this.GetMatches(this.regexList[$].regex,this.regexList[$].css)};dp.sh.Highlighter.prototype.ProcessSmartTabs=function(E){var B=E.split("\n"),$="",D=4,A="\t";function _(A,E,_){var B=A.substr(0,E),C=A.substr(E+1,A.length),$="";for(var D=0;D<_;D++)$+=" ";return B+$+C}function C(B,C){if(B.indexOf(A)==-1)return B;var D=0;while((D=B.indexOf(A))!=-1){var $=C-D%C;B=_(B,D,$)}return B}for(var F=0;F<B.length;F++)$+=C(B[F],D)+"\n";return $};dp.sh.Highlighter.prototype.SwitchToList=function(){var C=this.div.innerHTML.replace(/<(br)\/?>/gi,"\n"),B=C.split("\n");if(this.addControls==true)this.bar.appendChild(dp.sh.Toolbar.Create(this));if(this.showColumns){var A=this.CreateElement("div"),_=this.CreateElement("div"),E=10,G=1;while(G<=150)if(G%E==0){A.innerHTML+=G;G+=(G+"").length}else{A.innerHTML+="&middot;";G++}_.className="columns";_.appendChild(A);this.bar.appendChild(_)}for(var G=0,D=this.firstLine;G<B.length-1;G++,D++){var $=this.CreateElement("LI"),F=this.CreateElement("SPAN");$.className=(G%2==0)?"alt":"";F.innerHTML=B[G]+"&nbsp;";$.appendChild(F);this.ol.appendChild($)}this.div.innerHTML=""};dp.sh.Highlighter.prototype.Highlight=function(C){function A($){return $.replace(/^\s*(.*?)[\s\n]*$/g,"$1")}function $($){return $.replace(/\n*$/,"").replace(/^\n*/,"")}function _(B){var E=dp.sh.Utils.FixForBlogger(B).split("\n"),C=new Array(),D=new RegExp("^\\s*","g"),$=1000;for(var F=0;F<E.length&&$>0;F++){if(A(E[F]).length==0)continue;var _=D.exec(E[F]);if(_!=null&&_.length>0)$=Math.min(_[0].length,$)}if($>0)for(F=0;F<E.length;F++)E[F]=E[F].substr($);return E.join("\n")}function D(A,$,_){return A.substr($,_-$)}var F=0;if(C==null)C="";this.originalCode=C;this.code=$(_(C));this.div=this.CreateElement("DIV");this.bar=this.CreateElement("DIV");this.ol=this.CreateElement("OL");this.matches=new Array();this.div.className="dp-highlighter";this.div.highlighter=this;this.bar.className="bar";this.ol.start=this.firstLine;if(this.CssClass!=null)this.ol.className=this.CssClass;if(this.collapse)this.div.className+=" collapsed";if(this.noGutter)this.div.className+=" nogutter";if(this.tabsToSpaces==true)this.code=this.ProcessSmartTabs(this.code);this.ProcessRegexList();if(this.matches.length==0){this.AddBit(this.code,null);this.SwitchToList();this.div.appendChild(this.bar);this.div.appendChild(this.ol);return}this.matches=this.matches.sort(dp.sh.Highlighter.SortCallback);for(var E=0;E<this.matches.length;E++)if(this.IsInside(this.matches[E]))this.matches[E]=null;for(E=0;E<this.matches.length;E++){var B=this.matches[E];if(B==null||B.length==0)continue;this.AddBit(D(this.code,F,B.index),null);this.AddBit(B.value,B.css);F=B.index+B.length}this.AddBit(this.code.substr(F),null);this.SwitchToList();this.div.appendChild(this.bar);this.div.appendChild(this.ol)};dp.sh.Highlighter.prototype.GetKeywords=function($){return"\\b"+$.replace(/ /g,"\\b|\\b")+"\\b"};dp.sh.BloggerMode=function(){dp.sh.isBloggerMode=true};dp.sh.HighlightAll=function(N,B,K,I,O,E){function A(){var $=arguments;for(var _=0;_<$.length;_++){if($[_]==null)continue;if(typeof($[_])=="string"&&$[_]!="")return $[_]+"";if(typeof($[_])=="object"&&$[_].value!="")return $[_].value+""}return null}function J($,_){for(var A=0;A<_.length;A++)if(_[A]==$)return true;return false}function L(A,B,C){var _=new RegExp("^"+A+"\\[(\\w+)\\]$","gi"),$=null;for(var D=0;D<B.length;D++)if(($=_.exec(B[D]))!=null)return $[1];return C}function C(B,A,_){var $=document.getElementsByTagName(_);for(var C=0;C<$.length;C++)if($[C].getAttribute("name")==A)B.push($[C])}var T=[],P=null,M={},$="innerHTML";C(T,N,"pre");C(T,N,"textarea");if(T.length==0)return;for(var R in dp.sh.Brushes){var F=dp.sh.Brushes[R].Aliases;if(F==null)continue;for(var G=0;G<F.length;G++)M[F[G]]=R}for(G=0;G<T.length;G++){var _=T[G],U=A(_.attributes["class"],_.className,_.attributes["language"],_.language),Q="";if(U==null)continue;U=U.split(":");Q=U[0].toLowerCase();if(M[Q]==null)continue;P=new dp.sh.Brushes[M[Q]]();_.style.display="none";P.noGutter=(B==null)?J("nogutter",U):!B;P.addControls=(K==null)?!J("nocontrols",U):K;P.collapse=(I==null)?J("collapse",U):I;P.showColumns=(E==null)?J("showcolumns",U):E;var D=document.getElementsByTagName("head")[0];if(P.Style&&D){var S=document.createElement("style");S.setAttribute("type","text/css");if(S.styleSheet)S.styleSheet.cssText=P.Style;else{var H=document.createTextNode(P.Style);S.appendChild(H)}D.appendChild(S)}P.firstLine=(O==null)?parseInt(L("firstline",U,1)):O;P.Highlight(_[$]);P.source=_;_.parentNode.insertBefore(P.div,_)}};version.extensions.SyntaxHighLighterPlugin={major:1,minor:1,revision:3,date:new Date(2008,10,24)};dp.sh.ClipboardSwf="clipboard.swf";dp.sh.Highlight=function(_,Q,B,J,H,M,D){function A(){var $=arguments;for(var _=0;_<$.length;_++){if($[_]==null)continue;if(typeof($[_])=="string"&&$[_]!="")return $[_]+"";if(typeof($[_])=="object"&&$[_].value!="")return $[_].value+""}return null}function I($,_){for(var A=0;A<_.length;A++)if(_[A]==$)return true;return false}function K(A,B,C){var _=new RegExp("^"+A+"\\[(\\w+)\\]$","gi"),$=null;for(var D=0;D<B.length;D++)if(($=_.exec(B[D]))!=null)return $[1];return C}var N=null,$="innerHTML";if(this.registered==undefined){var L={};for(var O in dp.sh.Brushes){var E=dp.sh.Brushes[O].Aliases;if(E==null)continue;for(var F=0;F<E.length;F++)L[E[F]]=O}this.registered=L}Q=Q.split(":");language=Q[0].toLowerCase();if(this.registered[language]==null)return;N=new dp.sh.Brushes[this.registered[language]]();_.style.display="none";N.noGutter=(B==null)?I("nogutter",Q):!B;N.addControls=(J==null)?!I("nocontrols",Q):J;N.collapse=(H==null)?I("collapse",Q):H;N.showColumns=(D==null)?I("showcolumns",Q):D;var C=document.getElementsByTagName("head")[0],P=document.getElementById(N.CssClass);if(N.Style&&C&&!P){P=document.createElement("style");P.setAttribute("id",N.CssClass);P.setAttribute("type","text/css");if(P.styleSheet)P.styleSheet.cssText=N.Style;else{var G=document.createTextNode(N.Style);P.appendChild(G)}C.appendChild(P)}N.firstLine=(M==null)?parseInt(K("firstline",Q,1)):M;N.Highlight(_[$]);N.source=_;_.parentNode.insertBefore(N.div,_)};config.formatters.push({name:"SyntaxHighlighter",match:"^<code[\\s]+[^>]+>\\n",element:"pre",handler:function(_){this.lookaheadRegExp=/<code[\s]+([^>]+)>\n((?:^[^\n]*\n)+?)(^<\/code>$\n?)/mg;this.lookaheadRegExp.lastIndex=_.matchStart;var $=this.lookaheadRegExp.exec(_.source);if($&&$.index==_.matchStart){var C=$[1],B=$[2];if(config.browser.isIE)B=B.replace(/\n/g,"\r");var A=createTiddlyElement(_.output,this.element,null,null,B);dp.sh.Highlight(A,C);_.nextMatch=$.index+$[0].length}}});config.formatterHelpers.enclosedTextHelper=function(_){this.lookaheadRegExp.lastIndex=_.matchStart;var $=this.lookaheadRegExp.exec(_.source);if($&&$.index==_.matchStart){var B=$[1];if(config.browser.isIE)B=B.replace(/\n/g,"\r");var A=createTiddlyElement(_.output,this.element,null,null,B);switch(_.matchText){case"/*{{{*/\n":dp.sh.Highlight(A,"css");break;case"//{{{\n":dp.sh.Highlight(A,"js");break;case"<!--{{{-->\n":dp.sh.Highlight(A,"xml");break}_.nextMatch=$.index+$[0].length}};dp.sh.Brushes.AS3=function(){var _="class interface package",$="Array Boolean Date decodeURI decodeURIComponent encodeURI encodeURIComponent escape "+"int isFinite isNaN isXMLName Number Object parseFloat parseInt "+"String trace uint unescape XML XMLList "+"Infinity -Infinity NaN undefined "+"as delete instanceof is new typeof "+"break case catch continue default do each else finally for if in "+"label return super switch throw try while with "+"dynamic final internal native override private protected public static "+"...rest const extends function get implements namespace set "+"import include use "+"AS3 flash_proxy object_proxy "+"false null this true "+"void Null";this.regexList=[{regex:dp.sh.RegexLib.SingleLineCComments,css:"comment"},{regex:dp.sh.RegexLib.MultiLineCComments,css:"blockcomment"},{regex:dp.sh.RegexLib.DoubleQuotedString,css:"string"},{regex:dp.sh.RegexLib.SingleQuotedString,css:"string"},{regex:new RegExp("^\\s*#.*","gm"),css:"preprocessor"},{regex:new RegExp(this.GetKeywords(_),"gm"),css:"definition"},{regex:new RegExp(this.GetKeywords($),"gm"),css:"keyword"},{regex:new RegExp("var","gm"),css:"variable"}];this.CssClass="dp-as";this.Style=".dp-as .comment { color: #009900; font-style: italic; }"+".dp-as .blockcomment { color: #3f5fbf; }"+".dp-as .string { color: #990000; }"+".dp-as .preprocessor { color: #0033ff; }"+".dp-as .definition { color: #9900cc; font-weight: bold; }"+".dp-as .keyword { color: #0033ff; }"+".dp-as .variable { color: #6699cc; font-weight: bold; }"};dp.sh.Brushes.AS3.prototype=new dp.sh.Highlighter();dp.sh.Brushes.AS3.Aliases=["as","actionscript","ActionScript","as3","AS3"];dp.sh.Brushes.Bash=function(){var _="alias bg bind break builtin cd command compgen complete continue "+"declare dirs disown echo enable eval exec exit export fc fg "+"getopts hash help history jobs kill let local logout popd printf "+"pushd pwd read readonly return set shift shopt source "+"suspend test times trap type typeset ulimit umask unalias unset wait",$="case do done elif else esac fi for function if in select then "+"time until while";this.regexList=[{regex:dp.sh.RegexLib.SingleLinePerlComments,css:"comment"},{regex:dp.sh.RegexLib.DoubleQuotedString,css:"string"},{regex:dp.sh.RegexLib.SingleQuotedString,css:"string"},{regex:new RegExp("[()[\\]{}]","g"),css:"delim"},{regex:new RegExp("\\$\\w+","g"),css:"vars"},{regex:new RegExp("\\w+=","g"),css:"vars"},{regex:new RegExp("\\s-\\w+","g"),css:"flag"},{regex:new RegExp(this.GetKeywords(_),"gm"),css:"builtin"},{regex:new RegExp(this.GetKeywords($),"gm"),css:"keyword"}];this.CssClass="dp-bash";this.Style=".dp-bash .builtin {color: maroon; font-weight: bold;}"+".dp-bash .comment {color: gray;}"+".dp-bash .delim {font-weight: bold;}"+".dp-bash .flag {color: green;}"+".dp-bash .string {color: red;}"+".dp-bash .vars {color: blue;}"};dp.sh.Brushes.Bash.prototype=new dp.sh.Highlighter();dp.sh.Brushes.Bash.Aliases=["bash","sh"];dp.sh.Brushes.Batch=function(){var _="APPEND ATTRIB CD CHDIR CHKDSK CHOICE CLS COPY DEL ERASE DELTREE "+"DIR EXIT FC COMP FDISK FIND FORMAT FSUTIL HELP JOIN "+"LABEL LOADFIX MK MKDIR MEM MEMMAKER MORE MOVE MSD PCPARK "+"PRINT RD RMDIR REN SCANDISK SHARE SORT SUBST SYS "+"TIME DATE TREE TRUENAME TYPE UNDELETE VER XCOPY",$="DO ELSE FOR IN CALL CHOICE GOTO SHIFT PAUSE ERRORLEVEL "+"IF NOT EXIST LFNFOR START SETLOCAL ENDLOCAL ECHO SET";this.regexList=[{regex:new RegExp("REM.*$","gm"),css:"comment"},{regex:new RegExp("::.*$","gm"),css:"comment"},{regex:dp.sh.RegexLib.DoubleQuotedString,css:"string"},{regex:dp.sh.RegexLib.SingleQuotedString,css:"string"},{regex:new RegExp("[()[\\]{}]","g"),css:"delim"},{regex:new RegExp("%\\w+%","g"),css:"vars"},{regex:new RegExp("%%\\w+","g"),css:"vars"},{regex:new RegExp("\\w+=","g"),css:"vars"},{regex:new RegExp("@\\w+","g"),css:"keyword"},{regex:new RegExp(":\\w+","g"),css:"keyword"},{regex:new RegExp("\\s/\\w+","g"),css:"flag"},{regex:new RegExp(this.GetKeywords(_),"gm"),css:"builtin"},{regex:new RegExp(this.GetKeywords($),"gm"),css:"keyword"}];this.CssClass="dp-batch";this.Style=".dp-batch .builtin {color: maroon; font-weight: bold;}"+".dp-batch .comment {color: gray;}"+".dp-batch .delim {font-weight: bold;}"+".dp-batch .flag {color: green;}"+".dp-batch .string {color: red;}"+".dp-batch .vars {color: blue;font-weight: bold;}"};dp.sh.Brushes.Batch.prototype=new dp.sh.Highlighter();dp.sh.Brushes.Batch.Aliases=["batch","dos"];dp.sh.Brushes.ColdFusion=function(){this.CssClass="dp-coldfusion";this.Style=".dp-coldfusion { font: 13px \"Courier New\", Courier, monospace; }"+".dp-coldfusion .tag, .dp-coldfusion .tag-name { color: #990033; }"+".dp-coldfusion .attribute { color: #990033; }"+".dp-coldfusion .attribute-value { color: #0000FF; }"+".dp-coldfusion .cfcomments { background-color: #FFFF99; color: #000000; }"+".dp-coldfusion .cfscriptcomments { color: #999999; }"+".dp-coldfusion .keywords { color: #0000FF; }"+".dp-coldfusion .mgkeywords { color: #CC9900; }"+".dp-coldfusion .numbers { color: #ff0000; }"+".dp-coldfusion .strings { color: green; }";this.mgKeywords="setvalue getvalue addresult viewcollection viewstate";this.keywords="var eq neq gt gte lt lte not and or true false "+"abs acos addsoaprequestheader addsoapresponseheader "+"arrayappend arrayavg arrayclear arraydeleteat arrayinsertat "+"arrayisempty arraylen arraymax arraymin arraynew "+"arrayprepend arrayresize arrayset arraysort arraysum "+"arrayswap arraytolist asc asin atn binarydecode binaryencode "+"bitand bitmaskclear bitmaskread bitmaskset bitnot bitor bitshln "+"bitshrn bitxor ceiling charsetdecode charsetencode chr cjustify "+"compare comparenocase cos createdate createdatetime createobject "+"createobject createobject createobject createobject createodbcdate "+"createodbcdatetime createodbctime createtime createtimespan "+"createuuid dateadd datecompare dateconvert datediff dateformat "+"datepart day dayofweek dayofweekasstring dayofyear daysinmonth "+"daysinyear de decimalformat decrementvalue decrypt decryptbinary "+"deleteclientvariable directoryexists dollarformat duplicate encrypt "+"encryptbinary evaluate exp expandpath fileexists find findnocase "+"findoneof firstdayofmonth fix formatbasen generatesecretkey "+"getauthuser getbasetagdata getbasetaglist getbasetemplatepath "+"getclientvariableslist getcontextroot getcurrenttemplatepath "+"getdirectoryfrompath getencoding getexception getfilefrompath "+"getfunctionlist getgatewayhelper gethttprequestdata gethttptimestring "+"getk2serverdoccount getk2serverdoccountlimit getlocale "+"getlocaledisplayname getlocalhostip getmetadata getmetricdata "+"getpagecontext getprofilesections getprofilestring getsoaprequest "+"getsoaprequestheader getsoapresponse getsoapresponseheader "+"gettempdirectory gettempfile gettemplatepath gettickcount "+"gettimezoneinfo gettoken hash hour htmlcodeformat htmleditformat "+"iif incrementvalue inputbasen insert int isarray isbinary isboolean "+"iscustomfunction isdate isdebugmode isdefined isk2serverabroker "+"isk2serverdoccountexceeded isk2serveronline isleapyear islocalhost "+"isnumeric isnumericdate isobject isquery issimplevalue issoaprequest "+"isstruct isuserinrole isvalid isvalid isvalid iswddx isxml "+"isxmlattribute isxmldoc isxmlelem isxmlnode isxmlroot javacast "+"jsstringformat lcase left len listappend listchangedelims listcontains "+"listcontainsnocase listdeleteat listfind listfindnocase listfirst "+"listgetat listinsertat listlast listlen listprepend listqualify "+"listrest listsetat listsort listtoarray listvaluecount "+"listvaluecountnocase ljustify log log10 lscurrencyformat lsdateformat "+"lseurocurrencyformat lsiscurrency lsisdate lsisnumeric lsnumberformat "+"lsparsecurrency lsparsedatetime lsparseeurocurrency lsparsenumber "+"lstimeformat ltrim max mid min minute month monthasstring now "+"numberformat paragraphformat parameterexists parsedatetime pi "+"preservesinglequotes quarter queryaddcolumn queryaddrow querynew "+"querysetcell quotedvaluelist rand randomize randrange refind "+"refindnocase releasecomobject removechars repeatstring replace "+"replacelist replacenocase rereplace rereplacenocase reverse right "+"rjustify round rtrim second sendgatewaymessage setencoding "+"setlocale setprofilestring setvariable sgn sin spanexcluding "+"spanincluding sqr stripcr structappend structclear structcopy "+"structcount structdelete structfind structfindkey structfindvalue "+"structget structinsert structisempty structkeyarray structkeyexists "+"structkeylist structnew structsort structupdate tan timeformat "+"tobase64 tobinary toscript tostring trim ucase urldecode urlencodedformat "+"urlsessionformat val valuelist week wrap writeoutput xmlchildpos "+"xmlelemnew xmlformat xmlgetnodetype xmlnew xmlparse xmlsearch xmltransform "+"xmlvalidate year yesnoformat";this.stringMatches=new Array();this.attributeMatches=new Array()};dp.sh.Brushes.ColdFusion.prototype=new dp.sh.Highlighter();dp.sh.Brushes.ColdFusion.Aliases=["coldfusion","cf"];dp.sh.Brushes.ColdFusion.prototype.ProcessRegexList=function(){function B(_,$){_[_.length]=$}function A(A,$){for(var _=0;_<A.length;_++)if(A[_]==$)return _;return-1}var _=null,$=null;this.GetMatches(new RegExp("\\b(\\d+)","gm"),"numbers");this.GetMatches(new RegExp(this.GetKeywords(this.mgKeywords),"igm"),"mgkeywords");this.GetMatches(dp.sh.RegexLib.SingleLineCComments,"cfscriptcomments");this.GetMatches(dp.sh.RegexLib.MultiLineCComments,"cfscriptcomments");this.GetMatches(new RegExp("(&lt;|<)!---[\\s\\S]*?---(&gt;|>)","gm"),"cfcomments");$=new RegExp("(cfset\\s*)?([:\\w-.]+)\\s*=\\s*(\".*?\"|'.*?')*","gm");while((_=$.exec(this.code))!=null){if(_[1]!=undefined&&_[1]!="")continue;if(_[3]!=undefined&&_[3]!=""&&_[3]!="\"\""&&_[3]!="''"){B(this.matches,new dp.sh.Match(_[2],_.index,"attribute"));B(this.matches,new dp.sh.Match(_[3],_.index+_[0].indexOf(_[3]),"attribute-value"));B(this.stringMatches,_[3]);B(this.attributeMatches,_[2])}}this.GetMatches(new RegExp("(&lt;|<)/*\\?*(?!\\!)|/*\\?*(&gt;|>)","gm"),"tag");$=new RegExp("(?:&lt;|<)/*\\?*\\s*([:\\w-.]+)","gm");while((_=$.exec(this.code))!=null)B(this.matches,new dp.sh.Match(_[1],_.index+_[0].indexOf(_[1]),"tag-name"));$=new RegExp(this.GetKeywords(this.keywords),"igm");while((_=$.exec(this.code))!=null)if(A(this.attributeMatches,_[0])==-1)B(this.matches,new dp.sh.Match(_[0],_.index,"keywords"));$=new RegExp("cfset\\s*.*(\".*?\"|'.*?')","gm");while((_=$.exec(this.code))!=null)if(_[1]!=undefined&&_[1]!=""){B(this.matches,new dp.sh.Match(_[1],_.index+_[0].indexOf(_[1]),"strings"));B(this.stringMatches,_[1])}while((_=dp.sh.RegexLib.DoubleQuotedString.exec(this.code))!=null)if(A(this.stringMatches,_[0])==-1)B(this.matches,new dp.sh.Match(_[0],_.index,"strings"));while((_=dp.sh.RegexLib.SingleQuotedString.exec(this.code))!=null)if(A(this.stringMatches,_[0])==-1)B(this.matches,new dp.sh.Match(_[0],_.index,"strings"))};dp.sh.Brushes.Cpp=function(){var _="ATOM BOOL BOOLEAN BYTE CHAR COLORREF DWORD DWORDLONG DWORD_PTR "+"DWORD32 DWORD64 FLOAT HACCEL HALF_PTR HANDLE HBITMAP HBRUSH "+"HCOLORSPACE HCONV HCONVLIST HCURSOR HDC HDDEDATA HDESK HDROP HDWP "+"HENHMETAFILE HFILE HFONT HGDIOBJ HGLOBAL HHOOK HICON HINSTANCE HKEY "+"HKL HLOCAL HMENU HMETAFILE HMODULE HMONITOR HPALETTE HPEN HRESULT "+"HRGN HRSRC HSZ HWINSTA HWND INT INT_PTR INT32 INT64 LANGID LCID LCTYPE "+"LGRPID LONG LONGLONG LONG_PTR LONG32 LONG64 LPARAM LPBOOL LPBYTE LPCOLORREF "+"LPCSTR LPCTSTR LPCVOID LPCWSTR LPDWORD LPHANDLE LPINT LPLONG LPSTR LPTSTR "+"LPVOID LPWORD LPWSTR LRESULT PBOOL PBOOLEAN PBYTE PCHAR PCSTR PCTSTR PCWSTR "+"PDWORDLONG PDWORD_PTR PDWORD32 PDWORD64 PFLOAT PHALF_PTR PHANDLE PHKEY PINT "+"PINT_PTR PINT32 PINT64 PLCID PLONG PLONGLONG PLONG_PTR PLONG32 PLONG64 POINTER_32 "+"POINTER_64 PSHORT PSIZE_T PSSIZE_T PSTR PTBYTE PTCHAR PTSTR PUCHAR PUHALF_PTR "+"PUINT PUINT_PTR PUINT32 PUINT64 PULONG PULONGLONG PULONG_PTR PULONG32 PULONG64 "+"PUSHORT PVOID PWCHAR PWORD PWSTR SC_HANDLE SC_LOCK SERVICE_STATUS_HANDLE SHORT "+"SIZE_T SSIZE_T TBYTE TCHAR UCHAR UHALF_PTR UINT UINT_PTR UINT32 UINT64 ULONG "+"ULONGLONG ULONG_PTR ULONG32 ULONG64 USHORT USN VOID WCHAR WORD WPARAM WPARAM WPARAM "+"char bool short int __int32 __int64 __int8 __int16 long float double __wchar_t "+"clock_t _complex _dev_t _diskfree_t div_t ldiv_t _exception _EXCEPTION_POINTERS "+"FILE _finddata_t _finddatai64_t _wfinddata_t _wfinddatai64_t __finddata64_t "+"__wfinddata64_t _FPIEEE_RECORD fpos_t _HEAPINFO _HFILE lconv intptr_t "+"jmp_buf mbstate_t _off_t _onexit_t _PNH ptrdiff_t _purecall_handler "+"sig_atomic_t size_t _stat __stat64 _stati64 terminate_function "+"time_t __time64_t _timeb __timeb64 tm uintptr_t _utimbuf "+"va_list wchar_t wctrans_t wctype_t wint_t signed",$="break case catch class const __finally __exception __try "+"const_cast continue private public protected __declspec "+"default delete deprecated dllexport dllimport do dynamic_cast "+"else enum explicit extern if for friend goto inline "+"mutable naked namespace new noinline noreturn nothrow "+"register reinterpret_cast return selectany "+"sizeof static static_cast struct switch template this "+"thread throw true false try typedef typeid typename union "+"using uuid virtual void volatile whcar_t while";this.regexList=[{regex:dp.sh.RegexLib.SingleLineCComments,css:"comment"},{regex:dp.sh.RegexLib.MultiLineCComments,css:"comment"},{regex:dp.sh.RegexLib.DoubleQuotedString,css:"string"},{regex:dp.sh.RegexLib.SingleQuotedString,css:"string"},{regex:new RegExp("^ *#.*","gm"),css:"preprocessor"},{regex:new RegExp(this.GetKeywords(_),"gm"),css:"datatypes"},{regex:new RegExp(this.GetKeywords($),"gm"),css:"keyword"}];this.CssClass="dp-cpp";this.Style=".dp-cpp .datatypes { color: #2E8B57; font-weight: bold; }"};dp.sh.Brushes.Cpp.prototype=new dp.sh.Highlighter();dp.sh.Brushes.Cpp.Aliases=["cpp","c","c++"];dp.sh.Brushes.CSharp=function(){var $="abstract as base bool break byte case catch char checked class const "+"continue decimal default delegate do double else enum event explicit "+"extern false finally fixed float for foreach get goto if implicit in int "+"interface internal is lock long namespace new null object operator out "+"override params private protected public readonly ref return sbyte sealed set "+"short sizeof stackalloc static string struct switch this throw true try "+"typeof uint ulong unchecked unsafe ushort using virtual void while";this.regexList=[{regex:dp.sh.RegexLib.SingleLineCComments,css:"comment"},{regex:dp.sh.RegexLib.MultiLineCComments,css:"comment"},{regex:dp.sh.RegexLib.DoubleQuotedString,css:"string"},{regex:dp.sh.RegexLib.SingleQuotedString,css:"string"},{regex:new RegExp("^\\s*#.*","gm"),css:"preprocessor"},{regex:new RegExp(this.GetKeywords($),"gm"),css:"keyword"}];this.CssClass="dp-c";this.Style=".dp-c .vars { color: #d00; }"};dp.sh.Brushes.CSharp.prototype=new dp.sh.Highlighter();dp.sh.Brushes.CSharp.Aliases=["c#","c-sharp","csharp"];dp.sh.Brushes.CSS=function(){var _="ascent azimuth background-attachment background-color background-image background-position "+"background-repeat background baseline bbox border-collapse border-color border-spacing border-style border-top "+"border-right border-bottom border-left border-top-color border-right-color border-bottom-color border-left-color "+"border-top-style border-right-style border-bottom-style border-left-style border-top-width border-right-width "+"border-bottom-width border-left-width border-width border cap-height caption-side centerline clear clip color "+"content counter-increment counter-reset cue-after cue-before cue cursor definition-src descent direction display "+"elevation empty-cells float font-size-adjust font-family font-size font-stretch font-style font-variant font-weight font "+"height letter-spacing line-height list-style-image list-style-position list-style-type list-style margin-top "+"margin-right margin-bottom margin-left margin marker-offset marks mathline max-height max-width min-height min-width orphans "+"outline-color outline-style outline-width outline overflow padding-top padding-right padding-bottom padding-left padding page "+"page-break-after page-break-before page-break-inside pause pause-after pause-before pitch pitch-range play-during position "+"quotes richness size slope src speak-header speak-numeral speak-punctuation speak speech-rate stemh stemv stress "+"table-layout text-align text-decoration text-indent text-shadow text-transform unicode-bidi unicode-range units-per-em "+"vertical-align visibility voice-family volume white-space widows width widths word-spacing x-height z-index",$="above absolute all always aqua armenian attr aural auto avoid baseline behind below bidi-override black blink block blue bold bolder "+"both bottom braille capitalize caption center center-left center-right circle close-quote code collapse compact condensed "+"continuous counter counters crop cross crosshair cursive dashed decimal decimal-leading-zero default digits disc dotted double "+"embed embossed e-resize expanded extra-condensed extra-expanded fantasy far-left far-right fast faster fixed format fuchsia "+"gray green groove handheld hebrew help hidden hide high higher icon inline-table inline inset inside invert italic "+"justify landscape large larger left-side left leftwards level lighter lime line-through list-item local loud lower-alpha "+"lowercase lower-greek lower-latin lower-roman lower low ltr marker maroon medium message-box middle mix move narrower "+"navy ne-resize no-close-quote none no-open-quote no-repeat normal nowrap n-resize nw-resize oblique olive once open-quote outset "+"outside overline pointer portrait pre print projection purple red relative repeat repeat-x repeat-y rgb ridge right right-side "+"rightwards rtl run-in screen scroll semi-condensed semi-expanded separate se-resize show silent silver slower slow "+"small small-caps small-caption smaller soft solid speech spell-out square s-resize static status-bar sub super sw-resize "+"table-caption table-cell table-column table-column-group table-footer-group table-header-group table-row table-row-group teal "+"text-bottom text-top thick thin top transparent tty tv ultra-condensed ultra-expanded underline upper-alpha uppercase upper-latin "+"upper-roman url visible wait white wider w-resize x-fast x-high x-large x-loud x-low x-slow x-small x-soft xx-large xx-small yellow",A="[mM]onospace [tT]ahoma [vV]erdana [aA]rial [hH]elvetica [sS]ans-serif [sS]erif";this.regexList=[{regex:dp.sh.RegexLib.MultiLineCComments,css:"comment"},{regex:dp.sh.RegexLib.DoubleQuotedString,css:"string"},{regex:dp.sh.RegexLib.SingleQuotedString,css:"string"},{regex:new RegExp("\\#[a-zA-Z0-9]{3,6}","g"),css:"value"},{regex:new RegExp("(-?\\d+)(.\\d+)?(px|em|pt|:|%|)","g"),css:"value"},{regex:new RegExp("!important","g"),css:"important"},{regex:new RegExp(this.GetKeywordsCSS(_),"gm"),css:"keyword"},{regex:new RegExp(this.GetValuesCSS($),"g"),css:"value"},{regex:new RegExp(this.GetValuesCSS(A),"g"),css:"value"}];this.CssClass="dp-css";this.Style=".dp-css .value { color: black; }"+".dp-css .important { color: red; }"};dp.sh.Highlighter.prototype.GetKeywordsCSS=function($){return"\\b([a-z_]|)"+$.replace(/ /g,"(?=:)\\b|\\b([a-z_\\*]|\\*|)")+"(?=:)\\b"};dp.sh.Highlighter.prototype.GetValuesCSS=function($){return"\\b"+$.replace(/ /g,"(?!-)(?!:)\\b|\\b()")+":\\b"};dp.sh.Brushes.CSS.prototype=new dp.sh.Highlighter();dp.sh.Brushes.CSS.Aliases=["css"];dp.sh.Brushes.Delphi=function(){var $="abs addr and ansichar ansistring array as asm begin boolean byte cardinal "+"case char class comp const constructor currency destructor div do double "+"downto else end except exports extended false file finalization finally "+"for function goto if implementation in inherited int64 initialization "+"integer interface is label library longint longword mod nil not object "+"of on or packed pansichar pansistring pchar pcurrency pdatetime pextended "+"pint64 pointer private procedure program property pshortstring pstring "+"pvariant pwidechar pwidestring protected public published raise real real48 "+"record repeat set shl shortint shortstring shr single smallint string then "+"threadvar to true try type unit until uses val var varirnt while widechar "+"widestring with word write writeln xor";this.regexList=[{regex:new RegExp("\\(\\*[\\s\\S]*?\\*\\)","gm"),css:"comment"},{regex:new RegExp("{(?!\\$)[\\s\\S]*?}","gm"),css:"comment"},{regex:dp.sh.RegexLib.SingleLineCComments,css:"comment"},{regex:dp.sh.RegexLib.SingleQuotedString,css:"string"},{regex:new RegExp("\\{\\$[a-zA-Z]+ .+\\}","g"),css:"directive"},{regex:new RegExp("\\b[\\d\\.]+\\b","g"),css:"number"},{regex:new RegExp("\\$[a-zA-Z0-9]+\\b","g"),css:"number"},{regex:new RegExp(this.GetKeywords($),"gm"),css:"keyword"}];this.CssClass="dp-delphi";this.Style=".dp-delphi .number { color: blue; }"+".dp-delphi .directive { color: #008284; }"+".dp-delphi .vars { color: #000; }"};dp.sh.Brushes.Delphi.prototype=new dp.sh.Highlighter();dp.sh.Brushes.Delphi.Aliases=["delphi","pascal"];dp.sh.Brushes.Java=function(){var $="abstract assert boolean break byte case catch char class const "+"continue default do double else enum extends "+"false final finally float for goto if implements import "+"instanceof int interface long native new null "+"package private protected public return "+"short static strictfp super switch synchronized this throw throws true "+"transient try void volatile while";this.regexList=[{regex:dp.sh.RegexLib.SingleLineCComments,css:"comment"},{regex:dp.sh.RegexLib.MultiLineCComments,css:"comment"},{regex:dp.sh.RegexLib.DoubleQuotedString,css:"string"},{regex:dp.sh.RegexLib.SingleQuotedString,css:"string"},{regex:new RegExp("\\b([\\d]+(\\.[\\d]+)?|0x[a-f0-9]+)\\b","gi"),css:"number"},{regex:new RegExp("(?!\\@interface\\b)\\@[\\$\\w]+\\b","g"),css:"annotation"},{regex:new RegExp("\\@interface\\b","g"),css:"keyword"},{regex:new RegExp(this.GetKeywords($),"gm"),css:"keyword"}];this.CssClass="dp-j";this.Style=".dp-j .annotation { color: #646464; }"+".dp-j .number { color: #C00000; }"};dp.sh.Brushes.Java.prototype=new dp.sh.Highlighter();dp.sh.Brushes.Java.Aliases=["java"];dp.sh.Brushes.JScript=function(){var $="abstract boolean break byte case catch char class const continue debugger "+"default delete do double else enum export extends false final finally float "+"for function goto if implements import in instanceof int interface long native "+"new null package private protected public return short static super switch "+"synchronized this throw throws transient true try typeof var void volatile while with";this.regexList=[{regex:dp.sh.RegexLib.SingleLineCComments,css:"comment"},{regex:dp.sh.RegexLib.MultiLineCComments,css:"comment"},{regex:dp.sh.RegexLib.DoubleQuotedString,css:"string"},{regex:dp.sh.RegexLib.SingleQuotedString,css:"string"},{regex:new RegExp("^\\s*#.*","gm"),css:"preprocessor"},{regex:new RegExp(this.GetKeywords($),"gm"),css:"keyword"}];this.CssClass="dp-c"};dp.sh.Brushes.JScript.prototype=new dp.sh.Highlighter();dp.sh.Brushes.JScript.Aliases=["js","jscript","javascript"];dp.sh.Brushes.Lua=function(){var $="break do end else elseif function if local nil not or repeat return and then until while this",_="math\\.\\w+ string\\.\\w+ os\\.\\w+ debug\\.\\w+ io\\.\\w+ error fopen dofile coroutine\\.\\w+ arg getmetatable ipairs loadfile loadlib loadstring longjmp print rawget rawset seek setmetatable assert tonumber tostring";this.regexList=[{regex:new RegExp("--\\[\\[[\\s\\S]*\\]\\]--","gm"),css:"comment"},{regex:new RegExp("--[^\\[]{2}.*$","gm"),css:"comment"},{regex:dp.sh.RegexLib.DoubleQuotedString,css:"string"},{regex:dp.sh.RegexLib.SingleQuotedString,css:"string"},{regex:new RegExp(this.GetKeywords($),"gm"),css:"keyword"},{regex:new RegExp(this.GetKeywords(_),"gm"),css:"func"},];this.CssClass="dp-lua"};dp.sh.Brushes.Lua.prototype=new dp.sh.Highlighter();dp.sh.Brushes.Lua.Aliases=["lua"];dp.sh.Brushes.Mxml=function(){this.CssClass="dp-mxml";this.Style=".dp-mxml .cdata { color: #000000; }"+".dp-mxml .tag { color : #0000ff; }"+".dp-mxml .tag-name { color: #0000ff; }"+".dp-mxml .script { color: green; }"+".dp-mxml .metadata { color: green; }"+".dp-mxml .attribute { color: #000000; }"+".dp-mxml .attribute-value { color: #990000; }"+".dp-mxml .trace { color: #cc6666; }"+".dp-mxml .var { color: #6699cc; }"+".dp-mxml .comment { color: #009900; }"+".dp-mxml .string { color: #990000; }"+".dp-mxml .keyword { color: blue; }"};dp.sh.Brushes.Mxml.prototype=new dp.sh.Highlighter();dp.sh.Brushes.Mxml.Aliases=["mxml"];dp.sh.Brushes.Mxml.prototype.ProcessRegexList=function(){function H(_,$){_[_.length]=$}function B(B,_){var A=0,$=false;for(A=0;A<B.length;A++)if(_.index>B[A].firstIndex&&_.index<B[A].lastIndex)$=true;return $}var $=0,F=null,D=null,A=null,C="",E=new Array(),_="abstract boolean break byte case catch char class const continue debugger "+"default delete do double else enum export extends false final finally float "+"for function goto if implements import in instanceof int interface long native "+"new null package private protected public return short static super switch "+"synchronized this throw throws transient true try typeof var void volatile while with",G=[{regex:dp.sh.RegexLib.SingleLineCComments,css:"comment"},{regex:dp.sh.RegexLib.MultiLineCComments,css:"comment"},{regex:dp.sh.RegexLib.DoubleQuotedString,css:"string"},{regex:dp.sh.RegexLib.SingleQuotedString,css:"string"},{regex:new RegExp("^\\s*#.*","gm"),css:"preprocessor"},{regex:new RegExp(this.GetKeywords("trace"),"gm"),css:"trace"},{regex:new RegExp(this.GetKeywords(_),"gm"),css:"keyword"}];A=new RegExp("&lt;\\!\\[CDATA\\[(.|\\s)*?\\]\\]&gt;","gm");while((F=A.exec(this.code))!=null){C=F[0].substr(0,12);H(this.matches,new dp.sh.Match(C,F.index,"cdata"));C=F[0].substr(12,F[0].length-12-6);for(var I=0;I<G.length;I++)while((D=G[I].regex.exec(C))!=null)H(this.matches,new dp.sh.Match(D[0],F.index+12+D.index,G[I].css));C=F[0].substr(F[0].length-6,6);H(this.matches,new dp.sh.Match(C,F.index+F[0].length-6,"cdata"));E.push({firstIndex:F.index,lastIndex:F.index+F[0].length-1})}this.GetMatches(new RegExp("(&lt;|<)!--\\s*.*?\\s*--(&gt;|>)","gm"),"comments");A=new RegExp("([:\\w-.]+)\\s*=\\s*(\".*?\"|'.*?'|\\w+)*|(\\w+)","gm");while((F=A.exec(this.code))!=null){if(F[1]==null)continue;if(B(E,F))continue;H(this.matches,new dp.sh.Match(F[1],F.index,"attribute"));if(F[2]!=undefined)H(this.matches,new dp.sh.Match(F[2],F.index+F[0].indexOf(F[2]),"attribute-value"))}A=new RegExp("(?:&lt;|<)/*\\?*\\s*([:\\w-.]+)","gm");while((F=A.exec(this.code))!=null){if(B(E,F))continue;C=F[0].substr(4,F[0].length-4);switch(C){case"mx:Script":case"/mx:Script":H(this.matches,new dp.sh.Match(F[0]+"&gt;",F.index,"script"));break;case"mx:Metadata":case"/mx:Metadata":H(this.matches,new dp.sh.Match(F[0]+"&gt;",F.index,"metadata"));break;default:H(this.matches,new dp.sh.Match(F[0],F.index,"tag-name"));break}}A=new RegExp("\\?&gt;|&gt;|/&gt;","gm");while((F=A.exec(this.code))!=null){if(B(E,F))continue;H(this.matches,new dp.sh.Match(F[0],F.index,"tag"))}};dp.sh.Brushes.Perl=function(){var _="abs accept alarm atan2 bind binmode bless caller chdir chmod chomp chop chown chr chroot close closedir connect cos crypt dbmclose dbmopen defined delete dump each endgrent endhostent endnetent endprotoent endpwent endservent eof exec exists exp fcntl fileno flock fork format formline getc getgrent getgrgid getgrnam gethostbyaddr gethostbyname gethostent getlogin getnetbyaddr getnetbyname getnetent getpeername getpgrp getppid getpriority getprotobyname getprotobynumber getprotoent getpwent getpwnam getpwuid getservbyname getservbyport getservent getsockname getsockopt glob gmtime grep hex import index int ioctl join keys kill lc lcfirst length link listen localtime lock log lstat m map mkdir msgctl msgget msgrcv msgsnd no oct open opendir ord pack pipe pop pos print printf prototype push q qq quotemeta qw qx rand read readdir readline readlink readpipe recv ref rename reset reverse rewinddir rindex rmdir scalar seek seekdir semctl semget semop send setgrent sethostent setnetent setpgrp setpriority setprotoent setpwent setservent setsockopt shift shmctl shmget shmread shmwrite shutdown sin sleep socket socketpair sort splice split sprintf sqrt srand stat study sub substr symlink syscall sysopen sysread sysseek system syswrite tell telldir tie tied time times tr truncate uc ucfirst umask undef unlink unpack unshift untie utime values vec waitpid wantarray warn write qr",$="s select goto die do package redo require return continue for foreach last next wait while use if else elsif eval exit unless switch case",A="my our local";this.regexList=[{regex:dp.sh.RegexLib.SingleLinePerlComments,css:"comment"},{regex:dp.sh.RegexLib.DoubleQuotedString,css:"string"},{regex:dp.sh.RegexLib.SingleQuotedString,css:"string"},{regex:new RegExp("(\\$|@|%)\\w+","g"),css:"vars"},{regex:new RegExp(this.GetKeywords(_),"gmi"),css:"func"},{regex:new RegExp(this.GetKeywords($),"gm"),css:"keyword"},{regex:new RegExp(this.GetKeywords(A),"gm"),css:"declarations"}];this.CssClass="dp-perl"};dp.sh.Brushes.Perl.prototype=new dp.sh.Highlighter();dp.sh.Brushes.Perl.Aliases=["perl"];dp.sh.Brushes.Php=function(){var _="abs acos acosh addcslashes addslashes "+"array_change_key_case array_chunk array_combine array_count_values array_diff "+"array_diff_assoc array_diff_key array_diff_uassoc array_diff_ukey array_fill "+"array_filter array_flip array_intersect array_intersect_assoc array_intersect_key "+"array_intersect_uassoc array_intersect_ukey array_key_exists array_keys array_map "+"array_merge array_merge_recursive array_multisort array_pad array_pop array_product "+"array_push array_rand array_reduce array_reverse array_search array_shift "+"array_slice array_splice array_sum array_udiff array_udiff_assoc "+"array_udiff_uassoc array_uintersect array_uintersect_assoc "+"array_uintersect_uassoc array_unique array_unshift array_values array_walk "+"array_walk_recursive atan atan2 atanh base64_decode base64_encode base_convert "+"basename bcadd bccomp bcdiv bcmod bcmul bindec bindtextdomain bzclose bzcompress "+"bzdecompress bzerrno bzerror bzerrstr bzflush bzopen bzread bzwrite ceil chdir "+"checkdate checkdnsrr chgrp chmod chop chown chr chroot chunk_split class_exists "+"closedir closelog copy cos cosh count count_chars date decbin dechex decoct "+"deg2rad delete ebcdic2ascii echo empty end ereg ereg_replace eregi eregi_replace error_log "+"error_reporting escapeshellarg escapeshellcmd eval exec exit exp explode extension_loaded "+"feof fflush fgetc fgetcsv fgets fgetss file_exists file_get_contents file_put_contents "+"fileatime filectime filegroup fileinode filemtime fileowner fileperms filesize filetype "+"floatval flock floor flush fmod fnmatch fopen fpassthru fprintf fputcsv fputs fread fscanf "+"fseek fsockopen fstat ftell ftok getallheaders getcwd getdate getenv gethostbyaddr gethostbyname "+"gethostbynamel getimagesize getlastmod getmxrr getmygid getmyinode getmypid getmyuid getopt "+"getprotobyname getprotobynumber getrandmax getrusage getservbyname getservbyport gettext "+"gettimeofday gettype glob gmdate gmmktime ini_alter ini_get ini_get_all ini_restore ini_set "+"interface_exists intval ip2long is_a is_array is_bool is_callable is_dir is_double "+"is_executable is_file is_finite is_float is_infinite is_int is_integer is_link is_long "+"is_nan is_null is_numeric is_object is_readable is_real is_resource is_scalar is_soap_fault "+"is_string is_subclass_of is_uploaded_file is_writable is_writeable mkdir mktime nl2br "+"parse_ini_file parse_str parse_url passthru pathinfo readlink realpath rewind rewinddir rmdir "+"round str_ireplace str_pad str_repeat str_replace str_rot13 str_shuffle str_split "+"str_word_count strcasecmp strchr strcmp strcoll strcspn strftime strip_tags stripcslashes "+"stripos stripslashes stristr strlen strnatcasecmp strnatcmp strncasecmp strncmp strpbrk "+"strpos strptime strrchr strrev strripos strrpos strspn strstr strtok strtolower strtotime "+"strtoupper strtr strval substr substr_compare",$="and or xor __FILE__ __LINE__ array as break case "+"cfunction class const continue declare default die do else "+"elseif empty enddeclare endfor endforeach endif endswitch endwhile "+"extends for foreach function include include_once global if "+"new old_function return static switch use require require_once "+"var while __FUNCTION__ __CLASS__ "+"__METHOD__ abstract interface public implements extends private protected throw";this.regexList=[{regex:dp.sh.RegexLib.SingleLineCComments,css:"comment"},{regex:dp.sh.RegexLib.MultiLineCComments,css:"comment"},{regex:dp.sh.RegexLib.DoubleQuotedString,css:"string"},{regex:dp.sh.RegexLib.SingleQuotedString,css:"string"},{regex:new RegExp("\\$\\w+","g"),css:"vars"},{regex:new RegExp(this.GetKeywords(_),"gmi"),css:"func"},{regex:new RegExp(this.GetKeywords($),"gm"),css:"keyword"}];this.CssClass="dp-c"};dp.sh.Brushes.Php.prototype=new dp.sh.Highlighter();dp.sh.Brushes.Php.Aliases=["php"];dp.sh.Brushes.Python=function(){var $="and assert break class continue def del elif else "+"except exec finally for from global if import in is "+"lambda not or pass print raise return try yield while",_="None True False self cls class_";this.regexList=[{regex:dp.sh.RegexLib.SingleLinePerlComments,css:"comment"},{regex:new RegExp("^\\s*@\\w+","gm"),css:"decorator"},{regex:new RegExp("(['\"]{3})([^\\1])*?\\1","gm"),css:"comment"},{regex:new RegExp("\"(?!\")(?:\\.|\\\\\\\"|[^\\\"\"\\n\\r])*\"","gm"),css:"string"},{regex:new RegExp("'(?!')*(?:\\.|(\\\\\\')|[^\\''\\n\\r])*'","gm"),css:"string"},{regex:new RegExp("\\b\\d+\\.?\\w*","g"),css:"number"},{regex:new RegExp(this.GetKeywords($),"gm"),css:"keyword"},{regex:new RegExp(this.GetKeywords(_),"gm"),css:"special"}];this.CssClass="dp-py";this.Style=".dp-py .builtins { color: #ff1493; }"+".dp-py .magicmethods { color: #808080; }"+".dp-py .exceptions { color: brown; }"+".dp-py .types { color: brown; font-style: italic; }"+".dp-py .commonlibs { color: #8A2BE2; font-style: italic; }"};dp.sh.Brushes.Python.prototype=new dp.sh.Highlighter();dp.sh.Brushes.Python.Aliases=["py","python"];dp.sh.Brushes.Ruby=function(){var $="alias and BEGIN begin break case class def define_method defined do each else elsif "+"END end ensure false for if in module new next nil not or raise redo rescue retry return "+"self super then throw true undef unless until when while yield",_="Array Bignum Binding Class Continuation Dir Exception FalseClass File::Stat File Fixnum Fload "+"Hash Integer IO MatchData Method Module NilClass Numeric Object Proc Range Regexp String Struct::TMS Symbol "+"ThreadGroup Thread Time TrueClass";this.regexList=[{regex:dp.sh.RegexLib.SingleLinePerlComments,css:"comment"},{regex:dp.sh.RegexLib.DoubleQuotedString,css:"string"},{regex:dp.sh.RegexLib.SingleQuotedString,css:"string"},{regex:new RegExp(":[a-z][A-Za-z0-9_]*","g"),css:"symbol"},{regex:new RegExp("(\\$|@@|@)\\w+","g"),css:"variable"},{regex:new RegExp(this.GetKeywords($),"gm"),css:"keyword"},{regex:new RegExp(this.GetKeywords(_),"gm"),css:"builtin"}];this.CssClass="dp-rb";this.Style=".dp-rb .symbol { color: #a70; }"+".dp-rb .variable { color: #a70; font-weight: bold; }"};dp.sh.Brushes.Ruby.prototype=new dp.sh.Highlighter();dp.sh.Brushes.Ruby.Aliases=["ruby","rails","ror"];dp.sh.Brushes.Sql=function(){var _="abs avg case cast coalesce convert count current_timestamp "+"current_user day isnull left lower month nullif replace right "+"session_user space substring sum system_user upper user year",$="absolute action add after alter as asc at authorization begin bigint "+"binary bit by cascade char character check checkpoint close collate "+"column commit committed connect connection constraint contains continue "+"create cube current current_date current_time cursor database date "+"deallocate dec decimal declare default delete desc distinct double drop "+"dynamic else end end-exec escape except exec execute false fetch first "+"float for force foreign forward free from full function global goto grant "+"group grouping having hour ignore index inner insensitive insert instead "+"int integer intersect into is isolation key last level load local max min "+"minute modify move name national nchar next no numeric of off on only "+"open option order out output partial password precision prepare primary "+"prior privileges procedure public read real references relative repeatable "+"restrict return returns revoke rollback rollup rows rule schema scroll "+"second section select sequence serializable set size smallint static "+"statistics table temp temporary then time timestamp to top transaction "+"translation trigger true truncate uncommitted union unique update values "+"varchar varying view when where with work",A="all and any between cross in join like not null or outer some";this.regexList=[{regex:new RegExp("--(.*)$","gm"),css:"comment"},{regex:dp.sh.RegexLib.DoubleQuotedString,css:"string"},{regex:dp.sh.RegexLib.SingleQuotedString,css:"string"},{regex:new RegExp(this.GetKeywords(_),"gmi"),css:"func"},{regex:new RegExp(this.GetKeywords(A),"gmi"),css:"op"},{regex:new RegExp(this.GetKeywords($),"gmi"),css:"keyword"}];this.CssClass="dp-sql";this.Style=".dp-sql .func { color: #ff1493; }"+".dp-sql .op { color: #808080; }"};dp.sh.Brushes.Sql.prototype=new dp.sh.Highlighter();dp.sh.Brushes.Sql.Aliases=["sql"];dp.sh.Brushes.Vb=function(){var $="AddHandler AddressOf AndAlso Alias And Ansi As Assembly Auto "+"Boolean ByRef Byte ByVal Call Case Catch CBool CByte CChar CDate "+"CDec CDbl Char CInt Class CLng CObj Const CShort CSng CStr CType "+"Date Decimal Declare Default Delegate Dim DirectCast Do Double Each "+"Else ElseIf End Enum Erase Error Event Exit False Finally For Friend "+"Function Get GetType GoSub GoTo Handles If Implements Imports In "+"Inherits Integer Interface Is Let Lib Like Long Loop Me Mod Module "+"MustInherit MustOverride MyBase MyClass Namespace New Next Not Nothing "+"NotInheritable NotOverridable Object On Option Optional Or OrElse "+"Overloads Overridable Overrides ParamArray Preserve Private Property "+"Protected Public RaiseEvent ReadOnly ReDim REM RemoveHandler Resume "+"Return Select Set Shadows Shared Short Single Static Step Stop String "+"Structure Sub SyncLock Then Throw To True Try TypeOf Unicode Until "+"Variant When While With WithEvents WriteOnly Xor";this.regexList=[{regex:new RegExp("'.*$","gm"),css:"comment"},{regex:dp.sh.RegexLib.DoubleQuotedString,css:"string"},{regex:new RegExp("^\\s*#.*","gm"),css:"preprocessor"},{regex:new RegExp(this.GetKeywords($),"gm"),css:"keyword"}];this.CssClass="dp-vb"};dp.sh.Brushes.Vb.prototype=new dp.sh.Highlighter();dp.sh.Brushes.Vb.Aliases=["vb","vb.net"];dp.sh.Brushes.Xml=function(){this.CssClass="dp-xml";this.Style=".dp-xml .cdata { color: #ff1493; }"+".dp-xml .tag, .dp-xml .tag-name { color: #069; font-weight: bold; }"+".dp-xml .attribute { color: red; }"+".dp-xml .attribute-value { color: blue; }"};dp.sh.Brushes.Xml.prototype=new dp.sh.Highlighter();dp.sh.Brushes.Xml.Aliases=["xml","xhtml","xslt","html","xhtml"];dp.sh.Brushes.Xml.prototype.ProcessRegexList=function(){function B(_,$){_[_.length]=$}var $=0,A=null,_=null;this.GetMatches(new RegExp("(&lt;|<)\\!\\[[\\w\\s]*?\\[(.|\\s)*?\\]\\](&gt;|>)","gm"),"cdata");this.GetMatches(new RegExp("(&lt;|<)!--\\s*.*?\\s*--(&gt;|>)","gm"),"comments");_=new RegExp("([:\\w-.]+)\\s*=\\s*(\".*?\"|'.*?'|\\w+)*|(\\w+)","gm");while((A=_.exec(this.code))!=null){if(A[1]==null)continue;B(this.matches,new dp.sh.Match(A[1],A.index,"attribute"));if(A[2]!=undefined)B(this.matches,new dp.sh.Match(A[2],A.index+A[0].indexOf(A[2]),"attribute-value"))}this.GetMatches(new RegExp("(&lt;|<)/*\\?*(?!\\!)|/*\\?*(&gt;|>)","gm"),"tag");_=new RegExp("(?:&lt;|<)/*\\?*\\s*([:\\w-.]+)","gm");while((A=_.exec(this.code))!=null)B(this.matches,new dp.sh.Match(A[1],A.index+A[0].indexOf(A[1]),"tag-name"))}
//}}}
[[foobar显示歌词心得]]
*TiddlyWiki是采用Javascript+CSS+HTML构成的小程序,外表看起来仅仅是一个html页面,但由于其中采用js技术,就显得很酷很炫,真是可以称为绿色软件。它与wiki的不同之处是不能像一般的wiki程序一样在网络上由多人共同编辑,其他的功能一概不缺。而且,TiddlyWiki只需要通过浏览器执行,完全不需要PHP,或者ASP以及数据库等的支持。
*TiddlyWiki是由Jeremy Ruston开发的,目前Bram Chen的简体中文翻译,由于fans众多,而且都很努力,所以目前出现了多种版本应用,已经出现可以在网络上直接编辑的TiddlyWiki。
*那TiddlyWiki到底可以用来做什么呢?
*#在本地电脑中,它可以用来做记事本,日记,备忘录等等,但我个人感觉用来收集资料或者做教程将是非常理想,因为Wiki的内部互相链接,可以使一个框架不断展开,直到深层。
*#你也可以像我一样,将你编辑的内容上传变成一个网页或者网站。
台湾同胞在TiddlyWiki方面的研究远远超过了中国大陆,您可以在[[相关链接]]查看更多专业的作者,快速进步,变成高手。
Here is an incomplete list of some excellent TiddlyWiki Adaptations. If you want to be listed here, just email me at "jim at barr dot net" and I will gladly add your site!
|~JimBarr's ~TiddlyWikiTasks |http://TiddlyWikiTips.com/TiddlyWikiTasks.html|
|~KeithHodges' ~TiddlyPom |http://www.warwick.ac.uk/~tuspam/tiddlypom.html|
|~RodneyGomes' ~RoWiki, based on PyTW |http://rodney.gotdns.com/|
|~LarsEnglund's ~TiddlyWikiRDF |http://larsenglund.com/TiddlyWikiRDF/|
|~BramChen's ~PrinceTiddlyWiki |http://ptw.sf.net/index-en.html|
|~JoshGoebel's ~ServerSideWiki |http://www.serversidewiki.com|
|~MasakiYatsu's ~LesserWiki |http://lesserwiki.org/|
|~MichaelBridgen's ~StickyWiki |http://www.squaremobius.net/~mikeb/Darcs/sticky-wiki/|
|~DavidHarper's ~BloTid |http://www.spacecoastweb.net/BloTid/Tiddly/|
|~EricShulman's ELS Design site |http://www.elsdesign.com/tiddlywiki/|
|~JacquesTurbé's ~TidliPo, in French |http://avm.free.fr/tidlipo.html|
|~JoeRaii's pytw |http://www.cs.utexas.edu/~joeraii/pytw/ |
|and his Siglet |http://www.cs.utexas.edu/~joeraii/siglet/|
|~JároliJózsef's ~MagyarTiddlyWiki |http://innen.hu/MagyarTiddlyWiki in Hungarian|
|Yoshimov's ~EncryptedTiddlyWiki |http://wiki.yoshimov.com/?page=EncryptedTiddlyWiki|
|~TiagoDionizio's ~TsWiki using Tcl and ~SQLite |http://mega.ist.utl.pt/~tngd/wiki/|
|~TimMorgan's ~ZiddlyWiki based on Zope |http://timmorgan.org/ZiddlyWiki/|
|~SteveRumsby's ~YetAnotherTiddlyWikiAdaptation |http://www.rumsby.org/yatwa/|
|~PhonoHawk's ~PerlTiddlyWiki |http://ccm.sherry.jp/tiddly/|
|~NathanBower's ~GTDTiddlyWiki |http://shared.snapgrid.com/gtd_tiddlywiki.html|
|~SimonBaird's ~MonkeyPirateTiddlyWiki |http://simonbaird.com/mptw/|
|~GeetDuggal's ~PileTiddly |http://www.geetduggal.com/PileTiddly/|
|~DanPhiffer's ~TiddlyWikiRemote |http://phiffer.org/tiddly/|
|~JonnyLeRoy's ~TiddlyTagWiki |http://www.digitaldimsum.co.uk/|
|~JodyFoo's ~TagglyWiki |http://informationality.com/tagglywiki/tagglywiki.html|
|~ChristianHauck's |http://www.christianhauck.net/html/14300.html|
|~TonyLownds's ~TiddlyHacks |http://tony.lownds.com/tiddly/dev/cgi/index.cgi|
|~AlanHecht's ~QwikiWeb |http://snipurl.com/qwikiweb|
|~TimCuthbertson and ~MattGiuca's ~TiddlyWikiCSS |http://codestar.lidonet.net/misc/tiddlywikicss.html|
|~PeterLazarev's further improvements |http://petka.webhop.net/#NiceTiddlyWiki|
|~PatrickCurry and ~GabrielJeffrey's ~PhpTiddlyWiki |http://www.patrickcurry.com/tiddly/|
|~KevemBuangga's ~TiddlyWikiClone |http://www.kevembuangga.com/hwk/hailiwiki.htm|
|Inspired by ~TiddlyWiki, Dr ~MichaelRees' ~DotWikIE |http://comet.it.bond.edu.au/dotsoft/Pages/dotwikiehome.aspx|
相关资源:[[igvita|http://www.igvita.com/2009/02/13/tokyo-cabinet-beyond-key-value-store/]]的这篇很详细的介绍,以及[[官方文档|http://tokyocabinet.sourceforge.net/spex-en.html]]

看下来有如下几点理解:
#Cabinet快在他是key-value形的数据库,所以存储overhead也少了很多
#但是Cabinet功能不简单,照样提供了具有关系类型的tableDatabase
#各个类型的database的特点如下(其实官方文档上很清楚了):
>Hash Database速度很快,支持变长,但是不提供排序功能;
>B+ 同样支持变长,因为支持排序,所以速度较Hash慢;
>Fixed Length 不支持排序,不支持变长,但是也因此速度嗖嗖的,而且用mmap映射到内存,磁盘I/O进一步减少,速度更嗖嗖的;
>Table 支持变长,可以排序,有传统relational database复杂的功能,所以速度也影响,但是他更灵活(如不需要定义schema,详见igvita的文章);
总结来说:
>''速度:''{{{Fixed Length > Hash Database > B+ > Table }}}
>''功能:''{{{与速度正好相反}}}
具体使用要看情况

@@color(red):跟新@@
[[这篇文章|http://willko.javaeye.com/blog/333003]]的留言里作者讲到了三种不同类型数据库的特点及应用场景,作者博客里的其他几篇文章也很不错
[[这个博客|http://zhliji2.blogspot.com/2009/04/phptokyo-cabinetmemcache.html]]里有是几篇将tokyo的,主要是和PHP互操作
/***
Description: Contains the stuff you need to use Tiddlyspot
Note, you also need UploadPlugin, PasswordOptionPlugin and LoadRemoteFileThroughProxy
from http://tiddlywiki.bidix.info for a complete working Tiddlyspot site.
***/
//{{{

// edit this if you are migrating sites or retrofitting an existing TW
config.tiddlyspotSiteId = 'telooon';

// make it so you can by default see edit controls via http
config.options.chkHttpReadOnly = false;
window.readOnly = false; // make sure of it (for tw 2.2)
window.showBackstage = true; // show backstage too

// disable autosave in d3
if (window.location.protocol != "file:")
	config.options.chkGTDLazyAutoSave = false;

// tweak shadow tiddlers to add upload button, password entry box etc
with (config.shadowTiddlers) {
	SiteUrl = 'http://'+config.tiddlyspotSiteId+'.tiddlyspot.com';
	SideBarOptions = SideBarOptions.replace(/(<<saveChanges>>)/,"$1<<tiddler TspotSidebar>>");
	OptionsPanel = OptionsPanel.replace(/^/,"<<tiddler TspotOptions>>");
	DefaultTiddlers = DefaultTiddlers.replace(/^/,"[[WelcomeToTiddlyspot]] ");
	MainMenu = MainMenu.replace(/^/,"[[WelcomeToTiddlyspot]] ");
}

// create some shadow tiddler content
merge(config.shadowTiddlers,{

'TspotOptions':[
 "tiddlyspot password:",
 "<<option pasUploadPassword>>",
 ""
].join("\n"),

'TspotControls':[
 "| tiddlyspot password:|<<option pasUploadPassword>>|",
 "| site management:|<<upload http://" + config.tiddlyspotSiteId + ".tiddlyspot.com/store.cgi index.html . .  " + config.tiddlyspotSiteId + ">>//(requires tiddlyspot password)//<br>[[control panel|http://" + config.tiddlyspotSiteId + ".tiddlyspot.com/controlpanel]], [[download (go offline)|http://" + config.tiddlyspotSiteId + ".tiddlyspot.com/download]]|",
 "| links:|[[tiddlyspot.com|http://tiddlyspot.com/]], [[FAQs|http://faq.tiddlyspot.com/]], [[blog|http://tiddlyspot.blogspot.com/]], email [[support|mailto:support@tiddlyspot.com]] & [[feedback|mailto:feedback@tiddlyspot.com]], [[donate|http://tiddlyspot.com/?page=donate]]|"
].join("\n"),

'WelcomeToTiddlyspot':[
 "This document is a ~TiddlyWiki from tiddlyspot.com.  A ~TiddlyWiki is an electronic notebook that is great for managing todo lists, personal information, and all sorts of things.",
 "",
 "@@font-weight:bold;font-size:1.3em;color:#444; //What now?// &nbsp;&nbsp;@@ Before you can save any changes, you need to enter your password in the form below.  Then configure privacy and other site settings at your [[control panel|http://" + config.tiddlyspotSiteId + ".tiddlyspot.com/controlpanel]] (your control panel username is //" + config.tiddlyspotSiteId + "//).",
 "<<tiddler TspotControls>>",
 "See also GettingStarted.",
 "",
 "@@font-weight:bold;font-size:1.3em;color:#444; //Working online// &nbsp;&nbsp;@@ You can edit this ~TiddlyWiki right now, and save your changes using the \"save to web\" button in the column on the right.",
 "",
 "@@font-weight:bold;font-size:1.3em;color:#444; //Working offline// &nbsp;&nbsp;@@ A fully functioning copy of this ~TiddlyWiki can be saved onto your hard drive or USB stick.  You can make changes and save them locally without being connected to the Internet.  When you're ready to sync up again, just click \"upload\" and your ~TiddlyWiki will be saved back to tiddlyspot.com.",
 "",
 "@@font-weight:bold;font-size:1.3em;color:#444; //Help!// &nbsp;&nbsp;@@ Find out more about ~TiddlyWiki at [[TiddlyWiki.com|http://tiddlywiki.com]].  Also visit [[TiddlyWiki.org|http://tiddlywiki.org]] for documentation on learning and using ~TiddlyWiki. New users are especially welcome on the [[TiddlyWiki mailing list|http://groups.google.com/group/TiddlyWiki]], which is an excellent place to ask questions and get help.  If you have a tiddlyspot related problem email [[tiddlyspot support|mailto:support@tiddlyspot.com]].",
 "",
 "@@font-weight:bold;font-size:1.3em;color:#444; //Enjoy :)// &nbsp;&nbsp;@@ We hope you like using your tiddlyspot.com site.  Please email [[feedback@tiddlyspot.com|mailto:feedback@tiddlyspot.com]] with any comments or suggestions."
].join("\n"),

'TspotSidebar':[
 "<<upload http://" + config.tiddlyspotSiteId + ".tiddlyspot.com/store.cgi index.html . .  " + config.tiddlyspotSiteId + ">><html><a href='http://" + config.tiddlyspotSiteId + ".tiddlyspot.com/download' class='button'>download</a></html>"
].join("\n")

});
//}}}
根据[[这里|http://hi.baidu.com/wuxicn/blog/item/20eb1a0a84913b1a94ca6ba0.html]]所说的下载解压,HEAD ONLY部分一样,但是下面要编译安装部分还是参考官网上[[教程|http://www.boost.org/doc/libs/1_39_0/more/getting_started/unix-variants.html#build-directory]]。

下面这些库是需要单独编译的:
* Boost.Filesystem
* Boost.IOStreams
* Boost.ProgramOptions
* Boost.Python (see the Boost.Python build documentation before building and installing it)
* Boost.Regex
* Boost.Serialization
* Boost.Signals
* Boost.System
* Boost.Thread
* Boost.Wave

编译步骤如下同官网教程5.1节,但要注意的是
*''./bootstrap.sh''生成的是''project-config.jam''文件,应该是bjam工具的配置文件
*''{{{--prefix=path/to/installation/prefix}}}''参数是指定下一步运行bjam生成链接文件的位置;{{{--with-libraries=filesystem}}}参数来指定编译的库;其他可用{{{--help}}}来查看相关选项;
*''./bjam install''生成的主要内容是''stage文件夹'',里面的内容是所需要的连接文件。还有些中间文件生成,如bin.v2目录
*最后把stage目录中的文件拷到/usr/lib目录,这样就可用''-lboost_filesystem-gcc42-mt''参数来连接它
| !date | !user | !location | !storeUrl | !uploadDir | !toFilename | !backupdir | !origin |
| 04/11/2011 13:55:11 | wy | [[/|http://telooon.tiddlyspot.com/]] | [[store.cgi|http://telooon.tiddlyspot.com/store.cgi]] | . | [[index.html | http://telooon.tiddlyspot.com/index.html]] | . |
| 28/12/2011 12:35:28 | wy | [[/|http://telooon.tiddlyspot.com/]] | [[store.cgi|http://telooon.tiddlyspot.com/store.cgi]] | . | [[index.html | http://telooon.tiddlyspot.com/index.html]] | . |
| 29/12/2011 14:02:58 | YourName | [[/|http://telooon.tiddlyspot.com/]] | [[store.cgi|http://telooon.tiddlyspot.com/store.cgi]] | . | [[index.html | http://telooon.tiddlyspot.com/index.html]] | . |
| 16/02/2012 00:16:50 | teloon | [[/|http://telooon.tiddlyspot.com/]] | [[store.cgi|http://telooon.tiddlyspot.com/store.cgi]] | . | [[index.html | http://telooon.tiddlyspot.com/index.html]] | . |
| 02/03/2012 14:37:01 | teloon | [[/|http://telooon.tiddlyspot.com/]] | [[store.cgi|http://telooon.tiddlyspot.com/store.cgi]] | . | [[index.html | http://telooon.tiddlyspot.com/index.html]] | . |
| 23/04/2012 22:59:32 | wy | [[/|http://telooon.tiddlyspot.com/]] | [[store.cgi|http://telooon.tiddlyspot.com/store.cgi]] | . | [[index.html | http://telooon.tiddlyspot.com/index.html]] | . |
| 04/09/2012 12:58:09 | wy | [[/|http://telooon.tiddlyspot.com/]] | [[store.cgi|http://telooon.tiddlyspot.com/store.cgi]] | . | [[index.html | http://telooon.tiddlyspot.com/index.html]] | . |
| 08/04/2013 17:07:56 | wy | [[/|http://telooon.tiddlyspot.com/]] | [[store.cgi|http://telooon.tiddlyspot.com/store.cgi]] | . | [[index.html | http://telooon.tiddlyspot.com/index.html]] | . | ok |
| 08/04/2013 17:09:48 | wy | [[/|http://telooon.tiddlyspot.com/]] | [[store.cgi|http://telooon.tiddlyspot.com/store.cgi]] | . | [[index.html | http://telooon.tiddlyspot.com/index.html]] | . | ok |
| 08/04/2013 17:10:37 | wy | [[/|http://telooon.tiddlyspot.com/]] | [[store.cgi|http://telooon.tiddlyspot.com/store.cgi]] | . | [[index.html | http://telooon.tiddlyspot.com/index.html]] | . |
/***
|''Name:''|UploadPlugin|
|''Description:''|Save to web a TiddlyWiki|
|''Version:''|4.1.3|
|''Date:''|Feb 24, 2008|
|''Source:''|http://tiddlywiki.bidix.info/#UploadPlugin|
|''Documentation:''|http://tiddlywiki.bidix.info/#UploadPluginDoc|
|''Author:''|BidiX (BidiX (at) bidix (dot) info)|
|''License:''|[[BSD open source license|http://tiddlywiki.bidix.info/#%5B%5BBSD%20open%20source%20license%5D%5D ]]|
|''~CoreVersion:''|2.2.0|
|''Requires:''|PasswordOptionPlugin|
***/
//{{{
version.extensions.UploadPlugin = {
	major: 4, minor: 1, revision: 3,
	date: new Date("Feb 24, 2008"),
	source: 'http://tiddlywiki.bidix.info/#UploadPlugin',
	author: 'BidiX (BidiX (at) bidix (dot) info',
	coreVersion: '2.2.0'
};

//
// Environment
//

if (!window.bidix) window.bidix = {}; // bidix namespace
bidix.debugMode = false;	// true to activate both in Plugin and UploadService
	
//
// Upload Macro
//

config.macros.upload = {
// default values
	defaultBackupDir: '',	//no backup
	defaultStoreScript: "store.php",
	defaultToFilename: "index.html",
	defaultUploadDir: ".",
	authenticateUser: true	// UploadService Authenticate User
};
	
config.macros.upload.label = {
	promptOption: "Save and Upload this TiddlyWiki with UploadOptions",
	promptParamMacro: "Save and Upload this TiddlyWiki in %0",
	saveLabel: "save to web", 
	saveToDisk: "save to disk",
	uploadLabel: "upload"	
};

config.macros.upload.messages = {
	noStoreUrl: "No store URL in parmeters or options",
	usernameOrPasswordMissing: "Username or password missing"
};

config.macros.upload.handler = function(place,macroName,params) {
	if (readOnly)
		return;
	var label;
	if (document.location.toString().substr(0,4) == "http") 
		label = this.label.saveLabel;
	else
		label = this.label.uploadLabel;
	var prompt;
	if (params[0]) {
		prompt = this.label.promptParamMacro.toString().format([this.destFile(params[0], 
			(params[1] ? params[1]:bidix.basename(window.location.toString())), params[3])]);
	} else {
		prompt = this.label.promptOption;
	}
	createTiddlyButton(place, label, prompt, function() {config.macros.upload.action(params);}, null, null, this.accessKey);
};

config.macros.upload.action = function(params)
{
		// for missing macro parameter set value from options
		if (!params) params = {};
		var storeUrl = params[0] ? params[0] : config.options.txtUploadStoreUrl;
		var toFilename = params[1] ? params[1] : config.options.txtUploadFilename;
		var backupDir = params[2] ? params[2] : config.options.txtUploadBackupDir;
		var uploadDir = params[3] ? params[3] : config.options.txtUploadDir;
		var username = params[4] ? params[4] : config.options.txtUploadUserName;
		var password = config.options.pasUploadPassword; // for security reason no password as macro parameter	
		// for still missing parameter set default value
		if ((!storeUrl) && (document.location.toString().substr(0,4) == "http")) 
			storeUrl = bidix.dirname(document.location.toString())+'/'+config.macros.upload.defaultStoreScript;
		if (storeUrl.substr(0,4) != "http")
			storeUrl = bidix.dirname(document.location.toString()) +'/'+ storeUrl;
		if (!toFilename)
			toFilename = bidix.basename(window.location.toString());
		if (!toFilename)
			toFilename = config.macros.upload.defaultToFilename;
		if (!uploadDir)
			uploadDir = config.macros.upload.defaultUploadDir;
		if (!backupDir)
			backupDir = config.macros.upload.defaultBackupDir;
		// report error if still missing
		if (!storeUrl) {
			alert(config.macros.upload.messages.noStoreUrl);
			clearMessage();
			return false;
		}
		if (config.macros.upload.authenticateUser && (!username || !password)) {
			alert(config.macros.upload.messages.usernameOrPasswordMissing);
			clearMessage();
			return false;
		}
		bidix.upload.uploadChanges(false,null,storeUrl, toFilename, uploadDir, backupDir, username, password); 
		return false; 
};

config.macros.upload.destFile = function(storeUrl, toFilename, uploadDir) 
{
	if (!storeUrl)
		return null;
		var dest = bidix.dirname(storeUrl);
		if (uploadDir && uploadDir != '.')
			dest = dest + '/' + uploadDir;
		dest = dest + '/' + toFilename;
	return dest;
};

//
// uploadOptions Macro
//

config.macros.uploadOptions = {
	handler: function(place,macroName,params) {
		var wizard = new Wizard();
		wizard.createWizard(place,this.wizardTitle);
		wizard.addStep(this.step1Title,this.step1Html);
		var markList = wizard.getElement("markList");
		var listWrapper = document.createElement("div");
		markList.parentNode.insertBefore(listWrapper,markList);
		wizard.setValue("listWrapper",listWrapper);
		this.refreshOptions(listWrapper,false);
		var uploadCaption;
		if (document.location.toString().substr(0,4) == "http") 
			uploadCaption = config.macros.upload.label.saveLabel;
		else
			uploadCaption = config.macros.upload.label.uploadLabel;
		
		wizard.setButtons([
				{caption: uploadCaption, tooltip: config.macros.upload.label.promptOption, 
					onClick: config.macros.upload.action},
				{caption: this.cancelButton, tooltip: this.cancelButtonPrompt, onClick: this.onCancel}
				
			]);
	},
	options: [
		"txtUploadUserName",
		"pasUploadPassword",
		"txtUploadStoreUrl",
		"txtUploadDir",
		"txtUploadFilename",
		"txtUploadBackupDir",
		"chkUploadLog",
		"txtUploadLogMaxLine"		
	],
	refreshOptions: function(listWrapper) {
		var opts = [];
		for(i=0; i<this.options.length; i++) {
			var opt = {};
			opts.push();
			opt.option = "";
			n = this.options[i];
			opt.name = n;
			opt.lowlight = !config.optionsDesc[n];
			opt.description = opt.lowlight ? this.unknownDescription : config.optionsDesc[n];
			opts.push(opt);
		}
		var listview = ListView.create(listWrapper,opts,this.listViewTemplate);
		for(n=0; n<opts.length; n++) {
			var type = opts[n].name.substr(0,3);
			var h = config.macros.option.types[type];
			if (h && h.create) {
				h.create(opts[n].colElements['option'],type,opts[n].name,opts[n].name,"no");
			}
		}
		
	},
	onCancel: function(e)
	{
		backstage.switchTab(null);
		return false;
	},
	
	wizardTitle: "Upload with options",
	step1Title: "These options are saved in cookies in your browser",
	step1Html: "<input type='hidden' name='markList'></input><br>",
	cancelButton: "Cancel",
	cancelButtonPrompt: "Cancel prompt",
	listViewTemplate: {
		columns: [
			{name: 'Description', field: 'description', title: "Description", type: 'WikiText'},
			{name: 'Option', field: 'option', title: "Option", type: 'String'},
			{name: 'Name', field: 'name', title: "Name", type: 'String'}
			],
		rowClasses: [
			{className: 'lowlight', field: 'lowlight'} 
			]}
};

//
// upload functions
//

if (!bidix.upload) bidix.upload = {};

if (!bidix.upload.messages) bidix.upload.messages = {
	//from saving
	invalidFileError: "The original file '%0' does not appear to be a valid TiddlyWiki",
	backupSaved: "Backup saved",
	backupFailed: "Failed to upload backup file",
	rssSaved: "RSS feed uploaded",
	rssFailed: "Failed to upload RSS feed file",
	emptySaved: "Empty template uploaded",
	emptyFailed: "Failed to upload empty template file",
	mainSaved: "Main TiddlyWiki file uploaded",
	mainFailed: "Failed to upload main TiddlyWiki file. Your changes have not been saved",
	//specific upload
	loadOriginalHttpPostError: "Can't get original file",
	aboutToSaveOnHttpPost: 'About to upload on %0 ...',
	storePhpNotFound: "The store script '%0' was not found."
};

bidix.upload.uploadChanges = function(onlyIfDirty,tiddlers,storeUrl,toFilename,uploadDir,backupDir,username,password)
{
	var callback = function(status,uploadParams,original,url,xhr) {
		if (!status) {
			displayMessage(bidix.upload.messages.loadOriginalHttpPostError);
			return;
		}
		if (bidix.debugMode) 
			alert(original.substr(0,500)+"\n...");
		// Locate the storeArea div's 
		var posDiv = locateStoreArea(original);
		if((posDiv[0] == -1) || (posDiv[1] == -1)) {
			alert(config.messages.invalidFileError.format([localPath]));
			return;
		}
		bidix.upload.uploadRss(uploadParams,original,posDiv);
	};
	
	if(onlyIfDirty && !store.isDirty())
		return;
	clearMessage();
	// save on localdisk ?
	if (document.location.toString().substr(0,4) == "file") {
		var path = document.location.toString();
		var localPath = getLocalPath(path);
		saveChanges();
	}
	// get original
	var uploadParams = new Array(storeUrl,toFilename,uploadDir,backupDir,username,password);
	var originalPath = document.location.toString();
	// If url is a directory : add index.html
	if (originalPath.charAt(originalPath.length-1) == "/")
		originalPath = originalPath + "index.html";
	var dest = config.macros.upload.destFile(storeUrl,toFilename,uploadDir);
	var log = new bidix.UploadLog();
	log.startUpload(storeUrl, dest, uploadDir,  backupDir);
	displayMessage(bidix.upload.messages.aboutToSaveOnHttpPost.format([dest]));
	if (bidix.debugMode) 
		alert("about to execute Http - GET on "+originalPath);
	var r = doHttp("GET",originalPath,null,null,username,password,callback,uploadParams,null);
	if (typeof r == "string")
		displayMessage(r);
	return r;
};

bidix.upload.uploadRss = function(uploadParams,original,posDiv) 
{
	var callback = function(status,params,responseText,url,xhr) {
		if(status) {
			var destfile = responseText.substring(responseText.indexOf("destfile:")+9,responseText.indexOf("\n", responseText.indexOf("destfile:")));
			displayMessage(bidix.upload.messages.rssSaved,bidix.dirname(url)+'/'+destfile);
			bidix.upload.uploadMain(params[0],params[1],params[2]);
		} else {
			displayMessage(bidix.upload.messages.rssFailed);			
		}
	};
	// do uploadRss
	if(config.options.chkGenerateAnRssFeed) {
		var rssPath = uploadParams[1].substr(0,uploadParams[1].lastIndexOf(".")) + ".xml";
		var rssUploadParams = new Array(uploadParams[0],rssPath,uploadParams[2],'',uploadParams[4],uploadParams[5]);
		var rssString = generateRss();
		// no UnicodeToUTF8 conversion needed when location is "file" !!!
		if (document.location.toString().substr(0,4) != "file")
			rssString = convertUnicodeToUTF8(rssString);	
		bidix.upload.httpUpload(rssUploadParams,rssString,callback,Array(uploadParams,original,posDiv));
	} else {
		bidix.upload.uploadMain(uploadParams,original,posDiv);
	}
};

bidix.upload.uploadMain = function(uploadParams,original,posDiv) 
{
	var callback = function(status,params,responseText,url,xhr) {
		var log = new bidix.UploadLog();
		if(status) {
			// if backupDir specified
			if ((params[3]) && (responseText.indexOf("backupfile:") > -1))  {
				var backupfile = responseText.substring(responseText.indexOf("backupfile:")+11,responseText.indexOf("\n", responseText.indexOf("backupfile:")));
				displayMessage(bidix.upload.messages.backupSaved,bidix.dirname(url)+'/'+backupfile);
			}
			var destfile = responseText.substring(responseText.indexOf("destfile:")+9,responseText.indexOf("\n", responseText.indexOf("destfile:")));
			displayMessage(bidix.upload.messages.mainSaved,bidix.dirname(url)+'/'+destfile);
			store.setDirty(false);
			log.endUpload("ok");
		} else {
			alert(bidix.upload.messages.mainFailed);
			displayMessage(bidix.upload.messages.mainFailed);
			log.endUpload("failed");			
		}
	};
	// do uploadMain
	var revised = bidix.upload.updateOriginal(original,posDiv);
	bidix.upload.httpUpload(uploadParams,revised,callback,uploadParams);
};

bidix.upload.httpUpload = function(uploadParams,data,callback,params)
{
	var localCallback = function(status,params,responseText,url,xhr) {
		url = (url.indexOf("nocache=") < 0 ? url : url.substring(0,url.indexOf("nocache=")-1));
		if (xhr.status == 404)
			alert(bidix.upload.messages.storePhpNotFound.format([url]));
		if ((bidix.debugMode) || (responseText.indexOf("Debug mode") >= 0 )) {
			alert(responseText);
			if (responseText.indexOf("Debug mode") >= 0 )
				responseText = responseText.substring(responseText.indexOf("\n\n")+2);
		} else if (responseText.charAt(0) != '0') 
			alert(responseText);
		if (responseText.charAt(0) != '0')
			status = null;
		callback(status,params,responseText,url,xhr);
	};
	// do httpUpload
	var boundary = "---------------------------"+"AaB03x";	
	var uploadFormName = "UploadPlugin";
	// compose headers data
	var sheader = "";
	sheader += "--" + boundary + "\r\nContent-disposition: form-data; name=\"";
	sheader += uploadFormName +"\"\r\n\r\n";
	sheader += "backupDir="+uploadParams[3] +
				";user=" + uploadParams[4] +
				";password=" + uploadParams[5] +
				";uploaddir=" + uploadParams[2];
	if (bidix.debugMode)
		sheader += ";debug=1";
	sheader += ";;\r\n"; 
	sheader += "\r\n" + "--" + boundary + "\r\n";
	sheader += "Content-disposition: form-data; name=\"userfile\"; filename=\""+uploadParams[1]+"\"\r\n";
	sheader += "Content-Type: text/html;charset=UTF-8" + "\r\n";
	sheader += "Content-Length: " + data.length + "\r\n\r\n";
	// compose trailer data
	var strailer = new String();
	strailer = "\r\n--" + boundary + "--\r\n";
	data = sheader + data + strailer;
	if (bidix.debugMode) alert("about to execute Http - POST on "+uploadParams[0]+"\n with \n"+data.substr(0,500)+ " ... ");
	var r = doHttp("POST",uploadParams[0],data,"multipart/form-data; ;charset=UTF-8; boundary="+boundary,uploadParams[4],uploadParams[5],localCallback,params,null);
	if (typeof r == "string")
		displayMessage(r);
	return r;
};

// same as Saving's updateOriginal but without convertUnicodeToUTF8 calls
bidix.upload.updateOriginal = function(original, posDiv)
{
	if (!posDiv)
		posDiv = locateStoreArea(original);
	if((posDiv[0] == -1) || (posDiv[1] == -1)) {
		alert(config.messages.invalidFileError.format([localPath]));
		return;
	}
	var revised = original.substr(0,posDiv[0] + startSaveArea.length) + "\n" +
				store.allTiddlersAsHtml() + "\n" +
				original.substr(posDiv[1]);
	var newSiteTitle = getPageTitle().htmlEncode();
	revised = revised.replaceChunk("<title"+">","</title"+">"," " + newSiteTitle + " ");
	revised = updateMarkupBlock(revised,"PRE-HEAD","MarkupPreHead");
	revised = updateMarkupBlock(revised,"POST-HEAD","MarkupPostHead");
	revised = updateMarkupBlock(revised,"PRE-BODY","MarkupPreBody");
	revised = updateMarkupBlock(revised,"POST-SCRIPT","MarkupPostBody");
	return revised;
};

//
// UploadLog
// 
// config.options.chkUploadLog :
//		false : no logging
//		true : logging
// config.options.txtUploadLogMaxLine :
//		-1 : no limit
//      0 :  no Log lines but UploadLog is still in place
//		n :  the last n lines are only kept
//		NaN : no limit (-1)

bidix.UploadLog = function() {
	if (!config.options.chkUploadLog) 
		return; // this.tiddler = null
	this.tiddler = store.getTiddler("UploadLog");
	if (!this.tiddler) {
		this.tiddler = new Tiddler();
		this.tiddler.title = "UploadLog";
		this.tiddler.text = "| !date | !user | !location | !storeUrl | !uploadDir | !toFilename | !backupdir | !origin |";
		this.tiddler.created = new Date();
		this.tiddler.modifier = config.options.txtUserName;
		this.tiddler.modified = new Date();
		store.addTiddler(this.tiddler);
	}
	return this;
};

bidix.UploadLog.prototype.addText = function(text) {
	if (!this.tiddler)
		return;
	// retrieve maxLine when we need it
	var maxLine = parseInt(config.options.txtUploadLogMaxLine,10);
	if (isNaN(maxLine))
		maxLine = -1;
	// add text
	if (maxLine != 0) 
		this.tiddler.text = this.tiddler.text + text;
	// Trunck to maxLine
	if (maxLine >= 0) {
		var textArray = this.tiddler.text.split('\n');
		if (textArray.length > maxLine + 1)
			textArray.splice(1,textArray.length-1-maxLine);
			this.tiddler.text = textArray.join('\n');		
	}
	// update tiddler fields
	this.tiddler.modifier = config.options.txtUserName;
	this.tiddler.modified = new Date();
	store.addTiddler(this.tiddler);
	// refresh and notifiy for immediate update
	story.refreshTiddler(this.tiddler.title);
	store.notify(this.tiddler.title, true);
};

bidix.UploadLog.prototype.startUpload = function(storeUrl, toFilename, uploadDir,  backupDir) {
	if (!this.tiddler)
		return;
	var now = new Date();
	var text = "\n| ";
	var filename = bidix.basename(document.location.toString());
	if (!filename) filename = '/';
	text += now.formatString("0DD/0MM/YYYY 0hh:0mm:0ss") +" | ";
	text += config.options.txtUserName + " | ";
	text += "[["+filename+"|"+location + "]] |";
	text += " [[" + bidix.basename(storeUrl) + "|" + storeUrl + "]] | ";
	text += uploadDir + " | ";
	text += "[[" + bidix.basename(toFilename) + " | " +toFilename + "]] | ";
	text += backupDir + " |";
	this.addText(text);
};

bidix.UploadLog.prototype.endUpload = function(status) {
	if (!this.tiddler)
		return;
	this.addText(" "+status+" |");
};

//
// Utilities
// 

bidix.checkPlugin = function(plugin, major, minor, revision) {
	var ext = version.extensions[plugin];
	if (!
		(ext  && 
			((ext.major > major) || 
			((ext.major == major) && (ext.minor > minor))  ||
			((ext.major == major) && (ext.minor == minor) && (ext.revision >= revision))))) {
			// write error in PluginManager
			if (pluginInfo)
				pluginInfo.log.push("Requires " + plugin + " " + major + "." + minor + "." + revision);
			eval(plugin); // generate an error : "Error: ReferenceError: xxxx is not defined"
	}
};

bidix.dirname = function(filePath) {
	if (!filePath) 
		return;
	var lastpos;
	if ((lastpos = filePath.lastIndexOf("/")) != -1) {
		return filePath.substring(0, lastpos);
	} else {
		return filePath.substring(0, filePath.lastIndexOf("\\"));
	}
};

bidix.basename = function(filePath) {
	if (!filePath) 
		return;
	var lastpos;
	if ((lastpos = filePath.lastIndexOf("#")) != -1) 
		filePath = filePath.substring(0, lastpos);
	if ((lastpos = filePath.lastIndexOf("/")) != -1) {
		return filePath.substring(lastpos + 1);
	} else
		return filePath.substring(filePath.lastIndexOf("\\")+1);
};

bidix.initOption = function(name,value) {
	if (!config.options[name])
		config.options[name] = value;
};

//
// Initializations
//

// require PasswordOptionPlugin 1.0.1 or better
bidix.checkPlugin("PasswordOptionPlugin", 1, 0, 1);

// styleSheet
setStylesheet('.txtUploadStoreUrl, .txtUploadBackupDir, .txtUploadDir {width: 22em;}',"uploadPluginStyles");

//optionsDesc
merge(config.optionsDesc,{
	txtUploadStoreUrl: "Url of the UploadService script (default: store.php)",
	txtUploadFilename: "Filename of the uploaded file (default: in index.html)",
	txtUploadDir: "Relative Directory where to store the file (default: . (downloadService directory))",
	txtUploadBackupDir: "Relative Directory where to backup the file. If empty no backup. (default: ''(empty))",
	txtUploadUserName: "Upload Username",
	pasUploadPassword: "Upload Password",
	chkUploadLog: "do Logging in UploadLog (default: true)",
	txtUploadLogMaxLine: "Maximum of lines in UploadLog (default: 10)"
});

// Options Initializations
bidix.initOption('txtUploadStoreUrl','');
bidix.initOption('txtUploadFilename','');
bidix.initOption('txtUploadDir','');
bidix.initOption('txtUploadBackupDir','');
bidix.initOption('txtUploadUserName','');
bidix.initOption('pasUploadPassword','');
bidix.initOption('chkUploadLog',true);
bidix.initOption('txtUploadLogMaxLine','10');


// Backstage
merge(config.tasks,{
	uploadOptions: {text: "upload", tooltip: "Change UploadOptions and Upload", content: '<<uploadOptions>>'}
});
config.backstageTasks.push("uploadOptions");


//}}}
//Navendu Jain   Department of Computer Sciences   University of Texas at Austin  Austin, TX, 78712   nav@cs.utexas.edu
Mike Dahlin       Department of Computer  Sciences  University of Texas at Austin  Austin, TX, 78712   dahlin@cs.utexas.edu
Renu Tewari      IBM Almaden Research Center    650 Harry Road      San Jose, CA, 95111     tewarir@us.ibm.com//

!!!Framework
>Use ''content-defined chunking (CDC)'' to extract document features that are resilient to modifications.
>>Use these features as set elements for ''generating Bloom filters''({{{   Sampling}}})
>>>''Compare the Bloom filters'' to detect near-duplicate documents above a certain similarity thresh-old (say 70%)

!!!!CDC Overview
CDC splits a document into ''variable-sized'' blocks whose bound-aries are determined by its ''Rabin fingerprint'' matching a pre-determined marker value [18]. The number of bits in the Rabin fingerprint that are used to match the marker deter-mine the expected chunk size.

!!!!Bloom Filter Overview
''Elements''
*a set of chunks(U)
*k hash functions: h1,h2,h3...hk
*array whose size is m
>Each hash function hi(u) for 1 ≤ i ≤ k maps to one bit in the array {1 . . .m}. Thus, when an element is added to the set,it sets k bits, each bit corresponding to a hash function, in the Bloom filter array to 1. If a bit was already set it stays 1.If all of the m bits is already set 1, the element is abandoned.
>>''Advantage:''
####The compactness of Bloom filters is very attractive for storage and transmission whenever we want to minimize the meta-data overheads.
####Bloom filters enable fast comparison as matching is a bitwise-AND operation.
####Since Bloom filters are a complete repre-sentation of a set rather than a deterministic sample (e.g.,shingling), they can determine inclusions effectively
>>''Flaws:''It may yield false positive
!!!初级
VIM(应该是某个版本以上)自带命令:
# '':tabnew [++opt选项] [+cmd] 文件''            建立对指定文件新的tab
# '':tabc''       关闭当前的tab
# '':tabo''       关闭所有其他的tab
# '':tabs''       查看所有打开的tab
# '':tabp''      前一个
# '':tabn''      后一个
''标准模式下'':
gt , gT 可以直接在tab之间切换。(''最方便'')
>更详细的可'':help table''查看
!!!进阶
修改''.vimrc''文件,增加''映射'':
[[灵活操作 Vim 中的 Tabs|http://hi.baidu.com/tpxc/blog/item/9ab09cb1013f4350092302c4.html]]
!!!高级
自己写脚本或插件:[[使用alt+数字键来切换tab (vim7+)|http://vim.group.javaeye.com/group/topic/7050]]
用现有插件:[[Bufpos -- 用 Alt+n 切换 Vim 的标签|http://www.linuxgem.org/2009/1/24/use-alt-n-switch-gvim-tab.6984.html]]
1.安装VNC Server
2.运行vncpasswd
>设置VNC连接的密码
3.默认的图形管理器twm会比较丑,更改~/.xstartup,将其中的twm改成''gnome-session''
4.运行''{{{vncserver -geometry 1024x768 -depth 16}}}''
>系统装了vncserver以后,每个用户都能创建自己的VNC session,session ID自动递增,这条命令的输出信息中有
>vncserver会监听某一端口,端口号为''{{{5900+sessionID}}}'',通过浏览器中访问ip地址+端口即可访问
5.一般来说这样就可以用VNC Viewer访问了

一些错误
*10065错误
>有可能是开启了防火墙,使用命令# service iptales stop 停止防火墙。或参照[[这里|http://blog.csdn.net/Tobeabetterman_He/archive/2006/11/14/1384180.aspx]]和[[这里|http://hi.baidu.com/itsuper/blog/item/474206c2a9c66a30e5dd3bd9.html]]设置iptable。
>>或者通过SSH Tunnel绕过去,参照[[这里|http://blog.csdn.net/Tobeabetterman_He/archive/2006/11/14/1384180.aspx]],在putty中''Connection-SSH-tunnels''设置转发:源端口为{''{{{5900+sessionID}}}''},目的地为''localhost:{{{{5900+sessionID}}}}''。它的解释见[[这里|http://www.cyberciti.biz/tips/tunneling-vnc-connections-over-ssh-howto.html]]
>或者是配置文件开启了localhost,使得只允许本地访问,见[[这里|http://hi.baidu.com/higkoo/blog/item/d04b901f990774e5e0fe0b80.html]]
*10061错误
>没有启动vnc server

上面的方法有个缺点,即系统重启VNC Server的守护程序就不运行了,需要手动启动,故可在系统配置文件中设置开机启动
参考:[[Linux 远程桌面 VNC server|http://www.hduo.net/archives/linux-remote-desktop-vncserver.html]]和[[Configuring the VNC server/viewer in Linux.|http://bobpeers.com/linux/vnc]]

*参考
**[[CentOS官方文档|http://wiki.centos.org/HowTos/VNC-Server]]
**[[Ubuntu下的配置|http://imthi.com/blog/linux/ubuntu-904-remote-desktop-using-vncserver-without-monitor.php]]
<html><font size=4 color=purple><b>About this: A collect of pages about Web Application.</b></font></html>
*[[url转义字符]]
*[[去除点击链接时出现的虚线框]]
*[[如何上twitter]]
<html><font size=4 color=purple><b>This page is a collect of my pages about this wiki</b></font></html>
*[[关于Wiki的组织]]
*[[关于Wiki的编辑]]
*[[上传TiddlyWiki|http://faq.tiddlyspot.com/]]
/***
|''Name:''|WikiBar|
|''Version:''|2.0.0 beta3|
|''Source:''|[[AiddlyWiki|http://aiddlywiki.sourceforge.net]]|
|''Author:''|[[Arphen Lin|mailto:arphenlin@gmail.com]]|
|''Type:''|toolbar macro command extension|
|''Required:''|TiddlyWiki 2.0.0 beta6|
!Description
WikiBar is a toolbar that gives access to most of TiddlyWiki's formatting features with a few clicks. It's a handy tool for people who are not familiar with TiddlyWiki syntax.
Besides, with WikiBar-addons, users can extend the power of WikiBar.
!Support browser
*Firefox 1.5
!Revision history
*v2.0.0 beta3 (2005/12/30)
** remove macros (replaced by TWMacro addon)
** add wikibar command in toolbar automatically
** rename DOIT to HANDLER
** rename TIP to TOOLTIP
*v2.0.0 beta2 (2005/12/21)
** re-design Wikibar addon framework
*v2.0.0 beta1 (2005/12/14)
** Note:
*** WikiBarPlugin is renamed to WikiBar
** New Features:
*** support TiddlyWiki 2.0.0 template mechanism
*** new wikibar data structure
*** new wikibar-addon framework for developers
**** support dynamic popup menu generator
*** support most new macros added in TiddlyWiki 2.0.0
*** multi-level popup menu
*** fix wikibar tab stop
*** remove paletteSelector
** Known Bugs:
*** popup-menu and color-picker can't be closed correctly
*** some macros can't be displayed correctly in previewer
*** text in previewer will be displayed italic
*v1.2.0 (2005/11/21)
**New Features:
***User defined color palettes supported
####Get color palettes from [[ColorZilla Palettes|http://www.iosart.com/firefox/colorzilla/palettes.html]].
####Save the palette file(*.gpl) as a new tiddler and tag it with 'ColorPalettes', then you can use it in WikiBar.
***WikiBar style sheet supported
***Click on document to close current colorPicker, paletteSelector or aboutWikibar
*v1.1.1 (2005/11/03)
**Bugs fixed:
***'Not enough parameters!' message is displayed when the parameter includes '%+number', ex: 'hello%20world!'
*v1.1.0 (2005/11/01)
**Bugs fixed:
***WikiBar overruns (reported by by GeoffS <gslocock@yahoo.co.uk>)
**New features:
***Insert a color code at the cursor. (Thanks to RunningUtes <RunningUtes@gmail.com>)
***Enable gradient macro. (Thanks to RunningUtes <RunningUtes@gmail.com>)
***Insert tiddler comment tags {{{/% ... %/}}}. (new feature supported by TiddlyWiki 1.2.37)
***Insert DateFormatString for {{{<<today>>}}} macro. (new feature supported by TiddlyWiki 1.2.37)
**Enhanced:
***Allow optional parameters in syntax.
**Bugs:
***'Not enough parameters!' message is displayed when the parameter includes '%+number', ex: 'hello%20world!'
*v1.0.0 (2005/10/30)
**Initial release
!Code
***/
//{{{
config.macros.wikibar = {major: 2, minor: 0, revision: 0, beta: 3, date: new Date(2005,12,30)};
config.macros.wikibar.handler = function(place,macroName,params,wikifier,paramString,tiddler){
  if(!(tiddler instanceof Tiddler))  {return;}
	story.setDirty(tiddler.title,true);
  place.id = 'wikibar'+tiddler.title;
  place.className = 'toolbar wikibar';
};
function wikibar_install(){
  config.commands.wikibar = {
  	text: 'wikibar',
  	tooltip: 'wikibar on/off',
  	handler: function(e,src,title) {
      if(!e){ e = window.event; }
      var theButton = resolveTarget(e);
      theButton.id = 'wikibarButton'+title;
      wikibarPopup.remove();
      wikibar_installAddons(theButton, title);
      wikibar_createWikibar(title);
      return(false);
    }
  };
  config.shadowTiddlers['EditTemplate'] = wikibar_addWikibarCommand(config.shadowTiddlers['EditTemplate']);
  var tiddler = store.getTiddler('EditTemplate');
  if(tiddler){
    tiddler.text = wikibar_addWikibarCommand(tiddler.text);
  }
}
function wikibar_installAddons(theButton, title){
 	var tiddlers = store.getTaggedTiddlers('wikibarAddons');
	if(!tiddlers)	  { return; }
	theButton.addons=[];
  for(var i=0; i<tiddlers.length; i++){
    try{
      eval(tiddlers[i].text);
      try{
        wikibar_addonInstall(title);
        wikibar_addonInstall = null;
        theButton.addons.push({ok:true, name:tiddlers[i].title});
      }catch(ex){
        theButton.addons.push({ok:false, name:tiddlers[i].title, error:ex});
      }
    }catch(ex){
      theButton.addons.push({ok:false, name:tiddlers[i].title, error:ex});
    }
  }
}
function wikibar_addWikibarCommand(tiddlerText){
  var div = document.createElement('div');
  div.style.display = 'none';
  div.innerHTML = tiddlerText;
  for(var i=0; i<div.childNodes.length; i++){
    var o=div.childNodes[i];
    if(o.tagName==='DIV'){
      if(o.className=='toolbar'){
        var macroText = o.getAttribute('macro').trim();
        if(macroText.search('wikibar')<=0){
          macroText += ' wikibar';
          o.setAttribute('macro', macroText);
        }
        break;
      }
    }
  }
  return div.innerHTML.replace(/\"/g, "\'");
}
function wikibar_processSyntaxParams(theSyntax, params){
  try{
    var pcr = 'AplWikibarPcr';
    var rx=null;
    var allParams=null;
    if(params){
      if(typeof(params)=='object'){
        for(var i=0; i<params.length; i++){
          if(params[i]){
            params[i] = params[i].replace(new RegExp('%','g'), pcr).trim();
            rx = '(\\[%'+(i+1)+'\\])' + '|' + '(%'+(i+1)+')';
            theSyntax = theSyntax.replace(new RegExp(rx,'g'), params[i] );
          }
        }
        allParams = params.join(' ').trim();
      }else{
        allParams = params.replace(new RegExp('%','g'), pcr).trim();
        rx = /(\[%1{1}\])|(%1{1})/g;
        theSyntax = theSyntax.replace(rx, allParams);
      }
    }
    if(allParams){
      theSyntax = theSyntax.replace(new RegExp('%N{1}','g'), allParams);
    }
    rx=/\[%(([1-9]{1,}[0-9]{0,})|(N{1}))\]/g;
    theSyntax = theSyntax.replace(rx, '');
    rx=/%(([1-9]{1,}[0-9]{0,})|(N{1}))/g;
    if( theSyntax.match(rx) ){
      throw 'Not enough parameters! ' + theSyntax;
    }
    theSyntax=theSyntax.replace(new RegExp(pcr,'g'), '%');
    return theSyntax;
  } catch(ex){
    return null;
  }
}
function wikibar_resolveEditItem(tiddlerWrapper, itemName){
  if(tiddlerWrapper.hasChildNodes()){
    var c=tiddlerWrapper.childNodes;
    for(var i=0; i<c.length; i++){
      var txt=wikibar_resolveEditItem(c[i], itemName);
      if(!txt){
        continue;
      }else{
        return txt;
      }
    }
  }
  return ((tiddlerWrapper.getAttribute && tiddlerWrapper.getAttribute('edit')==itemName)? tiddlerWrapper : null);
}
function wikibar_resolveEditItemValue(tiddlerWrapper, itemName){
  var o = wikibar_resolveEditItem(tiddlerWrapper, itemName);
  return (o? o.value.replace(/\r/mg,'') : null);
}
function wikibar_resolveTiddlerEditorWrapper(obj){
  if(obj.id=='tiddlerDisplay'){return null;}
  if((obj.getAttribute && obj.getAttribute('macro')=='edit text')){return obj;}
  return wikibar_resolveTiddlerEditorWrapper(obj.parentNode);
}
function wikibar_resolveTiddlerEditor(obj){
  if(obj.hasChildNodes()){
    var c = obj.childNodes;
    for(var i=0; i<c.length; i++){
      var o=wikibar_resolveTiddlerEditor(c[i]);
      if(o){ return o;}
    }
  }
  return ((obj.getAttribute && obj.getAttribute('edit')=='text')? obj : null);
}
function wikibar_resolveTargetButton(obj){
  if(obj.id && obj.id.substring(0,7)=='wikibar'){ return null; }
  if(obj.tiddlerTitle){
    return obj;
  }else{
    return wikibar_resolveTargetButton(obj.parentNode);
  }
}
function wikibar_isValidMenuItem(tool){
  if(!tool){  return false; }
  if(tool.TYPE=='MENU' || tool.TYPE=='MAIN_MENU'){
    for(var key in tool){
      if(key.substring(0,8)=='DYNAITEM'){ return true; }
      if(wikibar_isValidMenuItem(tool[key])){ return true; }
    }
    return false;
  }else{
    return (tool.HANDLER? true : false);
  }
}
function wikibar_editFormat(param){
  var editor = param.button.editor;
  var params = param.params;
  clearMessage();
  if(!editor){ return; }
  var repText = wikibar_processSyntaxParams(this.syntax, params);
  if(repText===null){ return; }
	var st = editor.scrollTop;
	var ss = editor.selectionStart;
	var se = editor.selectionEnd;
	var frontText= '';
	var endText  = '';
	var fullText = editor.value;
	if(se>ss && ss>=0){
	  frontText  = fullText.substring(0, ss);
	  endText    = fullText.substring(se, fullText.length);
	}
	else if(ss===0 && (se===0 || se == fullText.length) ){
    endText    = fullText;
	}
	else if(se==ss && ss>0){
    frontText  = fullText.substring(0, ss);
    endText    = fullText.substring(se, fullText.length);
	}
	if(repText.indexOf('user_text')>=0 && this.hint){
		repText = repText.replace('user_text', this.hint);
	}
	editor.value = frontText + repText + endText;
	editor.selectionStart = ss;
	editor.selectionEnd   = ss + repText.length;
	editor.scrollTop      = st;
	editor.focus();
}
function wikibar_editFormatByWord(param){
  var editor = param.button.editor;
  var params = param.params;
  clearMessage();
  if(!editor){return;}
  var repText = wikibar_processSyntaxParams(this.syntax, params);
  if(repText===null){ return; }
	var st = editor.scrollTop;
	var ss = editor.selectionStart;
	var se = editor.selectionEnd;
	var frontText= '';
	var selText  = '';
	var endText  = '';
	var fullText = editor.value;
	if(se>ss && ss>=0){
	  frontText  = fullText.substring(0, ss);
	  selText	   = fullText.substring(ss,se);
	  endText    = fullText.substring(se, fullText.length);
	}
	else if(ss===0 && (se===0 || se == fullText.length) ){
    endText    = fullText;
	}
	else if(se==ss && ss>0){
    frontText  = fullText.substring(0, ss);
    endText    = fullText.substring(se, fullText.length);
	  if(!( fullText.charAt(ss-1).match(/\W/gi) || fullText.charAt(ss).match(/\W/gi) )){
      var m = frontText.match(/\W/gi);
      if(m){
        ss = frontText.lastIndexOf(m[m.length-1])+1;
      }
      else{
        ss = 0;
      }
      m = endText.match(/\W/gi);
      if(m){
        se += endText.indexOf(m[0]);
      }
      else{
        se = fullText.length;
      }
      frontText = fullText.substring(0, ss);
  	  endText   = fullText.substring(se, fullText.length);
  	  selText   = fullText.substring(ss,se);
	  }
	}
	if(selText.length>0){
		repText = repText.replace('user_text', selText);
	}
	if(repText.indexOf('user_text')>=0 && this.hint){
		repText = repText.replace('user_text', this.hint);
	}
	editor.value = frontText + repText + endText;
	editor.selectionStart = ss;
	editor.selectionEnd   = ss + repText.length;
	editor.scrollTop      = st;
	editor.focus();
}
function wikibar_editFormatByCursor(param){
  var editor = param.button.editor;
  var params = param.params;
  clearMessage();
  if(!editor){ return; }
  var repText = wikibar_processSyntaxParams(this.syntax, params);
  if(repText===null){ return; }
	var st = editor.scrollTop;
	var ss = editor.selectionStart;
	var se = editor.selectionEnd;
	var frontText= '';
	var endText  = '';
	var fullText = editor.value;
	if(se>ss && ss>=0){
	  frontText  = fullText.substring(0, ss);
	  endText    = fullText.substring(se, fullText.length);
	}
	else if(ss===0 && (se===0 || se == fullText.length) ){
    endText    = fullText;
	}
	else if(se==ss && ss>0){
    frontText  = fullText.substring(0, ss);
    endText    = fullText.substring(se, fullText.length);
	}
	if(repText.indexOf('user_text')>=0 && this.hint){
		repText = repText.replace('user_text', this.hint);
	}
	editor.value = frontText + repText + endText;
	editor.selectionStart = ss;
	editor.selectionEnd   = ss + repText.length;
	editor.scrollTop      = st;
	editor.focus();
}
function wikibar_editFormatByLine(param){
  var editor = param.button.editor;
  var params = param.params;
  clearMessage();
  if(!editor){ return; }
  var repText = wikibar_processSyntaxParams(this.syntax, params);
  if(repText===null){ return; }
	var st = editor.scrollTop;
	var ss = editor.selectionStart;
	var se = editor.selectionEnd;
	var frontText= '';
	var selText  = '';
	var endText  = '';
	var fullText = editor.value;
	if(se>ss && ss>=0){
		if(this.byBlock){
	    frontText  = fullText.substring(0, ss);
	    selText		 = fullText.substring(ss,se);
	    endText    = fullText.substring(se, fullText.length);
		}
		else{
	  	se = ss;
		}
	}
  if(ss===0 && (se===0 || se == fullText.length) ){
    var m=fullText.match(/(\n|\r)/g);
    if(m){
      se = fullText.indexOf(m[0]);
    }else{
      se = fullText.length;
    }
    selText    = fullText.substring(0, se);
    endText    = fullText.substring(se, fullText.length);
	}
	else if(se==ss && ss>0){
    frontText  = fullText.substring(0, ss);
    endText    = fullText.substring(se, fullText.length);
    m = frontText.match(/(\n|\r)/g);
    if(m){
      ss = frontText.lastIndexOf(m[m.length-1])+1;
    }
    else{
      ss = 0;
    }
    m = endText.match(/(\n|\r)/g);
    if(m){
      se += endText.indexOf(m[0]);
    }
    else{
      se = fullText.length;
    }
    frontText = fullText.substring(0, ss);
	  selText   = fullText.substring(ss,se);
	  endText   = fullText.substring(se, fullText.length);
	}
	if(selText.length>0){
		repText = repText.replace('user_text', selText);
	}
	if(repText.indexOf('user_text')>=0 && this.hint){
		repText = repText.replace('user_text', this.hint);
	}
	if(this.byBlock){
    if( (frontText.charAt(frontText.length-1)!='\n') && ss>0 ){
    	repText = '\n' + repText;
    }
    if( (endText.charAt(0)!='\n') || se==fullText.length){
    	repText += '\n';
    }
	}
	editor.value = frontText + repText + endText;
	editor.selectionStart = ss;
	editor.selectionEnd   = ss + repText.length;
	editor.scrollTop      = st;
	editor.focus();
}
function wikibar_editFormatByTableCell(param){
  var editor = param.button.editor;
  var params = param.params;
  clearMessage();
  if(!editor){ return; }
  var repText = wikibar_processSyntaxParams(this.syntax, params);
  if(repText===null){ return; }
	var st = editor.scrollTop;
	var ss = editor.selectionStart;
	var se = editor.selectionEnd;
	var frontText= '';
	var selText  = '';
	var endText  = '';
	var fullText = editor.value;
	if(ss===0 || ss==fullText.length){
		throw 'not valid cell!';
	}
	se=ss;
  frontText  = fullText.substring(0, ss);
  endText    = fullText.substring(se, fullText.length);
  i=frontText.lastIndexOf('\n');
  j=frontText.lastIndexOf('|');
  if(i>j || j<0){
  	throw 'not valid cell!';
  }
	ss = j+1;
  i=endText.indexOf('\n');
  j=endText.indexOf('|');
  if(i<j || j<0){
  	throw 'not valid cell!';
  }
  se += j;
  frontText = fullText.substring(0, ss-1);
  selText   = fullText.substring(ss,se);
  endText   = fullText.substring(se+1, fullText.length);
	if(this.key.substring(0,5)=='align'){
		selText = selText.trim();
		if(	selText=='>' || selText=='~' ||	selText.substring(0,8)=='bgcolor(')	{return; }
	}
	if(selText.length>0){
		repText = repText.replace('user_text', selText);
	}
	if(repText.indexOf('user_text')>=0 && this.hint){
		repText = repText.replace('user_text', this.hint);
	}
	editor.value = frontText + repText + endText;
	editor.selectionStart = ss;
	editor.selectionEnd   = ss + repText.length - 2;
	editor.scrollTop      = st;
	editor.focus();
}
function wikibar_editSelectAll(param){
  var editor = param.button.editor;
	editor.selectionStart = 0;
	editor.selectionEnd   = editor.value.length;
	editor.scrollTop      = 0;
	editor.focus();
}
function wikibar_doPreview(param){
  var theButton = param.button;
  var editor = param.button.editor;
  var wikibar = theButton.parentNode;
  if(!wikibar)  { return; }
  title = theButton.tiddlerTitle;
  var editorWrapper = wikibar_resolveTiddlerEditorWrapper(editor);
  var tiddlerWrapper = editorWrapper.parentNode;
  var previewer = document.getElementById('previewer'+title);
  if(previewer){
    previewer.parentNode.removeChild(previewer);
    editorWrapper.style.display = 'block';
    visible=true;
  }else{
    previewer = document.createElement('div');
    previewer.id = 'previewer'+title;
    previewer.className = 'viewer previewer';
    previewer.style.height = (editor.offsetHeight) + 'px';
    wikify(editor.value, previewer);
    tiddlerWrapper.insertBefore(previewer, editorWrapper);
    editorWrapper.style.display = 'none';
    visible=false;
  }
  var pv=null;
  for(var i=0; i<wikibar.childNodes.length; i++){
    try{
      var btn = wikibar.childNodes[i];
      if(btn.toolItem.key == 'preview'){ pv=btn; }
      if(btn.toolItem.key != 'preview'){
        btn.style.display = visible ? '': 'none';
      }
    }catch(ex){}
  }
  if(!pv) { return; }
  if(visible){
    pv.innerHTML = '<font face=\"verdana\">&infin;</font>';
    pv.title = 'preview current tiddler';
  }
  else{
    pv.innerHTML = '<font face=\"verdana\">&larr;</font>';
    pv.title = 'back to editor';
  }
}
function wikibar_doListAddons(param){
  clearMessage();
  var title = param.button.tiddlerTitle;
  var wikibarButton = document.getElementById('wikibarButton'+title);
  var ok=0, fail=0;
  for(var i=0; i<wikibarButton.addons.length; i++){
    var addon=wikibarButton.addons[i];
    if(addon.ok){
      displayMessage('[ o ] '+addon.name);
      ok++;
    }
    else{
      displayMessage('[ x ] '+addon.name + ': ' + addon.error);
      fail++;
    }
  }
  displayMessage('---------------------------------');
  displayMessage(ok + ' ok ; ' + fail + ' failed');
}
function wikibar_getColorCode(param){
  var cbOnPickColor = function(colorCode, param){
    param.params = colorCode;
    param.button.toolItem.doMore(param);
  };
  wikibarColorTool.openColorPicker(param.button, cbOnPickColor, param);
}
function wikibar_getLinkUrl(param){
  var url= prompt('Please enter the link target', (this.param? this.param : ''));
  if (url && url.trim().length>0){
    param.params = url;
    this.doMore(param);
  }
}
function wikibar_getTableRowCol(param){
  var rc= prompt('Please enter (rows x cols) of the table', '2 x 3');
  if (!rc || (rc.trim()).length<=0){ return; }
  var arr = rc.toUpperCase().split('X');
  if(arr.length != 2)   { return; }
  for(var i=0; i<arr.length; i++){
    if(isNaN(arr[i].trim()))  { return; }
  }
  var rows = parseInt(arr[0].trim(), 10);
  var cols = parseInt(arr[1].trim(), 10);
  var txtTable='';
  for(var r=0; r<rows; r++){
    for(var c=0; c<=cols; c++){
      if(c===0){
        txtTable += '|';
      }else{
        txtTable += ' |';
      }
    }
    txtTable += '\n';
  }
  if(txtTable.trim().length>0){
    param.params = txtTable.trim();
    this.doMore(param);
  }
}
function wikibar_getMacroParam(param){
  var p = prompt('Please enter the parameters of macro \"' + this.key + '\":' +
                 '\nSyntax: ' + this.syntax +
                 '\n\nNote: '+
                 '\n%1,%2,... - parameter needed'+
                 '\n[%1] - optional parameter'+
                 '\n%N   - more than one parameter(1~n)'+
                 '\n[%N] - any number of parameters(0~n)'+
                 '\n\nPS:'+
                 '\n1. Parameters should be seperated with space character'+
                 '\n2. Use \" to wrap the parameter that includes space character, ex: \"hello world\"'+
                 '\n3. Input the word(null) for the optional parameter ignored',
                 (this.param? this.param : '') );
  if(!p)  { return; }
  p=p.readMacroParams();
  for(var i=0; i<p.length; i++){
    var s=p[i].trim();
    if(s.indexOf(' ')>0){ p[i]="'"+s+"'"; }
    if(s.toLowerCase()=='null'){ p[i]=null; }
  }
  param.params = p;
  this.doMore(param);
}
function wikibar_getMorePalette(unused){
  clearMessage();
  displayMessage('Get more color palettes(*.gpl) from ColorZilla Palettes site', 'http:\/\/www.iosart.com/firefox/colorzilla/palettes.html');
  displayMessage('Save it as a new tiddler with \"ColorPalettes\" tag');
}
function wikibar_createWikibar(title){
  var theWikibar = document.getElementById('wikibar' + title);
  if(theWikibar){
    if(theWikibar.hasChildNodes()){
      theWikibar.style.display = (theWikibar.style.display=='block'? 'none':'block');
      return;
    }
  }
  var tiddlerWrapper = document.getElementById('tiddler'+title);
  var theTextarea = wikibar_resolveTiddlerEditor(tiddlerWrapper);
  if(!theTextarea){
    clearMessage();
    displayMessage('WikiBar only works in tiddler edit mode now');
    return;
  }else{
    if(!theTextarea.id){ theTextarea.id = 'editor'+title; }
    if(!theTextarea.parentNode.id){ theTextarea.parentNode.id='editorWrapper'+title;  }
  }
  if(theWikibar){
    theWikibar = document.getElementById('wikibar'+title);
  }else{
    var editorWrapper = wikibar_resolveTiddlerEditorWrapper(theTextarea);
    theWikibar = createTiddlyElement(tiddlerWrapper, 'div', 'wikibar'+title, 'toolbar');
    addClass(theWikibar, 'wikibar');
    var previewer = document.getElementById('previewer'+title);
    if(previewer){
      tiddlerWrapper.insertBefore(theWikibar, previewer);
    }else{
      tiddlerWrapper.insertBefore(theWikibar, editorWrapper);
    }
  }
  wikibar_createMenu(theWikibar,wikibarStore,title,theTextarea);
  if(config.options['chkWikibarSetEditorHeight'] && config.options['txtWikibarEditorRows']){
    theTextarea.rows = config.options['txtWikibarEditorRows'];
  }
  setStylesheet(
    '.wikibar{text-align:left;visibility:visible;margin:2px;padding:1px;}.previewer{overflow:auto;display:block;border:1px solid;}#colorPicker{position:absolute;display:none;z-index:10;margin:0px;padding:0px;}#colorPicker table{margin:0px;padding:0px;border:2px solid #000;border-spacing:0px;border-collapse:collapse;}#colorPicker td{margin:0px;padding:0px;border:1px solid;font-size:11px;text-align:center;cursor:auto;}#colorPicker .header{background-color:#fff;}#colorPicker .button{background-color:#fff;cursor:pointer;cursor:hand;}#colorPicker .button:hover{padding-top:3px;padding-bottom:3px;color:#fff;background-color:#136;}#colorPicker .cell{padding:4px;font-size:7px;cursor:crosshair;}#colorPicker .cell:hover{padding:10px;}.wikibarPopup{position:absolute;z-index:10;border:1px solid #014;color:#014;background-color:#cef;}.wikibarPopup table{margin:0;padding:0;border:0;border-spacing:0;border-collapse:collapse;}.wikibarPopup .button:hover{color:#eee;background-color:#014;}.wikibarPopup .disabled{color:#888;}.wikibarPopup .disabled:hover{color:#888;background-color:#cef;}.wikibarPopup tr .seperator hr{margin:0;padding:0;background-color:#cef;width:100%;border:0;border-top:1px dashed #014;}.wikibarPopup tr .icon{font-family:verdana;font-weight:bolder;}.wikibarPopup tr .marker{font-family:verdana;font-weight:bolder;}.wikibarPopup td{font-size:0.9em;padding:2px;}.wikibarPopup input{border:0;border-bottom:1px solid #014;margin:0;padding:0;font-family:arial;font-size:100%;background-color:#fff;}',
  	'WikiBarStyleSheet');
}
function wikibar_createMenu(place,toolset,title,editor){
  if(!wikibar_isValidMenuItem(toolset)){return;}
  if(!(toolset.TYPE=='MAIN_MENU' || toolset.TYPE=='MENU')){ return; }
    for(var key in toolset){
      if(key.substring(0,9)=='SEPERATOR'){
        wikibar_createMenuSeperator(place);
        continue;
      }
      if(key.substring(0,8)=='DYNAITEM'){
        var dynaTools = toolset[key](title,editor);
        if(dynaTools.TYPE && dynaTools.TYPE=='MENU'){
          wikibar_createMenuItem(place,dynaTools,null,editor,title);
        }else{
          dynaTools.TYPE = 'MENU';
          wikibar_createMenu(place, dynaTools, title, editor);
        }
        continue;
      }
      if((toolset[key].TYPE!='MENU' && toolset[key].TYPE!='MAIN_MENU') && !toolset[key].HANDLER){continue;}
      wikibar_createMenuItem(place,toolset,key,editor,title);
    }
}
function wikibar_createMenuItem(place,toolset,key,editor,title){
  if(!key){
    var tool = toolset;
  }else{
    tool = toolset[key];
    tool.key = key;
  }
  if(!wikibar_isValidMenuItem(tool)){return;}
  var toolIsOnMainMenu = (toolset.TYPE=='MAIN_MENU');
  var toolIsMenu = (tool.TYPE=='MENU');
  var theButton;
  if(toolIsOnMainMenu){
    theButton = createTiddlyButton(
                  place,
                  '',
                  (tool.TOOLTIP? tool.TOOLTIP : ''),
                  (toolIsMenu? wikibar_onClickMenuItem : wikibar_onClickItem),
                  'button');
    theButton.innerHTML = (tool.CAPTION? tool.CAPTION : key);
    theButton.isOnMainMenu = true;
    addClass(theButton, (toolIsMenu? 'menu' : 'item'));
  	place.appendChild( document.createTextNode('\n') );
    if(!toolIsMenu){
      if(config.options['chkWikibarPopmenuOnMouseOver']){
        theButton.onmouseover = function(e){ wikibarPopup.remove(); };
      }
    }
  }else{
    theButton=createTiddlyElement(place, 'tr',key,'button');
    theButton.title = (tool.TOOLTIP? tool.TOOLTIP : '');
    theButton.onclick = (toolIsMenu? wikibar_onClickMenuItem : wikibar_onClickItem);
    var tdL = createTiddlyElement(theButton, 'td','','marker');
    var td = createTiddlyElement(theButton, 'td');
    var tdR = createTiddlyElement(theButton, 'td','','marker');
    td.innerHTML = (tool.CAPTION? tool.CAPTION : key);
    if(toolIsMenu){
      tdR.innerHTML='&nbsp;&nbsp;&rsaquo;';
    }
    if(tool.SELECTED){
      tdL.innerHTML = '&radic; ';
      addClass(theButton, 'selected');
    }
    if(tool.DISABLED){
      addClass(theButton, 'disabled');
    }
  }
  theButton.tiddlerTitle = title;
  theButton.toolItem = tool;
  theButton.editor = editor;
  theButton.tabIndex = 999;
  if(toolIsMenu){
    if(config.options['chkWikibarPopmenuOnMouseOver']){
      theButton.onmouseover = wikibar_onClickMenuItem;
    }
  }
}
function wikibar_createMenuSeperator(place){
  if(place.id.substring(0,7)=='wikibar')  { return; }
  var onclickSeperator=function(e){
  	if(!e){ e = window.event; }
  	e.cancelBubble = true;
    if (e.stopPropagation){ e.stopPropagation();  }
  	return(false);
  };
  var theButton=createTiddlyElement(place,'tr','','seperator');
  var td = createTiddlyElement(theButton, 'td','','seperator');
  td.colSpan=3;
  theButton.onclick=onclickSeperator;
	td.innerHTML = '<hr>';
}
function wikibar_genWikibarAbout(){
  var toolset={};
  toolset.version = {
    CAPTION: '<center>WikiBar ' +
              config.macros.wikibar.major + '.' +
              config.macros.wikibar.minor + '.' +
              config.macros.wikibar.revision +
              (config.macros.wikibar.beta? ' beta '+config.macros.wikibar.beta : '') +
              '</center>',
    HANDLER: function(){}
  };
  toolset.SEPERATOR = {};
  toolset.author = {
    CAPTION: '<center>Arphen Lin<br>arphenlin@gmail.com</center>',
    TOOLTIP: 'send mail to the author',
    HANDLER: function(){ window.open('mailto:arphenlin@gmail.com'); }
  };
  toolset.website = {
    CAPTION: '<center>aiddlywiki.sourceforge.net</center>',
    TOOLTIP: 'go to the web site of WikiBar',
    HANDLER: function(){ window.open('http:\/\/aiddlywiki.sourceforge.net/'); }
  };
  return toolset;
}
function wikibar_genWikibarOptions(title, editor){
  var toolset={};
  toolset.popOnMouseOver = {
    CAPTION:'popup menu on mouse over',
    SELECTED: config.options['chkWikibarPopmenuOnMouseOver'],
    HANDLER: function(param){
      config.options['chkWikibarPopmenuOnMouseOver'] = !config.options['chkWikibarPopmenuOnMouseOver'];
      saveOptionCookie('chkWikibarPopmenuOnMouseOver');
      var title = param.button.tiddlerTitle;
      var wikibar = document.getElementById('wikibar'+title);
      if(wikibar){ wikibar.parentNode.removeChild(wikibar); }
      wikibar_createWikibar(title);
    }
  };
  toolset.setEditorSize = {
    CAPTION:'set editor height: <input id=\"txtWikibarEditorRows\" type=text size=1 MAXLENGTH=3 value=\"' +
            (config.options['txtWikibarEditorRows']? config.options['txtWikibarEditorRows']:editor.rows) + '\"> ok',
    HANDLER: function(param){
      var input = document.getElementById('txtWikibarEditorRows');
      if(input){
        var rows = parseInt(input.value, 10);
        if(!isNaN(rows)){
          var editor = param.button.editor;
          editor.rows = rows;
        }else{
          rows=config.maxEditRows;
        }
        config.options['txtWikibarEditorRows'] = rows;
        saveOptionCookie('txtWikibarEditorRows');
        config.maxEditRows = rows;
      }
    }
  };
  toolset.setEditorSizeOnLoadingWikibar = {
    CAPTION:'set editor height on loading wikibar',
    SELECTED: config.options['chkWikibarSetEditorHeight'],
    HANDLER: function(param){
      config.options['chkWikibarSetEditorHeight'] = !config.options['chkWikibarSetEditorHeight'];
      saveOptionCookie('chkWikibarSetEditorHeight');
      if(config.options['chkWikibarSetEditorHeight']){
        var rows = config.options['txtWikibarEditorRows'];
        if(!isNaN(rows)){ rows = 15; }
        var editor = param.button.editor;
        editor.rows = rows;
        config.options['txtWikibarEditorRows'] = rows;
        saveOptionCookie('txtWikibarEditorRows');
      }
    }
  };
  toolset.SEPERATOR = {};
  toolset.update = {
    CAPTION: 'check for updates',
    DISABLED: true,
    HANDLER: function(){}
  };
  return toolset;
}
function wikibar_genPaletteSelector(){
  try{
  	var cpTiddlers = store.getTaggedTiddlers('ColorPalettes');
  	if(!cpTiddlers) { return; }
  	var palettes=[];
  	palettes.push(wikibarColorTool.defaultPaletteName);
  	for(var i=0; i<cpTiddlers.length; i++){
  		palettes.push(cpTiddlers[i].title.trim());
  	}
    var toolset={};
    for(i=0; i<palettes.length; i++){
      toolset[palettes[i]] = {
        TOOLTIP: palettes[i],
        SELECTED: (palettes[i]==wikibarColorTool.paletteName),
        HANDLER: wikibar_doSelectPalette
      };
    }
    return toolset;
  }catch(ex){ return null; }
}
function wikibar_onClickItem(e){
	if(!e){ e = window.event; }
	var theTarget = resolveTarget(e);
	if(theTarget.tagName=='INPUT'){
    e.cancelBubble = true;
    if (e.stopPropagation){ e.stopPropagation(); }
    return;
	}
	var theButton = wikibar_resolveTargetButton(theTarget);
	if(!theButton){ return(false);  }
  	var o = theButton.toolItem;
    if(!o) { return; }
    var param = {
      event: e,
      button: theButton
    };
    if(o.HANDLER){ o.HANDLER(param);  }
  if(o.DISABLED){
    e.cancelBubble = true;
    if (e.stopPropagation){ e.stopPropagation(); }
  }
	return(false);
}
function wikibar_onClickMenuItem(e){
	if(!e){ e = window.event; }
	var theButton = wikibar_resolveTargetButton(resolveTarget(e));
	if(!theButton){ return(false);  }
	e.cancelBubble = true;
	if (e.stopPropagation){ e.stopPropagation(); }
    var title = theButton.tiddlerTitle;
    var editor = theButton.editor;
    var tool = theButton.toolItem;
    if(!tool) { return; }
    var popup = wikibarPopup.create(this);
  	if(popup){
      wikibar_createMenu(popup,tool,title,editor);
      if(!popup.hasChildNodes()){
        wikibarPopup.remove();
      }else{
        wikibarPopup.show(popup, false);
      }
    }
	return(false);
}
var wikibarColorTool = {
  defaultPaletteName : 'default',
  defaultColumns : 16,
  defaultPalette : [
    '#FFF','#DDD','#CCC','#BBB','#AAA','#999','#666','#333','#111','#000','#FC0','#F90','#F60','#F30','#C30','#C03',
    '#9C0','#9D0','#9E0','#E90','#D90','#C90','#FC3','#FC6','#F96','#F63','#600','#900','#C00','#F00','#F36','#F03',
    '#CF0','#CF3','#330','#660','#990','#CC0','#FF0','#C93','#C63','#300','#933','#C33','#F33','#C36','#F69','#F06',
    '#9F0','#CF6','#9C3','#663','#993','#CC3','#FF3','#960','#930','#633','#C66','#F66','#903','#C39','#F6C','#F09',
    '#6F0','#9F6','#6C3','#690','#996','#CC6','#FF6','#963','#630','#966','#F99','#F39','#C06','#906','#F3C','#F0C',
    '#3F0','#6F3','#390','#6C0','#9F3','#CC9','#FF9','#C96','#C60','#C99','#F9C','#C69','#936','#603','#C09','#303',
    '#0C0','#3C0','#360','#693','#9C6','#CF9','#FFC','#FC9','#F93','#FCC','#C9C','#969','#939','#909','#636','#606',
    '#060','#3C3','#6C6','#0F0','#3F3','#6F6','#9F9','#CFC','#9CF','#FCF','#F9F','#F6F','#F3F','#F0F','#C6C','#C3C',
    '#030','#363','#090','#393','#696','#9C9','#CFF','#39F','#69C','#CCF','#C9F','#96C','#639','#306','#90C','#C0C',
    '#0F3','#0C3','#063','#396','#6C9','#9FC','#9CC','#06C','#369','#99F','#99C','#93F','#60C','#609','#C3F','#C0F',
    '#0F6','#3F6','#093','#0C6','#3F9','#9FF','#699','#036','#039','#66F','#66C','#669','#309','#93C','#C6F','#90F',
    '#0F9','#6F9','#3C6','#096','#6FF','#6CC','#366','#069','#36C','#33F','#33C','#339','#336','#63C','#96F','#60F',
    '#0FC','#6FC','#3C9','#3FF','#3CC','#399','#033','#39C','#69F','#00F','#00C','#009','#006','#003','#63F','#30F',
    '#0C9','#3FC','#0FF','#0CC','#099','#066','#3CF','#6CF','#09C','#36F','#0CF','#09F','#06F','#03F','#03C','#30C'
  ],
	colorPicker : null,
  pickColorHandler: null,
  userData: null
};
wikibarColorTool.paletteName = wikibarColorTool.defaultPaletteName;
wikibarColorTool.columns = wikibarColorTool.defaultColumns;
wikibarColorTool.palette = wikibarColorTool.defaultPalette;
wikibarColorTool.onPickColor = function(e){
	if (!e){ e = window.event; }
	var theCell = resolveTarget(e);
	if(!theCell){ return(false); }
    color = theCell.bgColor.toLowerCase();
    if(!color)  { return; }
    wikibarColorTool.displayColorPicker(false);
    if(wikibarColorTool.pickColorHandler){
      wikibarColorTool.pickColorHandler(color, wikibarColorTool.userData);
    }
	return(false);
};
wikibarColorTool.onMouseOver = function(e){
	if (!e){ e = window.event; }
	var theButton = resolveTarget(e);
	if(!theButton){ return(false);  }
  	if(!wikibarColorTool)  { return; }
    color = theButton.bgColor.toUpperCase();
    if(!color)  { return; }
    td=document.getElementById('colorPickerInfo');
  	if(!td) { return; }
  	td.bgColor = color;
  	td.innerHTML = '<span style=\"color:#000;\">'+color+'</span>&nbsp;&nbsp;&nbsp;' +
  	               '<span style=\"color:#fff;\">'+color+'</span>';
	e.cancelBubble = true;
	if (e.stopPropagation){ e.stopPropagation(); }
	return(false);
};
wikibarColorTool.openColorPicker = function(theTarget, pickColorHandler, userData){
  wikibarColorTool.skipClickDocumentEvent = true;
  wikibarColorTool.pickColorHandler = pickColorHandler;
  wikibarColorTool.userData = userData;
  wikibarColorTool.moveColorPicker(theTarget);
};
wikibarColorTool.convert3to6HexColor = function(c){
  c=c.trim();
  var rx=/^\#(\d|[a-f])(\d|[a-f])(\d|[a-f])$/gi;
  return (rx.test(c)? c.replace(rx, '#$1$1$2$2$3$3') : c);
};
wikibarColorTool.numToHexColor = function (n){
  if(typeof(n)=='number' && (n>=0 && n<=255)) {
  		s = n.toString(16).toLowerCase();
  		return ((s.length==1)? '0'+s : s);
  }else{
	 return null;
	}
};
wikibarColorTool.renderColorPalette = function(){
	if(wikibarColorTool.paletteName==wikibarColorTool.defaultPaletteName){
		wikibarColorTool.palette=wikibarColorTool.defaultPalette;
		wikibarColorTool.columns=wikibarColorTool.defaultColumns;
		return;
	}
	tiddlerText = (store.getTiddlerText(wikibarColorTool.paletteName, '')).trim();
	if(tiddlerText.length<=0) { return; }
	var cpContents = tiddlerText.split('\n');
	var colors=[];
	columns = wikibarColorTool.defaultColumns;
	var tmpArray=null;
	errCount=0;
	for(var i=0; i<cpContents.length; i++){
		cpLine=cpContents[i].trim();
    if( (!cpLine) || (cpLine.length<=0) || (cpLine.charAt(0) == '#') ){ continue; }
		if(cpLine.substring(0,8).toLowerCase()=='columns:'){
			tmpArray = cpLine.split(':');
			try{
				columns = parseInt(tmpArray[1],10);
			}catch(ex){
				columns = wikibarColorTool.defaultColumns;
			}
		}else{
			tmpArray = cpLine.replace('\t', ' ').split(/[ ]{1,}/);
			try{
				color='';
				for(var j=0; j<3; j++){
          c=parseInt(tmpArray[j].trim(), 10);
          if(isNaN(c)){
						break;
          }else{
						c=wikibarColorTool.numToHexColor(c);
						if(!c) {break;}
            color+=c;
					}
				}
				if(color.length==6){
					colors.push('#'+color);
				}	else {
					throw 'error';
				}
			}catch(ex){
			}
		}
	}
	if(colors.length>0){
		wikibarColorTool.palette = colors;
		wikibarColorTool.columns = columns;
	}else{
		throw 'renderColorPalette(): No color defined in the palette.';
	}
};
wikibarColorTool.displayColorPicker = function(visible){
  if(wikibarColorTool.colorPicker){
    wikibarColorTool.colorPicker.style.display = (visible? 'block' : 'none');
  }
};
wikibarColorTool.moveColorPicker = function(theTarget){
  if(!wikibarColorTool.colorPicker){
  	wikibarColorTool.createColorPicker();
  }
	var cp = wikibarColorTool.colorPicker;
	var rootLeft = findPosX(theTarget);
  var rootTop = findPosY(theTarget);
  var popupLeft = rootLeft;
  var popupTop = rootTop;
  var popupWidth = cp.offsetWidth;
  var winWidth = findWindowWidth();
  if(popupLeft + popupWidth > winWidth){
	  popupLeft = winWidth - popupWidth;
	}
  cp.style.left = popupLeft + 'px';
  cp.style.top = popupTop + 'px';
  wikibarColorTool.displayColorPicker(true);
};
wikibarColorTool.createColorPicker = function(unused, palette){
  if(palette){	wikibarColorTool.paletteName=palette; }
	wikibarColorTool.renderColorPalette();
	wikibarColorTool.colorPicker = document.createElement('div');
	wikibarColorTool.colorPicker.id = 'colorPicker';
	document.body.appendChild(wikibarColorTool.colorPicker);
  var theTable = document.createElement('table');
  wikibarColorTool.colorPicker.appendChild(theTable);
  var theTR = document.createElement('tr');
	theTable.appendChild(theTR);
	var theTD = document.createElement('td');
	theTD.className = 'header';
	theTD.colSpan = wikibarColorTool.columns;
	theTD.innerHTML = wikibarColorTool.paletteName;
  theTR.appendChild(theTD);
  for(var i=0; i<wikibarColorTool.palette.length; i++){
    if((i%wikibarColorTool.columns)===0){
      theTR = document.createElement('tr');
      theTable.appendChild(theTR);
    }
    theTD = document.createElement('td');
    theTD.className = 'cell';
    theTD.bgColor = wikibarColorTool.convert3to6HexColor(wikibarColorTool.palette[i]);
    theTD.onclick = wikibarColorTool.onPickColor;
    theTD.onmouseover = wikibarColorTool.onMouseOver;
    theTR.appendChild(theTD);
  }
  rest = wikibarColorTool.palette.length % wikibarColorTool.columns;
  if(rest>0){
    theTD = document.createElement('td');
		theTD.colSpan = wikibarColorTool.columns-rest;
    theTD.bgColor = '#000000';
    theTR.appendChild(theTD);
  }
  theTR = document.createElement('tr');
	theTable.appendChild(theTR);
	theTD = document.createElement('td');
	theTD.colSpan = wikibarColorTool.columns;
	theTD.id = 'colorPickerInfo';
  theTR.appendChild(theTD);
};
wikibarColorTool.onDocumentClick = function(e){
	if (!e){ e = window.event; }
	if(wikibarColorTool.skipClickDocumentEvent) {
	  wikibarColorTool.skipClickDocumentEvent = false;
    return true;
	}
	if((!e.eventPhase) || e.eventPhase == Event.BUBBLING_PHASE || e.eventPhase == Event.AT_TARGET){
    wikibarColorTool.displayColorPicker(false);
  }
	return true;
};
function wikibar_doSelectPalette(param){
	clearMessage();
	var theButton = param.button;
	if(!theButton.toolItem.key)  { return; }
	var palette = theButton.toolItem.key;
	var oldPaletteName = wikibarColorTool.paletteName;
	if(oldPaletteName != palette){
		try{
			wikibarColorTool.createColorPicker(theButton, palette);
			displayMessage('Palette \"'+palette+'\" ('+ wikibarColorTool.palette.length +' colors) is selected');
		}catch(ex){
			errMsg = ex;
			if(errMsg.substring(0,18)=='renderColorPalette'){
				displayMessage('Invalid palette \"' + palette + '\", please check it out!');
				wikibarColorTool.createColorPicker(theButton, oldPaletteName);
			}
		}
	}
}
var wikibarPopup = {
  skipClickDocumentEvent: false,
	stack: []
};
wikibarPopup.resolveRootPopup = function(o){
  if(o.isOnMainMenu){  return null; }
  if(o.className.substring(0,12)=='wikibarPopup'){  return o;}
  return wikibarPopup.resolveRootPopup(o.parentNode);
};
wikibarPopup.create = function(root){
  for(var i=0; i<wikibarPopup.stack.length; i++){
    var p=wikibarPopup.stack[i];
    if(p.root==root){
      wikibarPopup.removeFrom(i+1);
      return null;
    }
  }
  var rootPopup = wikibarPopup.resolveRootPopup(root);
  if(!rootPopup){
    wikibarPopup.remove();
  }else{
    wikibarPopup.removeFromRootPopup(rootPopup);
  }
	var popup = createTiddlyElement(document.body,'div','wikibarPopup'+root.toolItem.key,'wikibarPopup');
	var pop = createTiddlyElement(popup,'table','','');
	wikibarPopup.stack.push({rootPopup: rootPopup, root: root, popup: popup});
	return pop;
};
wikibarPopup.show = function(unused,slowly){
	var curr = wikibarPopup.stack[wikibarPopup.stack.length-1];
	var overlayWidth = 1;
  var rootLeft, rootTop, rootWidth, rootHeight, popupLeft, popupTop, popupWidth;
  if(curr.rootPopup){
  	rootLeft = findPosX(curr.rootPopup);
  	rootTop = findPosY(curr.root);
  	rootWidth = curr.rootPopup.offsetWidth;
  	popupLeft = rootLeft + rootWidth - overlayWidth;
  	popupTop = rootTop;
  }else{
  	rootLeft = findPosX(curr.root);
  	rootTop = findPosY(curr.root);
  	rootHeight = curr.root.offsetHeight;
  	popupLeft = rootLeft;
  	popupTop = rootTop + rootHeight;
  }
	var winWidth = findWindowWidth();
	popupWidth = curr.popup.offsetWidth;
	if(popupLeft + popupWidth > winWidth){
		popupLeft = rootLeft - popupWidth + overlayWidth;
	}
	curr.popup.style.left = popupLeft + 'px';
	curr.popup.style.top = popupTop + 'px';
	curr.popup.style.display = 'block';
	addClass(curr.root, 'highlight');
	if(config.options.chkAnimate){
		anim.startAnimating(new Scroller(curr.popup,slowly));
	}else{
		window.scrollTo(0,ensureVisible(curr.popup));
	}
};
wikibarPopup.remove = function(){
	if(wikibarPopup.stack.length > 0){
		wikibarPopup.removeFrom(0);
  }
};
wikibarPopup.removeFrom = function(from){
	for(var t=wikibarPopup.stack.length-1; t>=from; t--){
		var p = wikibarPopup.stack[t];
		removeClass(p.root,'highlight');
		p.popup.parentNode.removeChild(p.popup);
  }
	wikibarPopup.stack = wikibarPopup.stack.slice(0,from);
};
wikibarPopup.removeFromRootPopup = function(from){
  for(var t=0; t<wikibarPopup.stack.length; t++){
    var p = wikibarPopup.stack[t];
    if(p.rootPopup==from){
      wikibarPopup.removeFrom(t);
      break;
    }
  }
};
wikibarPopup.onDocumentClick = function(e){
	if (!e){ e = window.event; }
	if(wikibarPopup.skipClickDocumentEvent){
	 wikibarPopup.skipClickDocumentEvent=false;
	 return true;
	}
	if((!e.eventPhase) || e.eventPhase == Event.BUBBLING_PHASE || e.eventPhase == Event.AT_TARGET){
		wikibarPopup.remove();
	}
	return true;
};
var wikibarStore = {
  TYPE: 'MAIN_MENU',
  help:{
    TYPE:'MENU',
    CAPTION: '<font face=\"verdana\">?</font>',
    TOOLTIP:     'about WikiBar',
    options:{
      TYPE:'MENU',
      DYNAITEM: wikibar_genWikibarOptions
    },
    about:{
      TYPE:'MENU',
      DYNAITEM: wikibar_genWikibarAbout
    }
  },
  preview:{
    TOOLTIP:     'preview this tiddler',
    CAPTION: '<font face=\"verdana\">&infin;</font>',
    HANDLER: wikibar_doPreview
  },
	line:{
		TOOLTIP:    'horizontal line',
		CAPTION: '<font face=\"verdana\">&mdash;</font>',
		syntax: '\n----\n',
		HANDLER: wikibar_editFormatByCursor
	},
	crlf:{
		TOOLTIP:    'new line',
		CAPTION: '<font face=\"verdana\">&para;</font>',
		syntax: '\n',
		HANDLER: wikibar_editFormatByCursor
	},
	selectAll:{
		TOOLTIP:    'select all',
		CAPTION: '<font face=\"verdana\">&sect;</font>',
		HANDLER: wikibar_editSelectAll
	},
	deleteSelected:{
		TOOLTIP:    'delete selected',
		CAPTION: '<font face=\"verdana\">&times;</font>',
		syntax: '',
		HANDLER: wikibar_editFormat
	},
  textFormat:{
    TYPE: 'MENU',
    CAPTION: 'text',
    TOOLTIP: 'text formatters',
    ignore:{
			TOOLTIP:     'ignore wiki word',
			CAPTION: 'ignore wikiWord',
			syntax:  '~user_text',
			hint:    'wiki_word',
			HANDLER:    wikibar_editFormatByWord
		},
		bolder:{
			TOOLTIP:     'bolder text',
			CAPTION: '<strong>bolder</strong>',
			syntax:  "''user_text''",
			hint:		 'bold_text',
			HANDLER:    wikibar_editFormatByWord
		},
		italic:{
			TOOLTIP:    'italic text',
			CAPTION: '<em>italic</em>',
			syntax: '\/\/user_text\/\/',
			hint:		'italic_text',
			HANDLER: wikibar_editFormatByWord
		},
		underline:{
			TOOLTIP:    'underline text',
			CAPTION: '<u>underline</u>',
			syntax: '__user_text__',
			hint:		'underline_text',
			HANDLER: wikibar_editFormatByWord
		},
		strikethrough:{
			TOOLTIP:    'strikethrough text',
			CAPTION: '<strike>strikethrough</strike>',
			syntax: '==user_text==',
			hint:		'strikethrough_text',
			HANDLER: wikibar_editFormatByWord
		},
		superscript:{
			TOOLTIP:    'superscript text',
			CAPTION: 'X<sup>superscript</sup>',
			syntax: '^^user_text^^',
			hint:		'superscript_text',
			HANDLER: wikibar_editFormatByWord
		},
		subscript:{
			TOOLTIP:    'subscript text',
			CAPTION: 'X<sub>subscript</sub>',
			syntax: '~~user_text~~',
			hint:		'subscript_text',
			HANDLER: wikibar_editFormatByWord
		},
		comment:{
			TOOLTIP:    'comment text',
			CAPTION: 'comment text',
			syntax: '/%user_text%/',
			hint:		'comment_text',
			HANDLER: wikibar_editFormatByWord
		},
		monospaced:{
			TOOLTIP:    'monospaced text',
			CAPTION: '<code>monospaced</code>',
			syntax: '{{{user_text}}}',
			hint:		'monospaced_text',
			HANDLER: wikibar_editFormatByWord
		}
  },
  paragraph:{
    TYPE: 'MENU',
    TOOLTIP: 'paragarph formatters',
    list:{
      TYPE: 'MENU',
      TOOLTIP: 'list tools',
      bullet:{
  			TOOLTIP:    'bullet point',
  			syntax: '*user_text',
  			hint:		'bullet_text',
  			HANDLER: wikibar_editFormatByLine
  		},
  		numbered:{
  			TOOLTIP:    'numbered list',
  			syntax: '#user_text',
  			hint:		'numbered_text',
  			HANDLER: wikibar_editFormatByLine
  		}
    },
    heading:{
      TYPE: 'MENU',
      heading1:{
  		  CAPTION:'<h1>Heading 1</h1>',
  			TOOLTIP:    'Heading 1',
  			syntax: '!user_text',
  			hint:		'heading_1',
  			HANDLER: wikibar_editFormatByLine
  		},
  		heading2:{
  		  CAPTION:'<h2>Heading 2<h2>',
  			TOOLTIP:    'Heading 2',
  			syntax: '!!user_text',
  			hint:		'heading_2',
  			HANDLER: wikibar_editFormatByLine
  		},
  		heading3:{
  		  CAPTION:'<h3>Heading 3</h3>',
  			TOOLTIP:    'Heading 3',
  			syntax: '!!!user_text',
  			hint:		'heading_3',
  			HANDLER: wikibar_editFormatByLine
  		},
  		heading4:{
  		  CAPTION:'<h4>Heading 4</h4>',
  			TOOLTIP:    'Heading 4',
  			syntax: '!!!!user_text',
  			hint:		'heading_4',
  			HANDLER: wikibar_editFormatByLine
  		},
  		heading5:{
  		  CAPTION:'<h5>Heading 5</h5>',
  			TOOLTIP:    'Heading 5',
  			syntax: '!!!!!user_text',
  			hint:		'heading_5',
  			HANDLER: wikibar_editFormatByLine
  		}
    },
    comment:{
      TYPE: 'MENU',
      commentByLine:{
  			CAPTION:'comment by line',
  			TOOLTIP:    'line comment',
  			syntax: '/%user_text%/',
  			hint:		'comment_text',
  			HANDLER: wikibar_editFormatByLine
  		},
  		commentByBlock:{
  			CAPTION:'comment by block',
  			TOOLTIP:    'block comment',
  			syntax: '/%\nuser_text\n%/',
  			hint:		'comment_text',
  			byBlock: true,
  			HANDLER: wikibar_editFormatByLine
  		}
    },
    monospaced:{
      TYPE: 'MENU',
  		monosByLine:{
  			CAPTION: 	'monospaced by line',
  			TOOLTIP:    'line monospaced',
  			syntax: '{{{\nuser_text\n}}}',
  			hint:		'monospaced_text',
  			HANDLER: wikibar_editFormatByLine
  		},
  		monosByBlock:{
  			CAPTION: 	'monospaced by block',
  			TOOLTIP:    'block monospaced',
  			syntax: '{{{\nuser_text\n}}}',
  			hint:		'monospaced_text',
  			byBlock: true,
  			HANDLER: wikibar_editFormatByLine
  		}
    },
    quote:{
      TYPE: 'MENU',
  		quoteByLine:{
  			CAPTION: 	'quote by line',
  			TOOLTIP:    'line quote',
  			syntax: '>user_text',
  			hint:		'quote_text',
  			HANDLER: wikibar_editFormatByLine
  		},
  		quoteByBlcok:{
  			CAPTION: 	'quote by block',
  			TOOLTIP:    'block quote',
  			syntax: '<<<\nuser_text\n<<<',
  			hint:		'quote_text',
  			byBlock: true,
  			HANDLER: wikibar_editFormatByLine
  		}
    },
    plugin:{
      TYPE: 'MENU',
      code:{
  			CAPTION: 	'code area',
  			TOOLTIP:    'block monospaced for plugin',
  			syntax: '\n\/\/{{{\nuser_text\n\/\/}}}\n',
  			hint:		'monospaced_plugin_code',
  			byBlock: true,
  			HANDLER: wikibar_editFormatByLine
  		},
  		commentByLine:{
  			CAPTION: 	'comment by line',
  			TOOLTIP:    'line comment',
  			syntax: '\/\/user_text',
  			hint:		'plugin_comment',
  			HANDLER: wikibar_editFormatByLine
  		},
  		commentByBlock:{
  			CAPTION: 	'comment by block',
  			TOOLTIP:    'block comment',
  			syntax: '\/\***\nuser_text\n***\/',
  			hint:		'plugin_comment',
  			byBlock: true,
  			HANDLER: wikibar_editFormatByLine
  		}
    },
    css:{
      TYPE: 'MENU',
      code:{
  			CAPTION: 	'code area',
  			TOOLTIP:    'block monospaced for css',
  			syntax: '\n\nuser_text\n\n',
  			hint:		'monospaced_css_code',
  			byBlock: true,
  			HANDLER: wikibar_editFormatByLine
  		},
  		commentByLine:{
  			CAPTION: 	'comment by line',
  			TOOLTIP:    'line comment',
  			syntax: '',
  			hint:		'css_comment',
  			HANDLER: wikibar_editFormatByLine
  		},
  		commentByBlock:{
  			CAPTION: 	'comment by block',
  			TOOLTIP:    'block comment',
  			syntax: '',
  			hint:		'css_comment',
  			byBlock: true,
  			HANDLER: wikibar_editFormatByLine
  		}
    }
  },
  color:{
    TYPE: 'MENU',
    TOOLTIP: 'color tools',
    highlight:{
		  CAPTION:'highlight text',
			TOOLTIP:    'highlight text',
			syntax: '@@user_text@@',
			hint:		'highlight_text',
			HANDLER: wikibar_editFormatByWord
		},
		color:{
		  CAPTION:'text color',
			TOOLTIP:    'text color',
			hint:		'your_text',
			syntax: '@@color(%1):user_text@@',
			HANDLER:   wikibar_getColorCode,
			doMore: wikibar_editFormatByWord
		},
		bgcolor:{
		  CAPTION:'background color',
			TOOLTIP:    'background color',
			hint:		'your_text',
			syntax: '@@bgcolor(%1):user_text@@',
			HANDLER: wikibar_getColorCode,
			doMore: wikibar_editFormatByWord
		},
		colorcode:{
      CAPTION:'color code',
      TOOLTIP:    'insert color code',
      syntax: '%1',
      HANDLER: wikibar_getColorCode,
      doMore: wikibar_editFormatByCursor
    },
    'color palette':{
      TYPE:'MENU',
      DYNAITEM: wikibar_genPaletteSelector,
  		SEPERATOR:{},
  		morePalette:{
  		  CAPTION:'more palettes',
  		  TOOLTIP:'get more palettes',
  		  HANDLER: wikibar_getMorePalette
  		}
    }
  },
  link:{
    TYPE: 'MENU',
    TOOLTIP: 'insert link',
    wiki:{
		  CAPTION:'wiki link',
			TOOLTIP:    'wiki link',
			syntax: '[[user_text]]',
			hint:		'wiki_word',
			HANDLER: wikibar_editFormatByWord
		},
		pretty:{
			CAPTION: 	'pretty link',
			TOOLTIP:    'pretty link',
			syntax: '[[user_text|%1]]',
			hint:		'pretty_word',
			param:	'PrettyLink Target',
			HANDLER:   wikibar_getLinkUrl,
			doMore: wikibar_editFormatByWord
		},
		url:{
			TOOLTIP:    'url link',
			syntax: '[[user_text|%1]]',
			hint:		'your_text',
			param:	'http:\/\/...',
			HANDLER:   wikibar_getLinkUrl,
			doMore: wikibar_editFormatByWord
		},
		image:{
			TOOLTIP:    'image link',
			syntax: '[img[user_text|%1]]',
			hint:		'alt_text',
			param:	'image/icon.jpg',
			HANDLER:   wikibar_getLinkUrl,
			doMore: wikibar_editFormatByWord
		}
  },
  macro:{},
  more:{
    TYPE: 'MENU',
    TOOLTIP: 'more tools',
    table:{
      TYPE: 'MENU',
      TOOLTIP: 'table',
      table:{
  		  CAPTION:'create table',
  			TOOLTIP:    'create a new table',
  			syntax: '\n%1\n',
  			HANDLER: wikibar_getTableRowCol,
  			doMore: wikibar_editFormatByWord
  		},
  		header:{
  			TOOLTIP:    'table header text',
  			syntax: '|user_text|c',
  			hint:		'table_header',
  			HANDLER: wikibar_editFormatByWord
  		},
  		cell:{
  			TOOLTIP:    'create a tabel cell',
  			syntax: '|user_text|',
  			hint:		'your_text',
  			HANDLER: wikibar_editFormatByWord
  		},
  		columnHeader:{
  		  CAPTION:'column header',
  			TOOLTIP:    'create a column header cell',
  			syntax: '|!user_text|',
  			hint:		'column_header',
  			HANDLER: wikibar_editFormatByWord
  		},
  	  cell:{
  	    TYPE: 'MENU',
        CAPTION: 'cell options',
    		bgcolor:{
    			CAPTION: 	'background color',
    			TOOLTIP:    'cell bgcolor',
    			syntax: '|bgcolor(%1):user_text|',
    			hint:		'your_text',
    			HANDLER: wikibar_getColorCode,
    			doMore: wikibar_editFormatByTableCell
    		},
    		alignLeft:{
    			CAPTION: 	'align left',
    			TOOLTIP:    'left align cell text',
    			syntax: '|user_text|',
    			hint:		'your_text',
    			HANDLER: wikibar_editFormatByTableCell
    		},
    		alignCenter:{
    			CAPTION: 	'align center',
    			TOOLTIP:    'center align cell text',
    			syntax: '| user_text |',
    			hint:		'your_text',
    			HANDLER: wikibar_editFormatByTableCell
    		},
    		alignRight:{
    			CAPTION: 	'align right',
    			TOOLTIP:    'right align cell text',
    			syntax: '| user_text|',
    			hint:		'your_text',
    			HANDLER: wikibar_editFormatByTableCell
    		}
    	}
    },
    html:{
      TYPE: 'MENU',
      html:{
  			CAPTION: 	'&lt;html&gt;',
  			TOOLTIP:    'html tag',
  			syntax: '<html>\nuser_text\n</html>',
  			hint:		'html_content',
  			byBlock: true,
  			HANDLER: wikibar_editFormatByLine
  		}
    }
  },
  addon:{
    TYPE: 'MENU',
    TOOLTIP:'3rd party tools',
    'about addons':{
      TOOLTIP: 'list loaded addons',
      HANDLER: wikibar_doListAddons
    },
    SEPERATOR:{}
  }
};
addEvent(document, 'click', wikibarColorTool.onDocumentClick);
addEvent(document, 'click', wikibarPopup.onDocumentClick);
wikibar_install();
//}}}
!!ubuntu自带的共享工具
*ubuntu {{{-->}}} windows
路径:''System-Preferences-Personal File Sharing''(ubuntu10.04是这样,早期版本可能是''System-Administration-Shared Folders'')
若没有的话可以安装:
>sudo apt-get install nautilus-share
可能会出现如下错误
{{{
This feature  cannot  be enabled  because the required packages are not installed on your system
}}}
安装apache即可:
>sudo apt-get install apache2
*windows {{{-->}}} ubuntu
windows正常共享,ubuntu中工具:''Places-Network''用于查看局域网中的所有共享目录,或''Places-Connect to Server'',填入地址直接访问共享目录
!!samba工具
*ubuntu {{{-->}}} windows
安装samba,并配置,参考[[How To: Definitive Samba Guide for 10.04|http://ubuntuforums.org/showthread.php?t=1468498]]
需要注意的是''samba中增加的用户必须是系统中存在的用户'',否则会出错(可以先在系统中新建一个用于共享的用户)
*windows {{{-->}}} ubuntu
<code bash>
sudo mkdir /media/win_share #共享目录的挂载目的地
sudo apt-get install smbfs  #挂载时使用的是smbfs文件系统类型,samba会帮忙通信,需安装
#将window目录挂载到本地目录,注意iocharset=uft8是为了解决乱码问题,default的具体含义见最下参考文献
sudo mount -t smbfs –o username=wy,password=123,iocharset=uft8,defaults //192.168.0.1/share /media/win_share  
</code>
这样做的话每次重启都需要手动挂载,解决办法有两个1, 将上述命令写成脚本,设成开机启动;2, 设置fstab,在/etc/fstab中加入如下行
<code bash>
//192.168.0.1/share   /media/win_share  smbfs  username=wy,password=123,iocharset=utf8,defaults  0  0
</code>
fstab的信息可参考[[用fstab挂载分区]]和[[ How to edit and understand /etc/fstab|http://www.tuxfiles.org/linuxhelp/fstab.html#one-two]]
也可以使用''smbclient'',参考[[ubuntu_Samba||http://wiki.ubuntu.org.cn/Samba]],它还包括一些错误信息

@@color(red):来自电脑中的视频《word长篇文档排版技巧》@@

*{{{Ctrl+Home}}}
>定位到文章开头(24m46s)
*通过''查找''菜单中的''格式''菜单来定位所有某一个格式的文字
*应用样式可设置快捷键,在''修改样式''的菜单中
*{{{Ctrl+[或]}}}调整字体大小
*去除格式:选中文字-在''格式和样式''窗口点''清除格式''(27m56s)
*分节的作用是:可以对不同的节弄不同的格式
>查看分节:按“''显示或隐藏标记标记''”按钮,或者快捷键(''Ctrl+*''),后者用查找(查找内容在''特殊字符''中选择''分节符'')
>很多时候不同的章节之间要分节,而不是分页
>“''首页不同''”选项是指每一节的''第一页''的格式不同
*''模板''&''样式''的选择与传递(''1h35m'')
*预处理
由于[[XML标准|http://www.w3.org/TR/2000/REC-xml-20001006#NT-Char]]所规定的字符集是Unicode(如UTF8)的''子集'',所以在处理Unicode字符集的XML文档是需要进行预处理,见[[Invalid XML Characters: when valid UTF8 does not mean valid XML|http://cse-mjmcl.cse.bris.ac.uk/blog/2007/02/14/1171465494443.html]]。StackOverflow上也早有人遇到过此问题,有人提供了一个Sanitize XML文件的程序:见[[这里|http://stackoverflow.com/questions/93655/stripping-invalid-xml-characters-in-java]]
*Parsing
**Java版:[[Java处理XML]]
**Python版:[[Python处理XML]]
*XML生成
**xml.dom.minidom
>见[[这里|http://www.postneo.com/projects/pyxml/]]和[[CSDN博客|http://blog.csdn.net/kiki113/archive/2009/04/15/4078228.aspx]]
**xml.etree.ElementTree
>见[[这里|http://lulinbest.blog.sohu.com/75921823.html]]
*XML特殊字符转义([[Ref|http://blogger.org.cn/blog/more.asp?name=Qr&id=30342]])
| !特殊字符 | !实体值字符串 |
| > | &gt; |
| < | &lt; |
| & | &amp; |
| " | &quote; |
| ' | &apos; |
{{{__main__}}}是个模块,当整个文件作为主程序时,程序的{{{__name__}}}(应该是模块名)就为{{{__main__}}};当这个文件被当作模块被其他程序导入(调用)时,{{{__name__}}}是这个文件的文件名(即模块名)。
{{{update}}}:参见《Dive Into Python》26页,它的一般用处是在将模块集成到大程序中前先进行单元测试;
*''{{{内置变量}}}'':ARGC,ARGV,NR,FNR,NF,FS,OFS,RS,ORS,FILENAME,ENVIRON
*''{{{next}}}'':可以简单理解为''跳过后面''的代码,如果next被执行,那么它后面的代码就都不会被执行了。
*可以指定''变量名的值''或向脚本传''具名参数''
*''{{{字符串函数}}}''
*''{{{数组}}}''
*''{{{for}}}''循环遍历
{{{
for (i in array) {print array[i]}
}}}
*''{{{printf}}}''格式化输出字符串(不是打印到文件)
*''{{{awk脚本文件}}}''开头写上''!/bin/awk -f'',执行自包含脚本,需要输入文件作为参数
!C
*[[变量在内存中存储结构]]
*[[结构体指针+1的问题]]
*[[格式化sprintf]]
*[[C&C++中关于void的一些原则]]
*[[minix中函数原型定义的方法]]
*[[C语言指针]]
*[[关于char和unsigned char自己的一些理解]]
*[[struct中的字节对齐]]
*[[++操作及其效率]]
*[[关于指针和数组变量]]
*[[双重指针]]
!Java
*[[《JAVA SE6全方位学习》笔记]]
*[[java中的局部变量和成员变量]]
*[[java类中静态域、块,非静态域、块,构造函数的初始化顺序]]
*[[IO类选择]]
*[[Java处理XML]]
*[[Java正则]]
*[[long和byte[]相互转换]]
!CPP
*[[参考资源]]
*[[杂记]]
*[[《C++大学教程》笔记]]
*[[《C++ Primer》笔记]]
*[[Ubuntu8.04环境 boost手动安装]]
*[[vector中的resize和reserve]]
*[[CPP中指针与引用]]
*[[自定义STL容器中的比较函数]]
*[[STL容器中指针作为元素]]
*[[STL二三事]]
*[[调用python]]
*[[模板库]]
*[[文件操作方法]]
*[[二维数组声明]]
*[[图像处理]]
!Python
[[Python文件操作]]
[[Dive Into Python学习笔记]]
[[Core Python学习笔记]]
[[python杂]]
[[__main__二三事]]
[[eric安装]]
[[人人网信息抓取器]]
[[Java与Python]]
[[Python处理XML]]
[[Python处理cvs, xls, xlsx]]
[[PyQt]]
[[Python访问数据库]]
[[Python Debugging]]
!shell脚本
[[awk]]
!Profile
[[工具讨论]]
!Resource
台湾井民全的课程页面(Java,C++,Windows Programming等):[[传送们|http://debut.cis.nctu.edu.tw/~ching/Course/course.htm]]
!其他
[[XML处理]]
[[编码问题]]
!windows下安装

''@@bgcolor(lightblue):先安装[[Python(x,y)|http://www.pythonxy.com/]],它已经将环境和依赖配置好了,然后直接进入安装Eric的步骤@@''

==================================废弃=================================
1. ''安装Python''
>直接按默认目录(C:\Python26\)安装,然后配置环境变量
2.''安装QT4''
>到官网上下载Windows平台的GPL版本(170多M吧),它已经自带MINGW,安装目录可以自定义<下得很慢,自己都保存好好了>
>将QT和MINGW的''bin''目录加到path路径中
>增加下面两个环境变量,作用未知
>>QTDIR=E:\Qt\4.3.2(QT的安装目录)
>>QMAKESPEC=win32-g++
3.''将mingw-make复制为make.exe''
>因为下面编译的时候要用到make,不用单独下make工具了,直接用MinGW的
4.''安装SIP''(以下进入SIP目录)
>{{{python configure.py -p win32-g++}}}
>{{{make}}}
>{{{make install}}}
5.''安装QScintilla''(以下进入QScintilla目录)
>{{{cd Qt4}}}
>{{{qmake qscintilla.pro}}}
>{{{make}}}
>{{{make install}}}
>{{{copy %QTDIR%\lib\qscintilla2.dll %QTDIR%\bin}}}
>{{{cd ..}}}
>{{{cd Python}}}
>{{{python configure.py -n C:\Qt\4.4.2\include -o C:\Qt\4.4.2\lib}}}
以下几步没做(没成功),但是后面还是能正常安装的
><编辑makefile,将QT的目录换成真实目录>
>{{{make}}}
>{{{make install}}}
6.''安装PyQt''
>最好按''默认路径''直接安装到''Python的安装目录''中,第一次没这样做出现了问题
7.''安装eric''(以下进入eric目录)
>{{{python install}}}
>关于Eric的配置见''Ref3'',其中配置Auto-completion时,Python的api文件是在Python的安装目录中的api目录里

''首要参考'':[[Ref1|http://blog.chinaunix.net/u2/78219/showart_1211981.html]]
''次要参考'':[[Ref2|http://acestrong.spaces.live.com/blog/cns!A931637097BB476D!635.entry]]
''Another参考'':[[Ref3|http://beike.javaeye.com/blog/266007]]
==================================/废弃=================================
去[[这里|http://www.foobar2000.com.cn/showtopic-1693.html]]随便下个美化版,我试下来比较喜欢''仿播放器经典界面Classic Emu'',下下来解压到某处,暂且根目录定为如下路径:
|D:\foobar2000
打开后发现他本身就有一个''lyric show''组件,其实还可以的,但是词库量还是不够大,所以追求完美的话要自己的歌词显示组件来替换它。
试下来,最好的还是''乐辞'',它的词库比较全。它的安装步骤见[[这篇文章|http://www.jiaocheng360.com/jiaocheng/19680.html]],总体来说就是两步:
#下载并安装乐辞,很傻瓜的操作,都可以默认
#需要额外下载''Columns UI''组件,在它的官网上有,然后在configure中把它添加到合适位置
由于这个CUI(具体的CUI、PUI、DUI区别见[[这里|http://www.foobar2000.com.cn/showtopic-2765.html]])组件相当得丑,所以为了能够在其他CUI中添加乐辞,找了n久解决方案。最后居然是在不经意间解决的:
乐辞的原理貌似是本机上装了软件,但是foobar通过它自己的CUI组件来调用乐辞软件的。所以不换CUI理论上根本没法弄。事实上也证明是这样的,在CUI中右击,看不到''面板->乐辞''的选项。
然后,自己又在网上找,找到一个叫''速配歌词的软件'',下载它的''[[独立版|http://www.newhua.com/soft/1450.htm#download]]'',然后安装即可,安装过程桌选择foobar的路径即可。它其实是一个外挂字幕,暂时没发现把它嵌到foobar的方法,所以不大方便。
神奇的是,这是我有突然可以再foobar的configure里的CUI中添加乐辞了,即右键选项中有''面板->乐辞''的选项。正常加载!
总体来说,三者之间的比较就是:
||!自带的lyric show|!乐辞|!速配歌词|
|优点|不用配置,内嵌|词库大,内嵌|词库大(貌似调用的是九天的词库)|
|缺点|词库''相对''较小|--需要配置,配置拼人品-- 已解决,详见最后更新|外挂,不方便|
现在已经把成功运行乐辞的foobar打包,将来可以直接用了~

''<html><font color="red" size="5">更新:</font></html>''乐辞的那个问题已经解决,只要将一个名为foo_uie_lyricist.dll的文件放入components目录即可,至于之歌文件怎么来的,没发现,可能是装速配的时候有的吧。其他很多其他改版里面都包含了这个文件。

配置好的foobar贴图:
[img[这里应该是图片|file:///J:\pic\贴图\foobar.png]]
''See:'' [[Geek Stuff|http://www.thegeekstuff.com/2009/03/15-practical-unix-grep-command-examples/]]
*Checking for full words, not for sub-strings using ''grep -w''
* Displaying lines before/after/around the match using ''grep -A, -B and -C''
*Searching in all files recursively using ''grep -r''
*Invert match using ''grep -v''
*display the lines which does not matches all the given pattern.
Syntax:
''grep -v -e "pattern" -e "pattern"''
>$ cat test-file.txt
>a
>b
>c
>d
>$ grep -v -e "a" -e "b" -e "c" test-file.txt
>d
*Counting the number of matches using ''grep -c''
*Display only the file names which matches the given pattern using ''grep -l''
*Show only the matched string using ''grep -o''
*Show line number while displaying the output using ''grep -n''
1. [[iTunes注册|http://bbs.weiphone.com/read-htm-tid-215824-page-1.html]]
2.备份shsh:
**[[请小白重视一下备份SHSH的重要|http://bbs.weiphone.com/read-htm-tid-1134647.html]]
**[[教你如何备份shsh(新增4.1备份工具) 越狱 解锁 恢复3.1.3固件等一系列详细教程|http://bbs.weiphone.com/read-htm-tid-912818.html]]
3.越狱
**三代机器,所有系统版本(除iOS 4.1 Beta版以外):[[完美越狱JailbreakMe2.0降临|http://iphone.weiphone.com/news/2010-08-02/The_perfect_escape_JailbreakMe2.0_come_220871.shtml]]
**三代以上全系统,包括4.1:[[绿毒越狱|http://bbs.weiphone.com/read-htm-tid-1208735.html]]
>>此方法需要不断重试:[[我的绿毒越狱成功|http://bbs.weiphone.com/read-htm-tid-1208729.html]]
**比较老(但貌似也比较稳)的帖子(5月份)3.1.2, 3.1.3, or 3.2:[[全设备越狱时代到来,Spirit越狱工具发布|http://bbs.weiphone.com/read-htm-tid-772203.html]]
**4.0系统越狱:[[iPod Touch全系列4.0固件越狱详细教程|http://bbs.weiphone.com/read-htm-tid-858509.html]]
**4.1系统越狱
***[[itouch 4代亲测越狱成功(适合3代机子哦)|http://bbs.weiphone.com/read-htm-tid-1190125.html]]
>>>此方法的注意事项:[[〖99.99成功〗关于32G及其他版本使用becoolm方法越狱没出现绿水滴的解决办法|http://bbs.weiphone.com/read-htm-tid-1204439-page-1.html]]
***[[【4.1完美越狱教程】绿雨图文安装教程 (完美支持41周前与后)|http://bbs.weiphone.com/read-htm-tid-1190530.html]]
>>>[[分享我的touch 3代 32G越狱经验|http://bbs.weiphone.com/read-htm-tid-1192102.html]]
>>>[[touch 3 32g limera1n beta4 成功越狱记录.doc|http://bbs.weiphone.com/read-htm-tid-1212478.html]]
**越狱心得:
***[[伪3和3代32G越狱|http://bbs.weiphone.com/read-htm-tid-1215338.html]]
***[[说说是用绿雨越狱后的感受吧|http://bbs.weiphone.com/read-htm-tid-1210471.html]]
4. [[iTunes教程|http://bbs.weiphone.com/read-htm-tid-1137415.html]]
5.系统配置
**[[不用91助手!itouch2完全图文教程 [ipa、传输文件、安装主题](Winscp装主题)|http://bbs.weiphone.com/read.php?tid=306305]]
6.软件&游戏资源
**[[音乐经营类游戏|http://iphonebbs.cnmo.com/thread-98947-1-1.html]]
**[[iPod Touch软件资源收集全集合(分类较好)|http://bbs.weiphone.com/read-htm-tid-550417.html]]
**[[超华丽!目前最好用的RSS软件 SmartRSS 2|http://bbs.weiphone.com/read-htm-tid-317452.html]]
**[[App分享+经验技巧+系统改造+源集+工具|http://bbs.weiphone.com/read-htm-tid-857917.html]]
**[[weGeeks自购自破合集索引|http://bbs.weiphone.com/read-htm-tid-659072.html]]
**[[touch3代精品免费软件大收集|http://bbs.weiphone.com/read-htm-tid-512106.html]]
**[[IT3超无敌实用又好用软件游戏集锦|http://bbs.weiphone.com/read-htm-tid-528653.html]]
**[[22款精品游戏+14款实用软件(5月29日更新)|http://bbs.weiphone.com/read-htm-tid-785526-page-1.html]]
**[[破解软件海量下载!全力打造最强IPA集合|http://bbs.weiphone.com/read.php?tid=221494]]
**[[ios 4.0越狱后一定要安装的软件和使用教程|http://bbs.weiphone.com/read-htm-tid-1031027.html]]
**[[豆瓣小组推荐|http://www.douban.com/group/topic/9180754/]]
**[豆瓣在线活动——APP分享|http://www.douban.com/online/10363700/album/24385700/]]
7.电子书资源
**[[我的IBOOKS里收藏的图书(EPUB)|http://bbs.weiphone.com/read-htm-tid-989223.html]]
**[[导入电子书(传输文件)|http://www.digidna.net/products/diskaid/download]]
**[[电子书、文档查看器|http://www.digidna.net/products/fileapp]]
8. 主题
**[[ipod-touch-themes|http://www.ipod-touch-themes.de]]
**[[91 theme|http://mobile.91.com/Theme/iPhone/35554.html]]
9.传输文件与文件操作
**''DiskAid''
>>附keygen的下载见[[这里|http://bbs.weiphone.com/read-htm-tid-579144-page-1.html]],然后下载最新版本覆盖即可
{{{
相当好用的工具,可以传输电子书(直接定位StanZa的目录),软件的扩展文件(如字幕、歌词等等)
}}}
**''iFile''
>>直接在iTouch上访问文件系统,操作文件和目录
{{{
rou的Itouch的一些程序目录(/var/mobile/Applications/):太鼓达人(289D392C....)LRC Player(C5CE3CAC....)
}}}

*Reference:
**[[【iTouch 版块精品资源大集合】(几乎包含下面资源的索引)|http://bbs.weiphone.com/read-htm-tid-477787.html]]
**[[『WEIP技术组』我的iPod Touch我做主~新手篇&破解&说明&更新|http://bbs.weiphone.com/read-htm-tid-443797.html]]
***1楼:TOUCH的相关介绍 
***2楼:TOUCH的破解。 (包括固件升级教程)
***3楼:TOUCH的游戏和程序安装。 
***4楼:TOUCH的主题安装 
***5楼:TOUCH的相关高级说明 
***6楼:Touch固件大全
**[[苹果所有产品所有版本固件下载|http://bbs.weiphone.com/read-htm-tid-643300.html]]
**[[iPod Touch秘籍|http://bbs.weiphone.com/read-htm-tid-290195.html]]
**[[关于音乐.-.电影.-.破解后.-.Touch的使用集合帖子(音乐、电影格式转换)|http://bbs.weiphone.com/read-htm-tid-342904.html]]
**[[优酷视频专辑|http://u.youku.com/user_show/id_UMjQ1NTMyMDk2.html]]
**[[How do I transfer books from my computer to my iPhone or iPod Touch|http://www.lexcycle.com/faq/how_to_get_books_onto_stanza_iphone]]
*成员变量:作为类的成员而存在,直接存在于类中。
*局部变量:作为方法或语句块的成员而存在,存在于方法的参数列表和方法定义中。

局部变量在使用前必须被程序员主动的初始化,和此形成对比,系统中的成员变量则会被系统提供一个默认的初始值。所以在语法上,类的成员变量能够定义后直接使用,而局部变量在定义后先要赋初值,然后才能使用。

所有类的成员变量可以通过this来引用。成员变量又分成俩中类型:实例变量和静态变量。静态变量在定义时要使用static关键字。
[[原文|http://fishermen.javaeye.com/blog/24025]]
在《Core java 2: volumn 1, Edition 5》一书的第四章“对象与类”中讲到域赋值语句、实例块、静态块及构造方法等在创建类实例时的执行顺序,中文译本有些处翻译的不贴切,而英文原书中也有一处错误。本文通过一个小程序来说明类实例构造过程中的语句执行顺序。

程序如下:

public class Teststaticblock
{
public Teststaticblock()
{
  this("second");
  System.out.println("begin constructor");
  System.out.println(s_a);
  System.out.println(s_b);
  System.out.println(c);
  System.out.println(d);
{{{//  this("second");//call to this must be first statement in constructor}}}
  s_a=1111;
  s_b=2222;
  c=3333;
  d=4444;
  System.out.println(s_a);
  System.out.println(s_b);
  System.out.println(c);
  System.out.println(d);
  System.out.println("end constructor");
}
public Teststaticblock(String s)
{
  System.out.println("begin second constructor");
  System.out.println("end second constructor");
}
public static void main(String args[])
{
  System.out.println("begin main");
  System.out.println(s_a);
  System.out.println(s_b);
{{{//  System.out.println(c);//non-static variable c cannot be referenced from a static context}}}
{{{//  System.out.println(d);//non-static variable c cannot be referenced from a static context}}}
  s_a=11111;
  s_b=22222;
{{{//  c=33333;//non-static variable c cannot be referenced from a static context}}}
{{{//  d=44444;//non-static variable c cannot be referenced from a static context}}}
  System.out.println(s_a);
  System.out.println(s_b);
{{{//  System.out.println(c);//non-static variable c cannot be referenced from a static context}}}
{{{//  System.out.println(d);//non-static variable c cannot be referenced from a static context}}}
  System.out.println("before new class object");
  Teststaticblock t = new Teststaticblock();
  System.out.println("end new class object");
  System.out.println(s_a);
  System.out.println(s_b);
{{{//  System.out.println(c);//non-static variable c cannot be referenced from a static context}}}
{{{//  System.out.println(d);//non-static variable c cannot be referenced from a static context}}}
  s_a=111111;
  s_b=222222;
{{{//  c=333333;//non-static variable c cannot be referenced from a static context}}}
{{{//  d=444444;//non-static variable c cannot be referenced from a static context}}}
  System.out.println(s_a);
  System.out.println(s_b);
{{{//  System.out.println(c);//non-static variable c cannot be referenced from a static context}}}
{{{//  System.out.println(d);//non-static variable c cannot be referenced from a static context}}}
  System.out.println("end main");
}

static int s_a=1;
int c=3;
{
  System.out.println("begin block");
  System.out.println(s_a);
  System.out.println(s_b);
  System.out.println(c);
{{{//  System.out.println(d);//illegal forward reference}}}
  s_a=111;
  s_b=222;
  c=333;
  d=444;
  System.out.println(s_a);
  System.out.println(s_b);
  System.out.println(c);
{{{//  System.out.println(d);//illegal forward reference}}}
  System.out.println("end block");
}
static
{
  System.out.println("begin static block");
  System.out.println(s_a);
{{{//  System.out.println(s_b);//illegal forward reference}}}
{{{//  System.out.println(c);//non-static variable c cannot be referenced from a static context}}}
{{{//  System.out.println(d);//non-static variable c cannot be referenced from a static context}}}
  s_a=11;
  s_b=22;
  System.out.println(s_a);
{{{//  System.out.println(s_b);//illegal forward reference}}}
{{{//  System.out.println(c);//non-static variable c cannot be referenced from a static context}}}
{{{//  System.out.println(d);//non-static variable c cannot be referenced from a static context}}}
  System.out.println("end static block");
}
int d=4;
static int s_b=2;

}


输出如下:

begin static block
1
11
end static block
begin main
11
2
11111
22222
before new class object
begin block
11111
22222
3
111
222
333
end block
begin second constructor
end second constructor
begin constructor
111
222
333
4
1111
2222
3333
4444
end constructor
end new class object
1111
2222
111111
222222
end main

通过对输出进行分析,可以得出如下结果:
1、在类第一次加载时候,会执行静态域(field)初始化语句和静态块(用static{}包含的部分)。
这里要注意:
    a、不管静态域声明语句的实际位置在哪儿,当第一次加载类的时候都会首先对它初始化为缺省值(0,false,null等)。
    b、即使静态域声明中使用了显式初始化语句(比如:int x=3),第一次加载类的时候也会先把它初始化为缺省值(此时x为0),然后再按照下面说的要点c来执行赋值语句(x=3)。
    c、对于静态域的显式初始化语句和静态块,按照在类中代码出现的先后顺序执行。
     因此,在上面的例子程序中,我们看到
      static int s_a=1;
      static
      {
         s_a=11;
         s_b=22;
       }
       static int s_b=2;
      对s_a,s_b会有不同的效果。类加载时候,s_a,s_b都被初始化为0,然后由于依照代码顺序执行了s_a=1;s_a=11;s_b=22;s_b=2;结果s_a、s_b分别变成了11和2。

2、当构造类实例时候,会先对实例域初始化为缺省值,然后执行实例块(用{}括起来的部分),然后执行构造方法。其中:
    a、如同1中一样,如果有实例域的显式初始化语句,程序仍然是先将该域初始化为缺省值,然后按照代码在类中出现的先后顺序执行初始化语句或者实例块。如果实例块位置在初始化语句前面,即使它改变了该域的值,也会被随后执行的初始化语句改回去。
    b、在进入构造方法后,如果构造方法第一句是使用this(...)调用另一构造方法的话,则先执行另一构造方法,然后再执行本构造方法的方法体。这种用法必须让this(...)位于第一句。

《Core java 2》书中所说的"进入构造方法后,如果第一句是调用别的构造方法,则进入别的构造方法。否则,执行实例块"的提法有问题。事实是,不管是否使用 this()都会先执行实例块,再进入构造方法。另外,本程序需要在sdk1.4下编译,在sdk1.3下编译将不允许在静态块或实例块中改变位置在它们后面声明的域的值。
*使用移位操作(见org.apache.hadoop.io.MD5Hash类中的halfDigest方法)
<code java>
public long byteArrayToLong(byte[] digest){
			long value = 0;
		    for (int i = 0; i < 8; i++)
		      value |= ((digest[i] & 0xffL) << (8*(7-i)));
		    return value;
}
public byte[] longToByteArray(long value){
			byte[] res = new byte[8];
			for(int i=0; i<8; ++i){
				res[7-i] = (byte)(value>>>i*8); 
            }
            return res;
}
</code>
*使用ByteArrayInputStream、ByteArrayOutputStream、DataInputStream和DataOutputStream
见[[这里|http://www.coderanch.com/t/378647/java/java/convert-long-byte-array-back]]
<code java>
ByteArrayOutputStream bos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(bos);
dos.writeLong(10L);
dos.writeInt(-4);
// etc.
dos.flush();
byte[] data = bos.toByteArray();
</code>
minix中函数原型定义是用如下代码形式进行声明(见kernel/main.c):
>FORWARD _PROTOTYPE( void announce, (void));
>FORWARD _PROTOTYPE( void shutdown, (timer_t *tp));
其中FORWARD是minix定义的宏(include/minix/const.h),暂不管
对于_PROTOTYPE这种C中没有的关键字,其实早该想到是宏,它的定义是在include/ansi.h中:
>#ifdef _ANSI
>/* Keep everything for ANSI prototypes. */
>#define _PROTOTYPE(function, params) function params
>#define _ARGS(params)    params
>
>#else
>/* Throw away the parameters for K&R prototypes. */
>#define _PROTOTYPE(function, params) function()
>#define _ARGS(params)    ()
可以看出,实际上 ''_PROTOTYPE( void announce, (void));'' 就相当于 '' void announce (void);'',放在文件头即相当于函数原型的声明。

在实际编程中,也可以参照此法,自己定义一个 _PROTOTYPE( function, params) function params这样的宏,以便函数原型的统一管理。

再看一个minix中更复杂的例子,但原理是一样的(/servers/pm/table.c):
>{{{_PROTOTYPE (int (*call_vec[NCALLS]), (void) ) = {}}}
>{{{	no_sys,		/*  0 = unused	*/}}}
>{{{	do_pm_exit,	/*  1 = exit	*/}}}
>{{{	do_fork,	/*  2 = fork	*/}}}
>{{{	no_sys,		/*  3 = read	*/}}}
>{{{            ... ...}}}

其实这个就相当于:
>{{{int (*call_vec[NCALLS]) (void)  = {}}}
>{{{	no_sys,		/*  0 = unused	*/}}}
>{{{	do_pm_exit,	/*  1 = exit	*/}}}
>{{{	do_fork,	/*  2 = fork	*/}}}
>{{{	no_sys,		/*  3 = read	*/}}}
>{{{            ... ...}}}
关于(*call_vec[NCALLS]) (void)的理解,详见[[西邮wiki|http://www.xiyoulinux.cn/wiki/index.php?title=%E6%B7%B1%E5%85%A5C%E8%AF%AD%E8%A8%80#.E6.B7.B1.E5.85.A5.E7.90.86.E8.A7.A3C.2FC.2B.2B.E6.8C.87.E9.92.88]]
所以,这里声明的就是一个数组,数组里的东西是指向函数的指针,即指向no_sys,do_fork这些东西,所以这里的_PROTOTYPE()的作用就不是声明函数原型了,而就是用来声明一个指针数组。

''Reference: ''[[here|http://hi.baidu.com/shirdrn/blog/item/c3f6d3daca25c1ddb7fd4843.html]]
只要记住一个公式就行了:
>''nCr = (n-r+1/r) * nCr-1''
>''nC0 = 1''
>>其中n是行数,0,1,2,3...;r是每行中的列数,0,1,2,3....
''简单来说'',每行中的数(除了第一个)是他前面那个数的''(n-r+1)''倍;

参考:Algorithm Gossip
参考:
>1. [[Python Doc|file:///I:/STUDY/CODE/Python/python-2.6.2-docs-html/library/index.html]]
!!!正则表达式
1.{{{(?P<name>...)}}}语法,详见参考1;
2.{{{\w}}}和{{{\W}}}与''LOCAL''和''UNICODE'' flag有关,见参考1;
3.{{{re.search(r'(\d)+', '12345').group(1)}}}和{{{re.search(r'(\d+)', '12345').group(1)}}}的区别
>前者子组1中的数据不断被替换,开始时'1',然后'2',最后是'5'(详见《Python核心编程P461》)
4. ''贪婪匹配''和''非贪婪匹配''(详见《Python核心编程P462》)
5. {{{re.findall}}}返回的是groups()的list,list中的每个元素师每个匹配的groups,详见参考1和以下测试:
>{{{print re.findall(r'(\d)+', '12345a6789')}}}
6. group(),groups()
>''group() == group(0)'', return the whole match
>''group(N)'', return group N
>''group(N1, N2, N3....)'', return a list of n groups (N1st, N2nd, N3rd....)
>''groups()'', return a list of all groups
!!!other
1. raw_input省去''linesep'',readline()和readlines()保留''linesep''
2. ''拷贝''(deepcopy&shallowcopy)
* shallowcopy发生的条件:
** take a ''complete'' slice(''[:]'')
** using a ''factory function''(''list()''''dict()'')
** using ''copy()'' function in copy module
*deepcopy发生的条件:copy.deepcopy()
*注意:
>shallowcopy只对''mutable''的变量有效,而对于''immutable''的变量如''原子变量''(如string, int等),''tuple''等无效
>详见《Core Python Programming 2ed》英文版 6.20章节
3.''python多线程''
*[[threading模块]] 原文在[[这里|http://blog.chinaunix.net/u3/93470/showart_2203387.html]]
*相关例子:[[Thread|http://linhs.blog.51cto.com/370259/126180]], [[Semaphore|]]
4.''python国际化''
5.''with_statement''
>''with''语句的具体原理(流程):[[Python的with关键字|http://www.phpfans.net/forum/viewthread.php?tid=98585]]
>文件操作中的with:《The Python Library Reference》6.9小节
6.Iterator, generator, Iterable
*[[Iterators, Iterables, and Generators! Oh, my!|http://www.learningpython.com/2009/02/23/iterators-iterables-and-generators-oh-my/]]
*Python官方文档中:Iterator,Generator,Iterable
*[[The Python yield keyword explained|http://stackoverflow.com/questions/231767/the-python-yield-keyword-explained]]
*本地思维导图


参见''gettext''模块
单下划线(自动翻译成local指定的语言):见[[Python中的单下划线'_'漫谈|http://blog.sina.com.cn/s/blog_54ce569c01009orr.html]]

一些''内建的函数''
>range,type,str,dir,callable,getattr,lambda
其他''函数''和''变量''
>random.randint(), sys.maxint, date.ctime(),string.lowercase, random.choice(), string.strip(), 
基本规则:
{{{VC规定各成员变量存放的起始地址相对于结构的起始地址的偏移量必须为该变量的类型所占用的字节数的倍数。}}}''@@color(red):见第一例@@''
{{{同时VC为了确保结构的大小为结构的字节边界数(即该结构中占用最大空间的类型所占用的字节数)的倍数,所以在为最后一个成员变量申请空间后,还会根据需要自动填充空缺的字节。}}}''@@color(red):见第二例@@''
|!类型|!对齐方式(变量存放的起始地址相对于结构的起始地址的偏移量)|
|char|''偏移量''必须为sizeof(char)即1的倍数|
|short|''偏移量''必须为sizeof(short)即2的倍数|
|int|''偏移量''必须为sizeof(int)即4的倍数|
|float|''偏移量''必须为sizeof(float)即4的倍数|
|double|''偏移量''必须为sizeof(double)即8的倍数|
''一句话:''struct的对齐一般是保证下一个成员的偏移位置为该成员大小的整数倍。   
''具体例子1:''
 {{{    struct MyStruct   {     double dda1;    char dda;       int type;   };}}}
为上面的结构分配空间的时候,VC根据成员变量出现的顺序和对齐方式,依次分配。

''(1)''先为第一个成员dda1分配空间,其起始地址跟结构的起始地址相同,刚好偏移量0刚好为sizeof(double)的倍数,该成员变量占sizeof(double) =8个字节;
''(2)''接下来为第二个成员dda分配空间,这时下一个可以分配的地址对于结构的起始地址的''偏移量''为8,是sizeof(char)的倍数,所以把dda存放在偏移量为8的地方满足对齐方式,该成员变量占用sizeof(char)=1个字节;
''(3)''接下来为第三个成员type分配空间,这时下一个可以分配的地址对于结构的起始地址的''偏移量''为9,不是sizeof(int)=4的倍数,为了满足对齐方式对偏移量的约束问题,VC自动填充3个字节(这三个字节没有放什么东西),这时下一个可以分配的地址对于结构的起始地址的偏移量为12,刚好是=4的倍数,所以把type存放在偏移量为12的地方,该成员变量占用sizeof(int)=4个字节;、
''(4)''这时整个结构的成员变量已经都分配了空间,总的占用的空间大小为:8+1+3+4=16,刚好为结构的字节边界数(这个应该是和下面提到的''对齐系数''有关,用#pragma pack(n)指定)的倍数,所以没有空缺的字节需要填充。
''(5)''所以整个结构的大小为:sizeof(MyStruct)=8+1+3+4=16,其中有3个字节是VC自动填充的,没有放任何有意义的东西。

''具体例子2:''
{{{   struct MyStruct   {char dda;      double dda1;    int type;   };}}}

这个结构占用的空间为多大呢?在VC6.0环境下,可以得到sizeof(MyStruc)为24。结合上面提到的分配空间的一些原则,分析下VC怎么样为上面的结构分配空间的。(简单说明)
''struct MyStruct {char dda;''
/*偏移量为0,满足对齐方式,dda占用1个字节;*/
''double dda1;''
/*下一个可用的地址的偏移量为1,不是sizeof(double)=8的倍数,需要补足个字节才能使偏移量变为(满足对齐方式),因此VC自动填充7个字节,dda1存放在偏移量为8的地址上,它占用8个字节。*/
''int type;''
/*下一个可用的地址的偏移量为16,是sizeof(int)=4的倍数,满足int的对齐方式,所以不需要VC自动填充,type存放在偏移量为的地址上,它占用4个字节。*/
''};''
所有成员变量都分配了空间,空间总的大小为1+7+8+4=20,不是结构的''节边界数''(即结构中占用最大空间的类型所占用的字节数sizeof(double)=8)的倍数,所以需要填充4个字节,以满足结构的大小为sizeof(double)=8的倍数。所以该结构总的大小为:sizeof(MyStruc)为1+7+8+4+4=24。其中总的有7+4=11个字节是VC自动填充的,没有放任何有意义的东西。

同时,每个特定平台上的编译器都有自己的默认''对齐系数''(也叫对齐模数)。程序员可以通过预编译命令''#pragma pack(n)'',n=1,2,4,8,16来改变这一系数,其中的n就是你要指定的“对齐系数”。([[来源|http://bbs.chinaunix.net/viewthread.php?tid=955085]])

    VC中提供了''#pragma pack(n)''来设定变量以n字节对齐方式。n字节对齐就是说变量存放的起始地址的偏移量有两种情况:第一、如果n大于等于该变量所占用的字节数,那么偏移量必须满足默认的对齐方式,第二、如果n小于该变量的类型所占用的字节数,那么偏移量为n的倍数,不用满足默认的对齐方式。''结构的总大小也有个约束条件'',分下面两种情况:如果n大于所有成员变量类型所占用的字节数,那么结构的总大小必须为占用空间最大的变量占用的空间数的倍数;否则必须为n的倍数。下面举例说明其用法。
{{{  #pragma pack(push)    }}}/*保存对齐状态*/

{{{  #pragma pack(4)   }}}/*设定为4字节对齐*/

{{{  struct test{char m1;double m4;int m3;};   }}}

{{{  #pragma pack(pop)   }}}/*恢复对齐状态*/
    以上结构的大小为16,下面分析其存储情况,首先为m1分配空间,其''偏移量''为0,满足我们自己设定的对齐方式(4字节对齐),m1占用1个字节。接着开始为m4分配空间,这时其偏移量为1,需要补足3个字节,这样使''偏移量''满足为n=4的倍数(因为n小于sizeof(double)),m4占用8个字节。接着为m3分配空间,这时其偏移量为12,满足为4的倍数,m3占用4个字节。这时已经为所有成员变量分配了空间,共分配了16个字节,满足为n的倍数。如果把上面的#pragma pack(4)改为#pragma pack(16),那么我们可以得到结构的大小为24。([[来源|http://blog.pfan.cn/xman/38666.html]])

总之,对齐是为了加快CPU的运行速度。
首先看一下threading模块中的对象:
>   Thread:表示一个线程的执行的对象
>   Lock:锁原语对象
>   RLock:可重入锁对象。使单线程可以再次获得已经获得的锁
>   Condition:条件变量对象能让一个线程停下来,等待其他线程满足了某个“条件”,如状态的改变或值的改变
>   Event:通用的条件变量。多个线程可以等待某个事件发生,在事件发生后,所有的线程都被激活
>   Semaphore:为等待锁的线程提供一个类似“等候室”的结构
>   BoundedSemaphore :与semaphore类似,只是它不允许超过初始值
>   Timer:与Thread类似,只是,它要等待一段时间后才开始运行


其中Thread类是主要的运行对象,它有很多函数,常用的为以下三种。
>   创建一个Thread的实例,传给它一个函数
>   创建一个Thread实例,传给它一个可调用的类对象
>   从Thread派生出一个子类,创建一个这个子类的实例


Thread类的函数有:
>     | getName(self) 返回线程的名字
>     | isAlive(self) 布尔标志,表示这个线程是否还在运行中
>     | isDaemon(self) 返回线程的daemon标志
>     | join(self, timeout=None) 程序挂起,直到线程结束,如果给出timeout,则最多阻塞timeout秒
>     | run(self) 定义线程的功能函数
>     | setDaemon(self, daemonic) 把线程的daemon标志设为daemonic
>     | setName(self, name) 设置线程的名字
>     | start(self) 开始线程执行
如果机器无法直接访问外网,比如在学校,需要添加代理。

网上有很多解决方案,却都没完全解决问题:
*在~/.bashrc中添加:
>https_proxy=http://[username:password@]www.proxy.com:port/
>http_proxy=http://[username:password@]www.proxy.com:port/
*在/etc/apt/apt.conf中添加:
>Acquire::http::Proxy "http://[username:password@]www.proxy.com:port/";
>Acquire::http::Proxy "http://[username:password@]www.proxy.com:port/";

主要的问题是在进行apt-get或add-apt-repository都是需要sudo的,而sudo看的是root用户的环境变量,所以不看~/.bashrc中环境变量;同时,至少在10.04版本,/etc/sudoers文件中有一行”Defaults env_reset“,它会让sudoer忽略当前用户的环境变量,这其实是该版本的一个[[bug|https://bugs.launchpad.net/ubuntu/+source/software-properties/+bug/516032]]
正确的做法是:
*首先,如上在~/.bashrc中添加https_proxy和http_proxy;
*其次,参考该[[帖子|http://askubuntu.com/questions/53146/how-do-i-get-add-apt-repository-to-work-through-a-proxy]],对所有sudo命令加上''-E''参数,告诉sudo忽略''Defaults env_reset''(参考sudo的man),考虑当前的环境变量,如:
>sudo -E apt-add-repository ppa:linaro-maintainers/toolchain
>sudo -E apt-get update
*然而,如果通过apt-add-repository加了一个新的源,在‘’apt-get update‘’后会出现类似“''{{{GPG error...NO_PUBKEY E635A714505A2DD1}}}''“的错误,参考这个[[帖子|http://stream-recorder.com/forum/w-gpg-error-http-ppa-launchpad-net-t6741.html?s=21750c4fa5bba92d940e8f00325b9ed7&amp;]],运行如下命令(505A2DD1是出错信息中key的最后8位):
>gpg {{{--}}}keyserver keyserver.ubuntu.com {{{--}}}recv 505A2DD1
>gpg {{{--}}}export {{{--}}}armor 505A2DD1 | sudo apt-key add -
shingling with a fixed length sliding window avoids the alignment problem between two documents with minor differences
变长Chunk方法能够增加系统招回率
!url转义字符原理

如果表单的action为list.jsf?act=go&state=5

则提交时通过request.getParameter可以分别取得act和state的值。

如果你的本意是act='go&state=5'这个字符串,那么为了在服务端拿到act的准确值,你必须对&进行转义

[''预备知识'']
 
        对与通过get方式提交的url,浏览器在提交前首先根据http协议把一一个的参数及其值解析配对。而url的参数间是通过&分割的,这就是浏览器进行参数配置的分割依据。如果你的参数值中含有&等url特殊字符,那么你在服务器端就会拿到意想不到的值。所以必须对url的特殊字符进行转义。
编码的格式为:%加字符的ASCII码,即一个百分号%,后面跟对应字符的ASCII(16进制)码值。例如 空格的编码值是"%20"。
下表中列出了一些URL特殊符号及编码
 

[''十六进制值'']
>1. ''+''  URL 中+号表示空格 ''%2B''
>2. ''空格'' URL中的空格可以用+号或者编码 ''%20''
>3. ''/''  分隔目录和子目录 ''%2F'' 
>4. ''?''  分隔实际的 URL 和参数 ''%3F'' 
>5. ''%'' 指定特殊字符 ''%25'' 
>6. ''#'' 表示书签 ''%23'' 
>7. ''&'' URL 中指定的参数间的分隔符 ''%26'' 
>8. ''='' URL 中指定参数的值 ''%3D''
所以上述的action你应该写成list.jsf?act=go%26state=5
''附:''
|!字符|!URL编码值|
|空格|%20|
|"|%22|
|#|%23|
|%|%25|
|&|%26|
|(|%28|
|)|%29|
|+|%2B|
|,|%2C|
|/|%2F|
|:|%3A|
|;|%3B|
|<|%3C|
|=|%3D|
|{{{>}}}|%3E|
|?|%3F|
|@|%4o|
|\|%5C|
|{{{|}}}|%7C|
!!!resize
它改变的是有效数据的多少,即改变了size()返回的值:
>如果原来有元素:''{5,2}'',则它的size为2; 经过resize(5),它的元素将变为:''{5,2,0,0,0}'',而size变成了5,说明把后面的三个0都当作有效数据了
>所以,''resize''既改变了capacity,又改变了size;

!!!reserve
它改变的只是vertor的''capacity'',即容量,而不改变它的有效数据,即''不改变size''
*VIM 折叠和展开
>''V'',选中若干行,按''zF''折叠。
*VIM 分割窗口
>{{{:split <filename>}}}
>>按拆分模式打开文件,默认为上下拆分
>{{{:vsplit <filename>}}}
>>左右拆分
>{{{Ctrl-w w}}}
>>切换活动窗口
>{{{Ctrl-w Ctrl-w}}}
>>同上
>{{{Ctrl-w h/j/k/l}}}
>>切换活动窗口为 左/上/下/右 边的窗口
!!!目标:美观,高效
基本上参照这篇文章[[面向前端开发者和TextMate粉丝的vim配置|http://www.limboy.com/2009/05/30/vim-setting/#more-230]]
其中,''我的资源都在QQ邮箱的"网盘-linux"tag中'';下面的我不同于此教程之处:
*''主题''
>我使用的是''crt''或者''thestars''(与他的''yytextmate''基本相似)
*语法着色
>如果是正常安装VIM的,那么在''/usr/share/vim/vim71/syntax''目录下会有超多的配色文件,基本上全了;
>如果没有,可尝试完全安装:''sudo apt-get install vim-full''
>如果对现有的着色文件不满意,可替换(如那篇文章中说的html和javascript),可从[[这个网站|http://www.fleiner.com/vim/download.html]]下
*''插件''
>插件管理
>>默认插件文件分散在跟个目录,卸载麻烦
>>按照[[How I boosted my Vim|http://nvie.com/posts/how-i-boosted-my-vim/]]所介绍的pathogen插件可解决这个问题
>缩进
>>按照文章上说的设置
>bash support
>>我的资源中已配置好
>snippet
>>暂时没有很强烈的需求,暂不配置
>自动补全
>>参见[[这篇文章|http://hi.baidu.com/xydream/blog/item/fefaad38142055cbd462252a.html]]
>>默认可以用Ctrl+P或Ctrl+N来自动补全,但不能''实时过滤'',参见上面文章解决方案:
>>1、安装[[SuperTab|http://www.vim.org/scripts/script.php?script_id=1643]]插件
>>2、下载[[AutoComplPop|http://www.vim.org/scripts/script.php?script_id=1879]]插件(注意:它只支持7.0版本的VIM;测试下来它不装也无大碍),然后根据[[这篇文章|http://hi.baidu.com/walkandsing/blog/item/e2a3e20362577e8ad43f7c17.html]]下载并配置各语言的自动补全,上面提到的几种语言的complete文件在[[这里|http://mikael.jansson.be/hacking/limp/browser/vim-ecl/7.2/runtime/autoload?rev=367]]都有下;
>>这样需求就都满足了:@@color(blue):''自动弹出''、''实时过滤''、''基本的API帮定''@@
>文件项目管理
>>目录树:照那片文章下载,然后[[这里|http://blog.chinaunix.net/u2/72494/showart_1915745.html]]是用法
>>Buffer Explorer:打开多个文件是比较有用,见[[这里|http://hi.baidu.com/geniusfox/blog/item/57df1912b3934556f919b85d.html]]介绍

!!!一些配置
''set list''
>显示文件中的非打印字符,如换行符等等
''set fileformats=unix, dos, mac''
>选择文件的格式,根据文件的一些特征vim会自动选择(如结尾是不是^M(<Ctrl+V>,<Ctrl+M>));如果文件格式选择的是dos,这时即使行末尾是^M,使用''set list''命令也不会显示出^M来,需要转换成unix格式的;
wine 完全使用指南
from Linux开源系统 by jackcfan

wine-logo一直苦于没有一篇像样的使用指南,原来外国有朋友跟我有同感,既然他捷足先登了,那我只好翻译了。原文作者说会保持更新,这篇文章是很新的,介绍了很多实用的Wine设置方法,非常全面,无论新手还是老鸟都值得一读。

我收集到的关于Wine的一些资料

如果你像我一样的话,当你第一次使用Wine的时候,就会被Wine的帮助文章现状所困扰。互联网上确实有很多的HOWTO文章来教你使用一些程序或游戏,但是我找不到一个全面的“Wine初学者教程”来让我真正懂得实际了解和使用Wine所需的基本知识。我不需要一个教我如何运行半条命2的文章,我需要的是一篇能实实在在教我怎样使用Wine的文章。最后,我整理了从众多的Wiki、指南、帖子和HOWTO搜集来的资料,写成这篇文章。虽然这篇文章主要针对在Wine下运行游戏,但是它包括的几乎所有的信息都可以应用到用Wine来运行其它的程序。

!!1.一般资料

!!!1.1Wine is not an emulator

这个我就不翻译了,没有多少技术介绍。

!!!1.2使用最新的Wine

记住最新版的Wine会包含一些旧版本里没有的bug。在feisty的软件仓库里包含了0.9.33,而最新的Wine是0.9.44(我翻译文章时)。0.9.33更加稳定,但是最新的版本包含重大的DirectX改进。有一些不能在0.9.33下运行的游戏能够在0.9.44中很好地运行。在使用0.9.37到0.9.40之间的某些版本运行KotOR2时,声音在我的系统上崩溃了。那是最好的有关使用最新版导致棘手问题的好例子。

(译者:我个人还是推荐使用最新版,使用新版本会有更好的运行速度,而且基本上每个bug都会在未来的2~3个版本中被修复)

!!!1.3不要从源码编译安装Wine

(译者:作者没有说为什么,可能是因为编译要解决的依赖性问题太多了。

我个人还是推荐编译安装,这样安装完后问题少一点,性能好一点。)

!!!1.4使用终端

如果正确安装的话,wine会把它自己关联到exe文件,所以你只要双击exe文件就可以运行。无论怎样,这都不是我们所推荐的使用wine的方法(译者:我也不推荐)。使用终端会比较好,因为这样可以正确地设定程序的路径,否则程序就会找不到所需要的文件。另外,使用终端还可以显示出错误信息,这对于解决问题是非常有用的。

!!!1.5准备对付挫折

Wine并不完美。不会所有的事情都能顺利发展,有时候甚至需要你自己去解决问题。但你现在是一个linux用户了,你就要准备着去应付。

!!2.“winecfg”的使用资料

!!!2.1运行“winecfg”

你至少需要运行一次winecfg来设置wine的目录和硬件。

!!!2.2虚拟桌面

使用这个选项可以使软件的安装更加流畅。我发现在不使用这个选项的时候,使用某些程序会导致已经激活的对话框、CDKEY输入窗口或更换光盘的确认窗口不能出现在前端。让我以为程序卡死了,就kill掉了进程。选择这个选项还能够避免程序锁死你的桌面或者把你的屏幕分辨率改成难看的模式。

!!!2.3使用Application Settings

你可以在winecfg的Application标签里的Application Settings对话框对个别的程序进行自定义设置。那里只允许你进行windows兼容运行模式设置(译者:像windows下的exe属性里的兼容性标签)、某些显示设置和DLL的设置。

当你只需要设置某个程序使用某些特定的windows自带的DLL,不希望其它程序(包括wine)使用这些native的DLL的时候(而其它程序使用这些DLL会导致问题),(译者:wine自带的DLL叫做builtin,windows下原生的DLL叫做native)这个选项就会变得十分有用。在进行DLL设置时我都用这个方法,就是为了防止某些对wine的运行存在潜在威胁的nativeDLL被wine调用(译者:在一般情况下, wine只调用自带的builtinDLL,而不会使用native的DLL,版权问题,除非经过设置,如上所述)。这样我就只是修改了那些可执行的配置文件,当我不需要时,可以改回来而不会损坏整个Wine。(译者:设置这些东西之前,保证已经将一个程序的exe文件添加到Application标签的白框中,并且反色选中。不是default的那个,是你所需要设置的那个exe文件。)

!!!2.4Windows版本

对不同的程序尝试不同的Windows版本。这就是说一个为了XP而设计的游戏可能会在wine的98模式的支持下能更好地运行。在做这个之前确认你已经把程序添加到Application的白框中,并且选中,反色显示。

!!!2.5使用ALSA驱动

有些游戏是需要OSS才能运行,但是OSS已经不会再继续开发了。

(译者:推荐只是独立声卡使用ALSA,集成的还是使用OSS最好)

!!!2.6不要总是选择allow the window manager to control the windows(winecfg里的)

使用这个选项有时候会使游戏在全屏幕运行时出现问题。当前的wine版本0.9.39+已经修正了多数游戏的全屏问题,但是引入了一个新的问题:当不使用这个选项时,会使键盘不能游戏中输入。在使用一个单独的X server来运行游戏时,这个问题可以得到解决。(见“高级设置资料”)

!!!2.7谨慎对待DLL

winecfg可以让你用native的DLL替换builtin的DLL。下面的这些DLL是绝对不能被替换的。kernel32.dll, gdi32.dll,user32.dll,和ntdll.dll。有些nativeDLL也可能使一些程序不能运行。记得永远不要覆盖wine自带的 dll,如果native的用不了就用builtin的换回来。有些MS的DLL要得到许可才能用,如果你没有许可,就不要用。

!!3.特殊配置资料

!!!3.1建立一个到CD的链接

Wine会建立一个到你挂载CD的文件夹的链接,但是建立一个到真正的/dev里的设备的链接会更好。我发现如果不这样做,Wine会自己建立到 /dev的链接,把CD认成E:盘,而我的挂载目录却链接为D:盘。我认为这个可能会导致某些使用CD安装的程序出现问题。修改/dev/hdc以适应你的系统(译者:7.04一般都是/dev/scd0)。

ln -s /dev/hdc ~/.wine/dosdevices/d\:\:

!!!3.2实用注册表键值

有些设置是不能通过winecfg来进行设置的,但是可以在注册表中进行设置。在wine的wiki中有一篇保持更新的文章

http://wiki.winehq.org/UsefulRegistryKeys

有两个键值是非常有用的,一个是Alsa Driver的UseDirectHW,可以解决一些声音跳顿的问题;还有Direct3D的VideoMemorySize,你应该设置成你的显卡的准确显存,默认wine会设置成64MB。

!!!3.3WINEPREFIXCREATE

这个我暂时不翻译

!!!3.4安装Wine Gecko IE engine

有些程序的运行依赖于IE,但是,安装IE会严重地破环Wine。所以可以安装Wine Gecko IE engine作为替代品。

a、在终端下运行下面的命令:

>''wine iexplore http://www.winehq.org''

b、当出现安装提示时回答yes

c、打开http://wiki.winehq.org/UsefulRegistryKeys,找到HKEY_LOCAL_MACHINE板块

d、把所有有关Internet Explorer的键值加到注册表中

安装完成后,运行

>''wine iexplore http://www.winehq.org''

成功的话就会出现winehq的主页。

!!!3.5中文支持设置

把下面的代码保存为zh.reg,然后终端执行regedit zh.reg。从Windows目录下的Fonts里的simsun.ttc复制到/home/user/.wine/drive_c/windows/fonts里面。

REGEDIT4
[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\FontSubstitutes]
“Arial”=”simsun”
“Arial CE,238″=”simsun”
“Arial CYR,204″=”simsun”
“Arial Greek,161″=”simsun”
“Arial TUR,162″=”simsun”
“Courier New”=”simsun”
“Courier New CE,238″=”simsun”
“Courier New CYR,204″=”simsun”
“Courier New Greek,161″=”simsun”
“Courier New TUR,162″=”simsun”
“FixedSys”=”simsun”
“Helv”=”simsun”
“Helvetica”=”simsun”
“MS Sans Serif”=”simsun”
“MS Shell Dlg”=”simsun”
“MS Shell Dlg 2″=”simsun”
“System”=”simsun”
“Tahoma”=”simsun”
“Times”=”simsun”
“Times New Roman CE,238″=”simsun”
“Times New Roman CYR,204″=”simsun”
“Times New Roman Greek,161″=”simsun”
“Times New Roman TUR,162″=”simsun”
“Tms Rmn”=”simsun”

!!4.安装资料

!!!4.1不要在CD的目录下安装程序

(译者:就是不要cd到CD的挂载目录运行安装程序)

如果这样做的话,就会在换CD时出现CD不能推出的问题,用下面的命令来安装CD:

wine /media/cdrom0/setup.exe

!!!4.2需要用到“wine eject”

如果安装程序需要你换CD,而系统却说不能推出CD,那就打开一个新终端,输入:

wine eject d:

!!!4.3安装InstallShield的bug补丁

安装http://support.installshield.com …… 2/IkernelUpdate.exe

这个补丁可以解决一些CD安装问题。

!!!4.4使用uninstaller

使用命令“uninstaller”来卸载安装的程序,不要使用程序在菜单里面创建的卸载快捷方式,他们有时候不能正常工作,而uninstaller可以。

!!!4.5安装.msi文件

有些windows的安装程序是使用msi来安装的,那就用下面的命令来安装:

>''wine msiexec /i install.msi''

或者

>''wine start install.msi''

!!!4.6不要安装DirectX

Wine有它自己的DirectX库,安装微软的DirectX会破坏wine的DirectX库和Wine。

但是,d3dx9_##.dll和d3dx10_33.dll可以从Windows复制过来使用,可能会在启动某些游戏时有所帮助。使用这些dll你需要微软的授权证书。

!!5.一般使用资料

!!!5.1如何用wine来运行程序

wine application.exe

!!!5.2运行程序前cd到程序的安装目录

cd到程序的安装目录再运行程序。

!!!5.3关掉WINEDEBUG

一般情况下,wine会不断地产生一些debug信息(那些“fixme”的东西)。那些信息在很多情况下是没有用的,尤其你已经可以正常地运行一个程序。你可以使用下面的命令来避免debug信息,节省资源:

>''WINEDEBUG=-all game.exe''

!!!5.4不要使用root或者sudo来运行wine

可能会损坏系统文件。

!!!5.5其他wine的命令

wineboot 模拟windows的重新启动

wine control 运行控制面板

wineserver wineserver会随着wine的命令自动启动,但也能通过终端启动来达到不同的目的。

wineserver的一些参数

a、-d# 设置终端中debug的显示级别。

b、-h 显示wineserver帮助文件

c、-k kill掉当前的wineserver,当程序失去响应而你要结束它时使用。

d、-p 让wineserver一直运行,也就是说即使程序退出了,wineserver还继续运行。当你需要运行连续的程序时可以使用,这样可以缩短程序的启动时间。

e、-w 让wineserver一直运行直到当前已激活的wineserver退出。

!!!5.6让Wine运行更流畅

当出现程序运行缓慢或性能起伏不定的问题时,可以通过提高进程的优先级来解决。启动游戏后,可以使用“renice”命令来改变进程的优先级。 “renice”命令可以改变当前进程的优先级,“nice”的值是优先级级别的标志,(高优先级=低nice值,低优先级=高nice值)。这个命令把程序优先级的值设置为从-20(最高优先级)到19(最低优先级)之间的任何一个整数值,而默认的值是0。在启动游戏以后,你需要打开另外一个终端输入下面的命令来改变程序的优先级:

>''sudo renice -10 -n game.exe''

在用Wine运行游戏时,我不推荐直接把程序的优先级设置到-20,最好是从-10开始,如果效果提升不明显,可以一步步尝试小幅度的提高(- 11,-12,……)。你会发现绝大多数的游戏不需要比-10更高的优先级就已经可以达到最好的性能了。不用多说(我认为),在游戏中你可以用ALT- TAB组合键回到桌面使用“renice”命令。

第二种方法

使用图形界面来设置优先级。

1、 用终端运行游戏,按ALT-TAB回到桌面

2、 系统——>系统管理——>系统监视程序,切换到进程标签

3、 在进程上点右键——更改优先权

4、 要求密码时输入

5、 关闭系统监视程序,用ALT-TAB回到游戏

#!/bin/sh
#uncomment if launching from console session
#sudo /etc/init.d/gdm stop
#KDE use this instead
#sudo /etc/init.d/kdm stop
# Launches a new X session on display 3. If you don’t have an Nvidia card
# take out the “& nvidia-settings –load-config-only” part
X :3 -ac & nvidia-settings –load-config-only
# Goto game dir (modify as needed)
cd “$HOME/.wine/drive_c/Program Files/Game/Directory/”
# Forces the system to have a break for 2 seconds, X doesn’t launch instantly
sleep 2
# Launches game (modify as needed)
DISPLAY=:3 WINEDEBUG=-all wine “C:/Program Files/Game/Directory/game.exe”

!!6.第三方软件资料

!!!6.1 WineTools

WineTools是一个菜单式的可以安装90多个常见Windows程序的软件。它也可以帮助你设置Wine的基本目录。已经不再有人维护 WineTools,它已经两年没有升级了,但很多用户都发现它依然有用。而WineTools所作的一切事情都可以自己通过winecfg或终端完成。

!!!6.2Wine-Doors

Wine-Doors是一个帮助你安装很多的Windows程序,包括游戏的一个图形界面的软件。它现在还处在开发阶段,但已经发布了一个可以下载的最初版本。就这个软件看来,是非常有前途的。

!!!6.3Cedega

Cedega就技术上来说是Wine的一个分支,它明确地针对于游戏。cedega包含了一个安装和运行游戏的图形界面,还加上了对受防拷贝保护的软件的支持(不需要使用破解来免CD)(译者:wine的对防拷贝的支持不是很好)。cedega不适免费的,最低消费是购买3个月,每月3美元,如果预付一年的费用的话,可以享受一点折扣。cedega从前叫做WineX,在Wine还是MIT软件,而不是现在的GPL的时候,WineX就从wine的一个分支分离出来,就因为cedega不属于GPL,cedega不再对wine的代码发展作贡献了。再加上cedega缺少支持,很多人便不再用 cedega 在linux下玩游戏。

!!!6.4CrossOver

CrossOver从技术上来说,CrossOver不是wine的一个第三方产品,而是wine的主要财力支持者。CrossOver一开始是以在linux下运行Microsoft Office软件为目标的,但最近它开始添加对游戏的支持。CrossOver基于一个更老,更稳定的Wine版本(译者:好像是0.9.17),但 CrossOver也随着Wine一起升级。CrossOver标准版的售价是39.95美元。

!!!6.5ReactOS

正如CrossOver一样,ReactOS也是Wine的一个支持者,基于许多Wine已经完成的成果,它致力于建立一个能与Windows完全兼容的操作系统。完成后,ReactOS能够使用Windows的驱动程序和软件,完全兼容。这项计划还处于开发阶段,但已经可以提供安装CD、 LiveCD、QEMU和VMware镜像的下载。

!!7.高级设置资料

!!!7.1使用启动脚本(使用之前确保游戏能够正常运行)

再使用单独得X server时,很多游戏一般都可以发挥出他们最佳性能。wine不需要窗口管理器(GNOME或KDE)就可以正常地运行,所以如果你在一个单独的X server下运行游戏,你会得到明显的性能提升。在运行游戏之前,关闭GDM或KDM,还会得到更大的性能提升(只能通过控制(console)台来实现)。

a、首先,在终端下建立一个脚本

>''nano launcher.sh(可以用vim替换nano)''

b、复制下面的文字到终端里。如果你没有nVidia的显卡,就删除nvidia settings的那部分,然后用你的游戏的正确路径替换里面的路径

#!/bin/sh
#uncomment if launching from console session
#sudo /etc/init.d/gdm stop
#KDE use this instead
#sudo /etc/init.d/kdm stop
# Launches a new X session on display 3. If you don’t have an Nvidia card
# take out the “& nvidia-settings –load-config-only” part
X :3 -ac & nvidia-settings –load-config-only
# Goto game dir (modify as needed)
cd “$HOME/.wine/drive_c/Program Files/Game/Directory/”
# Forces the system to have a break for 2 seconds, X doesn’t launch instantly
sleep 2
# Launches game (modify as needed)
DISPLAY=:3 WINEDEBUG=-all wine “C:/Program Files/Game/Directory/game.exe”

c、把文件保存到你的主文件夹(保存Ctrl+O,退出Ctrl+X。Vim的话先Esc,再Shift+:,保存w,退出q)

d、然后,给你的脚本加上可执行属性

>''chmod +x ~/launcher.sh''

e、运行脚本

>''sh launcher.sh''

或

>''./launcher.sh''

f.结束游戏后,用CTRL-ALT-BACKSPACE回到桌面

第二种方法

如果你的游戏不能运行或者只是单纯想压榨出更好的游戏性能,跟着下面的步骤尝试在关闭X session的情况下运行游戏。

a、取消注销“sudo /etc/init.d/gdm stop”语句(删除#)后保存,如果你是使用KDE,就取消注销“sudo /etc/init.d/kdm stop”。

b、关闭所有程序,按CTRL-ALT-F1打开控制台

c、在控制台登陆并运行这个脚本。你会被要求输入密码,然后游戏会在它自己的X session里运行,而没有GDM或KDM的妨碍。

d、如果脚本显示你没有启动X session的权限,就修改那个脚本

按照这样修改X server的启动语句

>''sudo X :3 -ac & nvidia-settings ——load-config-only''

注意:为了避免修改脚本,你可以修改Xwrapper.config给与一般用户启动X的权限。用sudo vim打开/etc/X11/Xwrapper.config,把allowed_users=console修改为allowed_users=anybody。

e、结束游戏后,可以重启或CTRL-ALT-BACKSPACE回到控制台,重新启动X和桌面:

>''sudo /etc/init.d/gdm start''

如果是KDE

>''sudo /etc/init.d/kdm start''

桌面会很快出现,还不行的话就输入

>''startx''

注意:

a、如果让游戏使用它自己的X session,确认禁止winecfg里的virtual desktop。

b、让游戏使用它自己的X session可以解决在游戏时键盘无法输入的问题。
P19:C++源文件后缀
P21:取得main返回值(Linux & Window)
P40:C++头文件后缀
P55~P56:各种算术类型的存储空间
*最小存储空间
*一般的存储空间
P58:char有三种,但只有两种表示类型,由编译器决定
*plain char
*unsigned char
*signed char
P59:浮点数有效位数
P60:除用标准库中的类型外,使用unsigned类型比较安全,防止负数越界
P60:char类型是signed还是unsigned''貌似''由编译器决定
P61:八进制以''0''开头
P62:定义unsigned类型,数值后加u或U
P62:科学计数法,指数加E或e
P63:宽字符wchar_t,字符字面值前加L
P63:非打印字符表示:\ooo或\xddd
P64:为兼容C,C++编译器自动在''字符串''末尾添加空字符(''\0'')
P65:字符串''字面值''可以用空白(空格、tab或换行)连接,但''不用类型''的字符串字面值连接的行为是未定义的,由编译器决定
P72:变量命名:标识符不能包含''两个连续的下划线'',也不能''下划线开头后紧跟一个大写字母''
P74:两种初始化方法,初始化与赋值的区别(P75有多个初始化式时不能使用复制初始化)
P77:内置变量类型的初始化
P79:声明和定义之间的区别(形式、影响、作用)
P82:作用域的嵌套(同变量名覆盖)
P83:把一个对象定义在它首次使用的地方是一个很好的办法
P86:非 const 变量默认为 extern。const 变量默认为文件的局部变量,要使它能够在其他的文件中访问,必须地指定它为 extern。
P90:非const引用只能绑定到与该引用同类型的对象
P91:typedef的目的
P92:类定义后面要加''分号''
P96:''class''和''struct''的区别
P98:编译大的头文件需要耗费很多时间,所以有''预编译''出现
P99:编译和链接多个源文件的方法
P100:头文件不应该包含变量或函数的定义,会造成多重定义问题。三个例外
#类(class)
#const对象
#inline函数
!!!关键字
P51: ''static_cast''<//float//>( value )
>Ref:[[here|http://www.cplusplus.com/doc/tutorial/typecasting/]]
P51: ''setprecision(intValue)'' {{{    需要iomanip.h}}}
P51: ''setiosflags(ios::fixed | ios:showpoint)''{{{    需要iomanip.h}}}
>以上两条,都是对于关键字使用''以后''的输出有效
P67: ''setw(intValue)''
>仅对后面的''一个''输出有效
P109: ''函数原型''的一个重要作用:''强制参数类型转换''
P115: ''srand(time(0))''取得随机数{{{    需要stdlib.h(cstdlib)或time.h(ctime)}}}
P117: ''enum Status{ CONTUNUE=1, WON, LOSE};''
P119: ''auto, register(现在的编译器通常能自动识别常用变量,把它放到寄存器), extern, static''
P128: ''递归与迭代'':
#迭代用于''重复结构'',递归用于''选择结构''
#迭代采用''计数器'',递归不断''最初问题的简化副本''
#递归消耗大量内存
选择递归的原因:
>更自然地反映问题,更容易调试。或者没有明显的迭代方案
P130: ''空参数表:''
>CPP中表示''函数不去任何参数'',C中表示不对参数检查
P131  ''内联函数''
>任何对内联函数的修改都可能要求函数的所有客户端重新编译,这在有些程序的开发和维护中影响很大。
P133  ''按引用传递''的''形式''
>{{{int count=1;}}}
>{{{int &cRef = count;     }}}此后cRef是count的''别名''
''按引用传递''的''一般原则''
>通过''指针''将''可修改参数''传给函数
>通过''按值传递''将''不可修改''的''小参数''
>通过''常量引用''将''不可修改''的''大参数''
P134 ''引用变量''必须''初始化''
P135 ''默认参数''
P136 ''一元作用域运算符:''{{{::}}}
P138 ''重载函数''通过''签名''进行区别,签名是''函数名''+''参数类型、个数、顺序''的组合(与返回值无关),具体转换成汇编代码后的效果因编译器而异(Borland C++见书)
P139 ''函数模板''
>{{{template <class T>
>{{{T method(T val1, T val2, T val3)}}}
>{{{{   T local1 = val1;}}}
>{{{     .......       }}}
>{{{}}}}
P171 ''cin''从键盘读取字符,直到遇到第一个''空白字符''
P175 ''函数传递数组''
>定义:{{{void modifyArray(int a[], int arraySize)}}}
>调用:{{{const int ARRAYSIZE=5;  int a [ARRAYSIZE]={0,1,2,3,4};  modifyArray(a, arraySize)}}}
P210 C++第三种向函数传值方式:用''指针参数''按引用调用
>{{{void callByReference(int *nPtr)}}}
>{{{{}}}
>{{{.....}}}
>{{{}}}}
>{{{int number=5;}}}
>{{{callByReference(&number);}}}
P216 {{{const int *和int * const}}}
P237 setw用于cin时可保证读到的字符数目不超过某个长度
>{{{cin >> setw(20) >> word;}}}
P238  ''cin.getline(array, len, seperator)''
P297 ''函数返回数据成员的引用''
>{{{int &Time::badSetTime(int hh)}}}
>{{{{}}}
>{{{hour = hh;}}}
>{{{return }}}''hour'';
>{{{}}}}
>{{{int main()}}}
>{{{{}}}
>{{{Time t; int &hourRef = t.badSetTime(20);}}}
>{{{......}}};
>{{{}}}}
P317''友元'':有权访问类的private和protected成员
>友元关系是''给予''的;友元关系既''不对称'',也''不能传递'';
>一般将友元关系的声明放在''类的首部'',不能加任何成员''访问说明符'';
>友元''不是成员函数''
P319  this''指针''(this是指针)
>''x'' == ''this->x'' == ''(*this).x''
>返回this指针的用法(P320-P322)
P324 ''new''自动调用构造函数,''delete''自动调用析构函数
P328 ''#define NDEBUG''
>使预处理器''忽略所有断言'',而不必手动删除;
P331-332 ''代理类''的设计
P332 ''[[提前类声明|http://www-subatech.in2p3.fr/~photons/subatech/soft/carnac/CPP-INC-1.shtml]]''
P341 ''用作成员函数和友元函数的运算符函数''
>''if'' (运算符的''左操作数''是类的对象 ),可以把运算符重载函数作为类的成员;
>''else if'' ( 重载函数''需要访问类私有成员'' ),可以把重载函数设成友元函数;(另一原因是使得运算符有''可交换性'')
>''else'', 可以不是成员函数也不是友元(如果类中有set、get函数也行)
P344 static函数成员函数只能static数据变量
P344 重载''一元操作符'',有两法:
>设为成员函数,无参数(较好)
>设为友元,有一个类对象(副本或引用)作参数(破坏类封装性)
在需要连续操作时,运算符重载函数的返回值可能是引用,可能是副本,要具体情况分析。
>如''“{{{<<, >>, +=}}}”''的都需要引用,''“+”''一般返回副本
>上面不绝对,但是有原则:''返回的引用绝对不能是重载函数中的变量(栈上)''
*对整数来说,算术表达式运算完的结果自动变成int(P48)
*&和|是''非短路运算符'',&&和||是''短路运算符''(P50)
*位运算符,''只能用在整数类型上''(P56)
>''{{{&  |  ^  ~}}}''
*移位运算符:''{{{>> << >>>}}}''(P57)
>1. 对于负数,>>右移时,第一位补''1''
>2. ''>>>''是无符号右移,第一位补0,只能用于int和long,byte和short自动转换成int
>3. Java采取''减次运算'',如int类型,最终移位位数是''{{{用户要移的位数 mod 32}}}''
*''属性''和''方法''成为对象的''成员''(P88)
*''多态'':父类的方法被子类修改,当以父类的观点来调用子类的这个方法时,会运行子类的方法。(P90)
>多态,即多种状态,树袋熊可以是动物状态,可以是熊状态,但是这些“角度”没法改变他是树袋熊这一本质,故调用“睡觉”这个方法时,调用的是树袋熊自己的方法。
*子类转换成父类是自动转换,父类转换成子类要强制转换(P102)
*{{{A instanceof B}}},判断''A对象''是不是''B类''的''实例'':(P102)
>''{{{class SON extends PARENT }}}''
>''{{{ PARENT p = new SON();}}}''
>则,''{{{p instanceof SON}}}'' 为true
*成员:实例成员、类成员(P103)
*''super()''和''this()''只能在构造函数的第一句(P107)
*遮蔽(shadow)与覆写(override)(P109-P111)
>遮蔽的客体是''属性''
>覆写的课题是''方法'',即与''多态''中描述的一样,它本质上是什么类就会调用这用类的这个方法,强制转换也没用,即覆写父类的方法了。
>对于static的方法来说,他伴随于类,不会受子类影响,所以它只会被遮蔽,不会被覆写。
*包管理:
>''{{{javac zoo\Zoo.java;  java zoo.Zoo;}}}'',写成''“zoo.Zoo”''是因为Java对package的设置是用句点作为分割符的。
>使用java命令时,-classpath可以简写成''-cp'',但是javac不行
>''protected''修饰符表示的是受到''包和继承的保护''。
>''default''修饰符(其实不存在)表示的是只有在一个包中才能互相访问,在不同类中,''即使''继承也没法访问'。(成员修饰符)
>对于''类申明'',只能用''public''和''default(即什么都不写)''两种修饰符。
*''String:'' ==比较''对象'',euqals比较''内容'',对于''一般的类'',通常自己写equals函数来覆写Object中的equals函数。(P135)
*Java文档规定:两个相同的对象,其''散列码''必然相同。当然这只是(推荐的)规定,当你覆写并调用equals函数时,照样能产生''true''结果,。-----Object类中有hashCode方法来查看对象的散列码。(P136)
>''注:''在Hasdhmap等Hash家族中,查找都是根据hashcode和equals来判断的,内部它是先看hashcode是否相等,在看equals是否为true,具体看[[这里|http://blog.chinaunix.net/u1/53616/showart_432480.html]],还有[[重写equals()方法为什么还要必须重写hashCode方法|http://jaywee.javaeye.com/blog/265200]]
*clone()函数用来复制一个对象,产生一个''不同地址内容相同''的对象(P138)
>要求:1、impements Cloneable;  2、覆写clone函数
>注意:clone函数返回的是Object类型,要强制转换成所要的类型;clone可能产生CloneNotSupportException,要catch
*''System.arrayCopy''函数用来数组拷贝,5个参数
*Java支持不规则数组
*打印数组(数组的元素也是数组),可以用Arrays.deepToString函数,但是传入的参数必须是Object类型的数组(toString是可以任意类型的);同样,Arrays.equals也有对应的Arrays.deepEquals
*Java只有传值,没有传地址
*将对象赋值为null就可以让GC(Garbage Collection)回收这些内存
>可以用''freeMemory''和''totalMemory''来查看系统(JVM)中空闲内存和总内存容量(P163)
>设为null后系统可能不马上释放内存,可以通过Runtime.getRuntime.gc()来手动释放(当然也不完全肯定能马上释放,这只是''建议'')
>在对象被释放之前会自动调用''finalize''函数,类可以覆写这个函数来事项相关功能
*System类使用
>''setOut''''setErr''''setIn''重定向
>''setProperties''和''setProperty''设置系统属性
!!!异常处理
*''java.lang.Throwable''是所有异常类的始祖
>''Runtime Exception''、''Checked Exception''、''Error''
*finally
*‘’throws‘’与''throw''
*继承中异常的改写的原则
>不可丢出 父类的丢出的异常的父类或上层类
>丢出的异常类数目不可比父类丢出的多
<html><font size="4" color="red">   GUI   </font></html>
*''Layout'':使用Layout的目的是使不同的平台下显示的效果一样
>Frame默认是BorderLayout
>Panel默认是FlowLayout(同样Applet也是)
>FlowLayout默认居中对齐
>CardLayout名字取自“纸牌”,显示组件的方法:''{next | previous | first | last }''(CONTAINER)或指定组件名字:''show(CONTAINER, STRING)''
>GridLayout
>GridBagLayout属性与方法:gridx, gridy, gridwidth, gridheight, weightx, weighty, anchor, fill, inserts
>setHgap, SetVgap
*''AWT Event''
>''分类'':''ComponentEvent''(Low-Level Event)和Semantic Event
>''ComponentEvent''(Low-Level Event):
>>''ContainerEvent''
>>''FocusEvent''
>>''WindowEvent''
>>''InputEvent'':''KeyEvent''和''MouseEvent''
>''Semantic Event'':
>>''ActionEvent''
>>''AdjustmentEvent''
>>''ItemEvent''
>>''TextEvent''
*每种Event都有其对应的Listener
*由于实现接口要实现接口中的''所有方法'',所以较麻烦;故可用''Adapter''类,它实现了接口中所有的方法(空方法),用时只要''覆盖所需要的方法''
*不是每个Listener都有对应的Adapter,有个一个方法的Listener就不需要Adapter了
*一个组件上可以注册多个Listener,处理的顺序按照声明的顺序
<html><font size="4" color="red">  内部类(Inner Class)  </font></html>
*''内部类的好处:''既有独立类结构清晰的有点,也有同一个类的直接访问对象、成员的优点。
>故其''存在的目的是:''1、可以让逻辑上相关的类结合在一起;2、Inner Class可以直接访问外部类的成员;
*''声明的位置:''1、类成员式,声明为一个类的成员;  2、区域式,在一个方法中声明;   
*''访问权限:''可以是任何一个访问权限修饰符;
*''具体分类''(按照作用域):
#类级别:加上static修饰符;直接OutterClass.StaticInnerClass in = new OutterClass.StaticInnerClass();
#对象级别:在OutterClass中,但没static修饰符;OutterClass out = new OutterClass(); OutterClass.InnerClass in = out.new InnerClass();  
#区域变量(临时变量)级别:在方法中声明,一般的用法是当作Object类对象返回;  
#匿名级别:同上,目的是懒的命名了;
*''关于static:''Inner Class中的成员若要使用static修饰符,那么该Inner Class也必须是static的
<html><font size="4" color="red">  包装类  </font></html>
1、@@color(red):Integer@@
*''设计基本数据类型的原因:''1、速度(可直接放入寄存器);  2、直观;
*''引入包装类的原因:''又是不得不使用类对象;
*''构造函数:''可传入int型或@@color(red):String型@@参数
*''类常量:''MIN_VALUE、MAX_VALUE、TYPE(取得当前对象是那个Wrapper类);
*''取出int值:''1、Integer.parseInt(intString);  2、(Integer i = new Integer(aIntValue))i.intValue;
*''数据转换:''1、Integer.parseInt(intString, radix);  2、Integer.toString(aIntValue, radix); 3、valueOf类似,但返回Integer对象;  4、toBinaryString系列; 5、同理有byteValue、shortValue、longValue、floatValue、doubleValue来把类对象转换成对应的基本数据类型数值;
*''比较对象“大小”:''compareTo,返回int;
2、@@color(red):Boolean@@
*''类常量:''TRUE、FALSE、TYPE
*''方法:''booleanValue、getBoolean、valueOf;
3、@@color(red):Byte@@{{{  与Integer类类似}}}
4、@@color(red):Character@@{{{  详见API}}}
5、@@color(red):Double@@{{{  详见API}}}
6、@@color(red):Float@@{{{  详见API}}}
7、@@color(red):Short@@{{{  详见API}}}
8、@@color(red):Long@@{{{  详见API}}}

<html><font size="4" color="red">  深入理解字符串  </font></html>
*产生字符串对象方法
#调用''构造函数''(new),原理是直接产生一个新对象。
#使用''双引号''赋值,原理是从''字符串池''(String Pool)中寻找是否有相同字符串,有的话直接引用。
*字符串对象是不可修改的(''immutable''),所有修改操作都会导致新的字符串对象产生。若真需要常常修改,可用''StringBuffer''类。
*String类的构造函数:主要五类7个(全部看api):无参数、byte数组、char数组、字符串、StringBuffer
*String类的方法:
##类方法:copyValueOf、valueOf、format
##对象方法:……
*StringBuffer类方法(在java.lang包下)
**增加
##append:共10种重载,根据参数不同分为char、String、Object(toString)、char数组、有起终点的char数组、boolean、double、float、int、long
##''insert'':总共10种,与append几乎一样,只是第一个参数是插入的位置,int型;
**修改
##''reverse:''无参数,返回修改后的StringBuffer对象;
##''setCharAt:''参数:''(要替换的位置int,新的字符char)'',无返回;
##''replace:''参数:''(要替换的起点int,要替换的终点int,新的字符串String)'',返回修改后的StringBuffer对象;
**删除
##''deleteAt:''参数:''(要删除的位置int)'',返回修改后的StringBuffer对象;
##''delete:''参数:''(要删除的起点int,要删除的终点int)''
**查询
##''charAt''
##''getChars''
##''substring''
>@@color(red):注:@@StringBuffer是线程安全的(同步),但也因此执行效率''相对较低'';相反,StringBuilder是线程不安全的,但执行效率高。
>故当''确定''程序中不涉及多线程时,推荐使用StringBuilder。
*''StringTokenizer''(在java.util包下)
**''构造函数:''三种;默认的''分隔符''是:空格、定位符(Tab,\t)、换行(\n),Carriage-return(\r)、form feed(\f)
**''方法''
##''countTokens''
##''hasMoreElements''、''hasMoreTokens''   ''区别''在于前者是实现Enumeration接口而来的,后者是StringTokenizer专有的,两者效果一样;
##''nextElement''、''nextToken''对应于上面两个方法;

<html><font size="4" color="red">  文件与输入/输出处理  </font></html>
*''Stream''纵览
#''InputStream''和''OutputStream''是所有输入输出相关类的父类,它是以''字节''为单位来传送数据;继承的类大都是XXXXStream;
#''Reader''和''Writer''两个类用来处理字符流数据;继承的类大都是XXXXReader、XXXXWriter;
*''Node''(节点类)
#''作用:''将数据来源或目的地进行''连接'';
#''分类:''字节继承体(三类)和字符继承体(四类),具体见下表
|!种类\继承体系|!字节|!字符|
|!文件(File)|FileInputStream,FileOutputStream|FileReader,FileWriter|
|!内存(Array)|ByteArrayInputStream,ByteArrayOutputStream|CharArrayReader,CharArrayWriter|
|!内存(String)||StringReader,StringWriter|
|!管道(pipe)|PipeInputStream,PipeOutputStream|PipeReader,PipeWriter|
*''方法使用''
**''InputStream类''
##''read:''三种重载方式,参数...返回值...
##''close:''关闭数据流
##''available:''参数...返回值...可能会产生''IOException异常'',需要处理。
>>@@color(red):注:@@InputStream对象调用这个方法,它一直返回0;只有继承自InputStream的子类的对象调用才能正常使用;
##''skip:''参数...返回值...
##''mark''、''reset'':参数...返回值...
>>@@color(red):注:@@mark不是所有流都支持(而且只能是InputStream的子类),可用''markSupported''检测;reset会产生IOException异常
**''OutputStream类''
##''write:''三种重载方式,参数...返回值...
##''flush:''write之后不马上写,要flush
##''close:''同上
**''Reader类''
>>与InputStream类类似,只不过操作对象变成了''char类型'';同时,Reader类中没有available方法,取而代之的是''ready''方法;
**''Reader类''
>>与OutputStream类似,同样byte类型变成''char类型'';不过多出来两个write方法(把char数组编程String对象),总共5个;
*''文件处理''
**''文件操作''
##''File常量:''目录分隔符:''separator''(String类型)、''separatorChar''(char类型);路径分隔符:''pathSeparator''、''pathSeparatorChar'';
##''File构造:''三种,参数...返回值...
>>@@color(red):注:@@File类对象可以文件,也可以是''目录'';取得当前目录(PWD):System.getProperty("user.dir");
##''方法:''其中有createTempFile、delete、deleteOnExit、list、listFiles、listRoots、mkdir、mkdirs具体看API;
**''文件访问''
##''FileInputStream''初始化时要处理''FileNotFoundException''异常;
##''FileInputStream''类中的方法:read:每次读一个字节,没有数据返回-1;不过有available方法直接判断是否有数据可读。
##由于中文编码每个字要''两个字节'',所以一般不用read一个个地读取每个字节(用得话也要保证每个字的第一个字节是''奇数''个字节),通常读字符
##通常用''FileReader''和''FileWriter''来“包装”FileInputStream,实现每次读一个字符,其他InputStream应该类似。
##''RandomAccessFile'',直接继承Object类
**''数据流连接''(''Filter流''类)
##Java提供的机制,能用数据流做连接,使得流能够以''特殊(方便)的方法''访问。
##负责这项机制的是''Filter''类,类似可分为''FilterInputStream'',''FilterOuputStream'',''FilterReader'',''FilterWriter''四个类。具体继承自他们的类见下表
|!种类/集成体系|!字节|!字符|
|!暂存|BufferedInputStream,BufferedOutputStream|BufferedReader,BuffereWriter|
|!字节字符装换||InputStreamReader,OutputStreamWriter|
|!对象串行化|ObjectInputStream,ObjectOutputStream||
|!特定数据类型访问|DataInputStream,DataOutputStream||
|!计数|LineNumberInputStream|LineNumberReader|
|!重复|PushbackInputStream|PushbackReader|
|!打印|PrintStream|PrintWriter|
''注:''对于对象串行化,可以在类的属性声明时加上“''transient''”修饰符,这样这个属性就可以''不被串行化''(不被写入文件)。(格式如:{{{transient int a}}})
<html><font size="4" color="red">  线程  </font></html>
*尽量用''实现Runnable接口'',而不是''继承Thread类''
*''P336''的线程架构图
*Thread对象只能调用''一次start方法''
*在JDK1.1以后,''stop方法''被废弃了,只有当''run''方法运行结束以后,线程才会结束;
*''暂停线程运行''方法
#''sleep''方法(''类方法'',须处理''InterruptedException''异常):进入''block''状态,当到时间后,进入''runnable''状态(''@@color(red):不是running状态@@'')
#''yield''方法(''类方法''):进入''Runnable''状态,知道再次被CPU调度到;
#''join''方法(''对象方法''):一个线程A等在另一个调用join的线程B上,处于''block''状态;直到B运行结束,A进入''Runnable''状态;它也可以设置等待时间;
*关于''时间'':默认的方法都是以''毫秒''为单位(也有重载的以纳秒<十亿分之一秒>为单位);方便起见,可以使用''TimeUnit''类
*''TimeUnit''类是''Enum''类,具体使用见API
*''取得线程信息''的方法
#''isAlive''
#''setName''
#''getName''
#''currentThread'':当线程是''实现Runnable接口''而来时,由于没有Thread对象,故要用此方法来取得当前运行的对象;
*''数据同步''
>关于''@@color(red):锁@@'':每个对象都有一个锁,当要运行某个对象中设置锁的某段代码时,须先取得这个锁;当别的线程也想运行那段代码    >时,须等别的线程归还那把锁;
>具体代码:
>{{{synchronized(要取得锁的对象)
         {      要加上锁的代码       }}}}
>(按我理解,从效果上来讲,synchronized表示在某个''对象''上建立的各个线程对''"加上锁的的代码"''是互斥访问的,由此有了''得到锁''和''释放锁''的语义)
**''synchronized声明''
##如上面的代码:''优点:''可以对某段''需要同步的代码''锁定,不必浪费时间在其他代码上,并可以取得其他对象的锁;''缺点:''在javadoc中无法知道那些方法是synchronized的;
##{{{public synchronized void method() { ... }}}}   ''优点:''在生成的javadoc中知道哪些方法是synchronized的;''缺点:''方法中很多不需要同步的代码浪费运行时间,再有它只能取得这个方法所在类的对象的锁(''只能取得自己的对象的锁'')
**''锁归还的方式''
##''bread语句''跳离锁定的语句块,不过对于''方法声明上的synchronized''没用;
##遇到''return语句'';
##遇到''异常'';
**一些''原则'',除第一条,其他都是网上资料
##'受synchronized保护的代码中,要访问的对象属性必须设置为''private'';
##无论synchronized加在方法还是对象上,它''取得的锁都是对象'',而不是把一段代码或函数当作锁――且同步方法很可能还会被其他线程的对象访问,故''当心死锁''。 
##''每个对象''只有''一个锁''(lock)与之相关联。若一个对象有多个synchronized方法,只要一个线程访问了其中的一个synchronized方法,其它线程不能同时访问这个对象中任何一个synchronized方法。
##''类的锁'':(1)静态方法前加synchronized。 (2)synchronized(className.class).(3)synchronized(Class.forName(className)。
##''零长度的byte数组对象''创建起来将比任何对象都经济:private byte[] lock = new byte[0]; 
>''[[来源1|http://colorlife.javaeye.com/blog/325084]]'',''[[来源2|http://henry406.javaeye.com/blog/371932]]''
*高级线程操作
#对于同步(synchronized)的方法,一般''用while来判断wait的条件'':因为首先运行wait()后线程(B)停在wait()之后那句,其次线程调度是''随机''的,线程A执行notify后,不一定是我们想要的线程(B)得到运行,中间运行过几个线程后,当我们想要运行的线程(B)得到运行时,但是的''条件可能已经不满足''了,所以要继续判断一下wait的条件,如果还是满足,那要继续wait,所以用while。
#P354上的最终的状态转化图。系统的暂停状态有三个:
##''Blocked Pool'':属于系统,只有一个;
##''Lock Pool'':依不同的对象,会有多个;
##''Wait Pool'':依不同的对象,会有多个;
#''注意''
##wait和notify要对应同一个对象;
##调用notify后,从Wait Pool中''随机''挑选一个到''Lock Pool''(原因是Thread对象进入等待池前会''释放全部锁'',所以出来后要再加一次锁),然后到Runnable;
##可以用''notifyAll''方法把等待池中的线程全部转到锁定池中(Monitor Model),用于保证共用数据的一致性和系统不会进入死锁状态;
ubuntu推出的安装包,只要执行下面命令:
>''sudo apt-get install ubuntu-restrictes-extras''
黄连恩, 王磊, 李晓明 北京大学 网络与分布式系统实验室

提交时间:2007-12-20

!!!摘要
网页的相似性检测长期以来是一个研究的热点,shingling 和 simhash 被认为是当前最好的两个算法,然而它们存在着一定的不足:一方面,高的分数意味着高的相似概率,但并不必然意味着高的相似度;另一方面,哈希代码的长度和多样性之间的冲突决定了难以同时获得高的准确率和覆盖率。本文提出了一种新型的相似网页检测算法,同时具备高准确率与高覆盖率的优点。该算法采用基于LCS(longest common subsequence)的相似性度量方法,它可以更好地度量网页之间的相似度和包含关系,并获得高的准确度。同时,本文设计了一个包含了三个步骤的检测过程框架,以保证算法的效率。综合实验表明本文的算法同时获得了高准确率与高覆盖率并具有较好的效率。该算法成功应用于4.3亿文章型网页集合,将其分割为0.68亿个相似网页子集,整个过程使用6台Linux服务器仅花费了5天的时间。

!!!引言
*在基于哈希的相似检测算法中,''哈希代码的长度''决定了基于哈希方法的准确度,而''多样性''(multiplicity)则决定了召回率,两者之间的冲突决定了无法同时获得高的准确度和召回率。({{{源自论文:B. Stein. 《Principles of hash-based text retrieval》}}})

!!!定义
我们定义一个文档为一系列的字符组成。给定两个文档 A和 B,|LCS| 为它们的 LCS的长度,|SES|  为最短编辑脚本的长度。以上述例子为例,设 A = abcabba,B = cbabac,A 和 B的长度分别表示为 |A| 和 |B|,则有, 
>{{{                         |A| + |B| = 2|LCS| + |SES| }}}
定义 resemble rate 为: 
>{{{                       r(A,B) = |LCS| / (|A| + |B| - |LCS|) }}}
定义 contain rate 为: 
>{{{                           c(A,B) = |LCS| / |B|}}}
!!!检测过程
LCS是一种两两比较文档的相似性检测方法。假设对于一个文档集合 R,经相似性检测后将得到分割为若干相似文档子集 a, b, c, d,  …  共  n  个。那么,相似性检测的一般过程可描述如下: 
##按一定方法对文档进行排序,原则是尽可能使形成最大子集的文档排在前面。 
##读取第一个文档,放入第一个子集 a。 
##顺序读取其它文档,与已有子集的第一个文档比较,若不相似,新生成一个子集。 
分析可知,在这个过程中,每个文档最多将比较  n-1次。因此,每篇文档的比较次数,取决于文档集合 R 的不相似文章数量。
>‘’与COS测度比较的优势‘’
###LCS体现了词的顺序,而 Cos 没有;
###LCS 可以评估两篇文档之间的包容关系,而 Cos 不能;
###一般认为,Cos 的方法要比 LCS更快。但对于中文文档来说,这一优势并不是那么明显,因为COS方法要切词
!!!算法实现
算法的系统框架划分为三个步骤:
##将网页文档集合分割为''可能相似文档子集'',仅在每个可能相似文档子集中计算 LCS;
##在计算两篇网页文档的 LCS之前,对网页文档进行过滤生成文档''过滤框架'',在该框架而不是原始文档上进行 LCS计算;
##计算LCS并选取它的可信部分(称为 TLCS)来计算相似度
!!!!可能相似子集计算
>去HTML标签,去格式,按照标点分割成句子;
>>计算文档指纹:
####对''每个文档'',选择那些''长度大于一定值 X ''的句子,每个对句子计算 MD5摘要,对m取模,不同值''分成m个组'';
####对''每个组'',取其中MD5值''最小的Y个不同句子''(并且要求Y个句子分布在不同位置,即其覆盖的文字长度达到一定值 Z)计算一个哈希值(128 位),称为指纹,这样共得到''m个指纹'';
####对''MD5值''(共16字节)循环移位一个字节,重复上面 2 步,这样,最多可以得到 ‘’16×m个指纹‘’。
>>>对文档按指纹进行索引,然后将它们聚集到可能相似的子集里。聚集算法描述如下:
#####对文档按它可以生产的指纹数从大到小进行排序,显然,指纹越多它就可能找到越多的相似文档;
#####按顺序从文档集合中逐个读取文档,对于每个文档,根据指纹索引从剩下的文档集合中读取和它可能相似的文档以及根据传递性得到的可能相似文档聚集到一起,形成一个可能相似子集;
!!!!文档过滤框架计算 
对于给定将要进行比较的两篇文档 A和 B,做如下算法:
#对每篇文档, 使用一个长度为 S 的滑动窗口来顺序读取一个文字片断, 滑动窗口相互是交叉的;对该''窗口的文字片断''使用'' Rabin'' 的方法[16]计算一个哈希值。 
#每篇文档将''哈希值记录''在自己的一个哈希表里(另一种办法是记录在位图里,位图的大小应该远大于文档长度) 。 
#对于 A 中的每个哈希值,检查它是否在 B 中也存在,如果是,则它所对应的文字片断被保留下来。''文档 A 的过滤框架即为这些被保留下来的文字片断的交集''。 
>使用同样的方法得到文档 B 的过滤框架
!!!!可信部分计算
略
[[fat32文件系统最大文件不超过4G|http://www.javaeye.com/topic/188752]]
[[Design and Implementation of the EXT2|http://e2fsprogs.sourceforge.net/ext2intro.html]]
方法一:
>{{{a = a+b}}}
>{{{b = a-b}}}
>{{{a=a-b}}}

方法二(更高效):
>{{{a = a^b}}}
>{{{b = b^a}}}
>{{{a = a^b}}}

来源:[[这里|http://ipie.blogbus.com/logs/38126775.html]]
Type the text for '与python混合编程'
1、{{{int (*a)[n] = new int[m][n]}}}
>优点:空间连续,直观,使用方便
>缺点:n需事先知道
2、见下
<code c>
int **a = new int*[m]
for(int i=0; i<m; ++i)
    a[i]=new int[n];
.....
for(int i=0; i<m; ++i)
     delete[] a[i];
delete[] a;
</code>
>优点:n可未知,调用直观
>缺点:非连续存储,析构较烦
3、见下
<code c>
int *a = new int[m*n]
......
delete[] a;
</code>
>优点:析构简单,n可未知,连续存储
>缺点:调用不直观
4、见下
<code c>
vector<int> a;
a.resize(m);
for(int i=0;i<m; ++i)
    a[i].resize(n);
</code>
>优点:自动析构,动态增长,调用直观
>缺点:非连续存储,复杂性增大
5、见下
<code c>
vector<int> a;
a.resize(m*n);
</code>
>3、4的结合
6、见下
<code c>
int **a = new int*[m];
a[0] = new int[m*n];
for(int i=1; i<m; ++i)
    a[i] = a[i-1] + n;
........
delete[] a;
</code>
>优点:连续存储,方便析构,调用直观,n可以是未知

参考:[[这里|http://www.cnblogs.com/beyondstorm/archive/2008/08/26/1276278.html]]
代码1:[[人人网登陆发文|http://fayaa.com/code/view/9987/]]
!!!模拟登陆,保存cookie
*''Cookie保存''
Cookie用{{{cookielib.CookieJar()}}}生成的对象保存,然后用这个Cookie通过{{{urllib2.build_opener}}}生成OpenerDirector对象,以后用这个OpenerDirector对象建立的链接就不用登陆了(保存Cookie了)。详细见//代码1//中的{{{login}}}函数
!!!POST文章
*''组建参数''
基本的参数可以通过firebug的网络调试功能找到,到发表文章的[[页面|http://blog.renren.com/blog/0/addBlog]],开启firebug,填好内容提交,查看POST参数。可以看到,有如下值需要提交:
>''blogControl'', ''categoryId'',  ''editBlogControl'',  ''isVip'', ''title'', ''body'', ''postFormId''
前四个只要设成firebug中观测到的响应的值即可,title和body是将要发表的日志的内容,最重要也是最难弄的是最后一项,他与用户每次登陆的 session绑定,是个随机值。故需要//代码1中//的get_postFormID来取得每次登陆的所随到的值。
参数用如下方式来包装:
>{{{urllib.urlencode(body)}}}
*''提交POST''
只需用之前生成的opener(已经有Cookie)打开一个连接,发送POST请求{{{opener.open(url_post, urllib.urlencode(body))}}}
*''编码问题''
#title和body都有可能是中文,而人人网的默认编码是UTF8,所以需要转码;
#在Windows环境中,默认的编码是''mbcs'',或者是''cp936'',所以可以先用mbcs来''decode'',再encode成''utf8'',详见代码1。
#关键就是找到系统默认的文件系统编码,然后对其进行转换;
#问题解决参考:[[limodou|http://www.linuxforum.net/forum/printthread.php?Cat=&Board=python&main=575924&type=thread]]和取得[[系统编码|http://code.google.com/p/mylibs/source/browse/tools/Python/coding.py]]
  1.创建Google CSE
过程很简单,在[[Google CSE|http://www.google.com/cse/]]页面一步步按照提示创建即可。例子如笑来老师的[[Encyclopedia|http://www.lixiaolai.com/index.php/archives/992.html]]和[[Twitter|http://www.google.com/cse/home?cx=017195234153172777936:aqsxgxsvgyy]]搜索。

  2.Bookmarklet工具
相关资源见:电脑玩物的常用[[Bookmarklet|http://playpcesor.blogspot.com/2010/06/bookmarklets-2010.html]]和[[Brawny Walking|http://brownywalking.blogspot.com/2009/01/firefox-useful-bookmarklets.html]]的常用Bookmarklet,他的参考资料也是个不错的资源。
当Bookmarklet收藏了很多的时候,找也来可能也是个麻烦事,这时候另一个搜寻Bookmarklet的[[工具|http://brownywalking.blogspot.com/2010/01/command-line-bookmarklet.html]]就可能比较有用。

  3.创建Google CSE的Bookmarklet
利用[[Bookmarklets|http://bookmarklets.com/mk.phtml]]网站提供的工具创建,具体教程见[[这里|http://www.ampercent.com/site-search-bookmarklet/2647/]] 。
*首先是MainMenu,由于TiddlyWiki相互之间的链接是由Tiddler名称或Tag宏~~(暂时只发现这两种)~~来组织的,但是由于Tag宏的显示效果不适合导航Menu,所以采用Tiddler名称来组织。故现在看到的MainMenu上面的都是Tiddler名称。这样的话,由于Tiddler名称是单一的,所以这些Tiddler链向的页面都只能是一个汇总的页面,是几个页面的collector。所以MainMenu可以看做''一级目录'',这个collector页面可以看做有特定主题的一个''二级目录''。
*对于交叉的页面,比如我有个关于JavaScript的页面,我可以把它分在JavaScript目录,也可以把它分在code目录,那么我只需在二级目录分别建立对次Tiddler的链接。
*对于某篇文章的定位的几种方法:
**@@color(green):tag查找@@{{{       --------}}}若确定tag的话查找会很快,适合''了解文章,知道tag'';
**@@color(green):搜索@@{{{        --------}}}适合于''模糊查找'',''最慢'',但''成功率高'';
**@@color(green):~MainMenu@@{{{        --------}}}从~MainMenu开始,一级级定位。但对于查找某篇文章,这个方法比较''鸡肋'',没有tag查找的快速,没有搜索的准确;不过,对于''某一大类的文章''的浏览还是很适合的,毕竟MainMenu就是给一个粗略的分类。
*由于TiddlyWiki自身的编辑语法功能有限,所以产生的效果很难个性化;不过现在可以使用html代码以后,把TiddlyWiki的编辑功能简直提升了一个层次,估计以后用html来编辑可能会用得多一些。
首先要知道有char、unsigned char、signed char,char是与编译器相关的可能是signed(大多数情况),也可能是unsigned的,也正是这个编译器依赖性,标准制定者又引入了signed char。REF:[[Here|http://www.chinaunix.net/jh/23/894918.html]]

其次,char、unsigned char都是8位的变量,10进制范围分别是-128~127和0~255;同时ASCII自己也有自己的一套编码,只不过是正好与char的范围吻合(''这个应该是有历史原因的''),所以通过char的二进制编码值可以显示ASCII字符。所以看char对应的是什么字符,关键还是看他的二进制编码。由unsigned char*转到char *直接显式强行转换就好了。

最后,关于char扩展到整数,具体可看这篇文章:[[Here|http://blog.csdn.net/cugbliang/archive/2008/07/16/2657161.aspx]]
先看程序:
>#include<stdio.h>
>
>int main(void)
>{
>     char *a = "hello";
>     char c[10] = "ccc";
>
>     printf("c:%p\n&c[0]:%p\n&c:%p\n", c, &c[0], &c);
>     printf("a:%p\n&a[0]:%p\n&a:%p\n", a, &a[0], &a);
>
>     return 0;
>}

''输出结果'':
>c:0x22ccc0
>&c[0]:0x22ccc0
>&c:0x22ccc0
>a:0x402000
>&a[0]:0x402000
>&a:0x22ccdc

--结论:--
*--无论数组还是指针变量x,x表示的是''x变量的值'',对于指针,此值是''指向的地址'';对于数组,此值就是此变量x的地址,所以可以数组变量看作''指向自己的指针''(我的理解)--;
*--从对于数组变量c,c和&c的值相同验证了上面那一点:“数组可以看做''指向自己的指针''”--;
*--在上面“数组可以看做''指向自己的指针''”的基础上,可以把数组也看成指针;那么''x[n]''(n是0,1,2...)是在x变量的值的基础上的操作(n是偏移量),也就是对*x''指向的地址''的操作;''x[n]''是取值,''&x[n]''是取地址--;

''结论'':
上面的理解有问题,总的来说数组是数组,指针是指针,它们是两个不同的概念。指针和自己平常理解是相一致(变量的值被当成地址来看),而数组不应该和指针混起来,它只是''内存中的一块区域''(应该是连续的吧)。
*在C中,对于数组变量c,把c、&c、&c[0]都"解释"成那块内存的''首地址''(就是这么设计!),如在上面的程序中。
*在有些情况下,比如函数传参的时候等等,可以把数组变量看成指针变量,来访问那一块区域;
*对于sizeof,它计算的是''变量自身类型的大小'',所以绝大多数情况下,数组变量计算的是数组的大小(设计就是这样!),少数情况下,当它作为指针时,那么他就是指针变量的大小,即地址的大小(如32位是4字节)

''参考'':
*[[自己水源上的帖子|http://bbs.sjtu.edu.cn/bbscon?board=C&file=M.1246085304.A&num=11246]]
*[[西邮的wiki|http://www.xiyoulinux.cn/wiki/index.php?title=C%E8%AF%AD%E8%A8%80%E5%85%A5%E9%97%A8#C.E8.AF.AD.E8.A8.80.E6.A0.B8.E5.BF.83.E2.80.94.E2.80.94.E6.8C.87.E9.92.88]]

''最终语'':
关于知识,有的是内部的实现是这样,有其存在的规律或者必要性(比如栈、堆的实现、管理方式,否则就不成栈、堆,它是有道理的);也有的是作者就是这么规定、这么设计的,其他也许也行(比如不一定要设计成栈、堆的形式,其他管理方式也行,但是一旦这么设计了就有上面"遵守栈、堆的管理方式"的规律性的东西了,它是有道理的)。
!!一、头文件:
    #include <linux/proc_fs.h>
!!一、头文件:
    #include <linux/proc_fs.h>
!!二、创建与删除proc文件:
    ''<一>创建普通文件:''
        1.创建不可读写的普通文件
            /*此函数只负责在proc中创建一个只读文件,即能在proc中看到这个文件。
             * */
            struct proc_dir_entry* create_proc_entry (const char *name,mode_t mode,struct proc_dir_entry *parent);
            @name :要创建的文件名
            @mode :要创建的文件的属性 默认0755
            @parent :这个文件的父目录
        2.创建只读的普通文件
            /*和create_proc_entry基本一样。
             * 只是为该文件挂接上读函数:read_proc(void data);
             * */
            struct proc_dir_entry * create_proc_read_entry (const char *name,mode_t mode,struct proc_dir_entry *parent,read_proc_t* read_proc,void *data);
            @name :要创建的文件名
            @mode :要创建的文件的属性 默认0755
            @parent :这个文件的父目录
            @read_proc :当用户读这个文件时,内核调用的函数
            @data :传给read_proc的参数
        3.创建符号连接
            /*该函数在父目录parent下创建一个指向dest的连接name。
             * 就像ln:
             * #ln -s dest parent/name
             * */
            struct proc_dir_entry * proc_symlink (const char *name,struct proc_dir_entry *parent,const char *dest);
            @name :要创建的文件名
            @parent :这个文件的父目录
            @dest :符号连接的目标文件
        4.创建目录
            /*该函数在父目录parent下创建一个目录name
             * */
            struct proc_dir_entry * proc_mkdir (const char *name,struct proc_dir_entry *parent);
            @name :要创建的目录名
            @parent :这个目录的父目录
        5.删除文件或目录
            /*这个函数从proc文件系统中删除一个文件或目录。
             * 注意:1。是通过参数name,而不是通过创建时返回的指针来删除的。
             * 2。该函数不会递归删除目录下的文件。
             * 3。data变量保存了分配的内存,要先释放对应内存,再删除该文件。
             * */
            void remove_proc_entry (const char *name,struct proc_dir_entry *parent);
            @name :要删除的文件或目录名
            @parent :所在的父目录       
   '' <二>、读写proc文件''
        为了能让用户读写添加的proc文件,需要挂接上读写回调函数:read_proc和write_proc
        例:
            struct proc_dir_entry * entry;
            entry->read_proc = read_proc_foo;
            entry->write_proc = write_proc_foo;
        1.读函数read_func
            /*该函数把要写的信息写入buffer,最多不超过PAGE_SIZE
             * */
            int read_func (char *buffer,char **stat,off_t off,int count,int *peof,void *data);
            @buffer :把要返回给用户的信息写在buffer里,最大不超过PAGE_SIZE(一般4K)
            @stat :一般不使用
            @off :buffer的偏移量
            @count :用户要取的字节数
            @peof :读到文件尾时,把peof指向的位置置1
            @data :被多个proc文件定义为读时,通过data传递参数
        2.写函数write_func
            /*该函数最多从buffer中读取count个字节的数据。
             * 注意:buffer地址在用户空间,需要先用copy_from_user()把这些数据拷贝到内核中。
             * */
            int write_func (struct file *file,const char *buffer,unsigned long count,void *data);
            @file :该proc文件对应的file结构,一般忽略。
            @buffer :待写的数据所在的位置
            @count :待写数据的大小
            @data :同read_func
'' <三>、seq_file编程接口''
        include/linux/seq_file.h:
        struct seq_file{
            char *buf;
            size_t size;
            size_t from;
            size_t count;
            loff_t index;
            loff_t version;
            struct semaphore sem;
            struct seq_opertions *op;
            void *private;
        };
        seq_file结构会在seq_open函数调用中分配,然后作为参数传给每一个seq_file的操作函数。
        1.seq_file操作函数:
            struct seq_operations {
                void (*start) (struct seq_file *m,loff_t *pos);
                void (*stop) (struct seq_file *m,void *v);
                void (*next) (struct seq_file *m,void *v,loff_t *pos);
                void (*show) (struct seq_file *m,void *v);
            };
        2.四个操作函数作用:
            start:用来遍历连接对象的时候做初始化准备工作。
                    从pos得到偏移,返回一个连接对象的偏移。
                    也可以返回一个特殊值:SEQ_START_TOKEN
                    出错返回:ERR_PTR(error_code)
            stop:遍历结束时被调用。
                    主要做一些清理工作,如释放锁、释放内存
                    注意:如果调用了start,就必定会调用stop,即使start返回出错。
            next:遍历中寻找下一个连接对象。一般是下一个节点。
            show:对当前遍历到的连接对象或节点进行一些操作。
                    例如调用seq_xxx函数输出对象的一些内容。
        3.格式化输出函数
            seq_printf(struct seq_file *m,"格式化字符串",var):和printk很相似,只是多了个*m
            seq_putc (struct seq_file *m,char c);输出字符
            seq_puts (struct seq_file *m,const char *s);输出字符串
            seq_escape (struct seq_file *m,const char *s,const char *esc);跟seq_puts类似,不同的是这个函数特殊处理字符串s中的特殊字符(esc指针指向的每个字符),这些特殊字符输出为八进制,其他字符照常。 
''SRC:'' [[here|http://zhidao.baidu.com/question/38394944.html]]

!!!什么是分页?
无论你的NT服务器的内存有多大,它总是显得不够充足。当物理RAM从低端开始运行时,Windows NT使用了分页文件Pagefile.sys。为了运行不同的进程和应用程序,Pagefile.sys给物理内存分配了一些空间。在这些空间内允许交换数据页。

!!!什么是分段?

程序分段的好处。cpu中的段寄存器中保存了段址(base)和偏移值的上限(limit)。段址:有效地址 中,如果有效地址大于limit,便会引发异常。这样就可以限制程序不能范围当前段外的数据,不能访问其他程序的数据。总之就是不能访问它不能访问的数据。
面向对象的好处。对象就是一块连续的内存中的数据吧。这点跟上面一点类似。通过限制访问,就做到了private的效果吧。

!!!分段与分页:
(1)内存分段和内存分页一样都是一种内存管理技术,分段是为了权限保护,分页是为了虚拟内存.
(2)分段后,程序员可以定义自己的段,各段有独立的地址空间,象进程的地址空间互相独立一样.
(3)同一个类的实例分配在一个段中,只有该类的方法可以访问,如果其他类的方法去访问,会因为段保护而出错.可以从硬件上实现类的数据保护和隐藏

!!!什么是缺页?
为什么会出现缺页?你的问题中已经有了答案。物理内存和系统“提供”给用户的内存的不对称性。
是不是很容易就出现缺页的情况?像windows nt这样的系统,每个进程拥有4G的虚存,记住,是每个进程。其中3-4G影射为操作系统的核心,是只读的,1-2G映射为用户空间,其中一部分是系统提供的动态链接库。
对于每一个进程,操作系统只向物理内存映射少数的地址,这是因为 RAM 实在是太宝贵、太稀缺了。进程的剩下的内存实际上都保存在二级存储器(通常是硬盘)上。这就是为什么要叫虚拟内存的原因。没有映射到物理 RAM 的地址都被做上了标记。只要进程一访问这样的地址,操作系统就将数据从二级存储器上取回到内存。若操作系统把物理 RAM 用光了,它就把一些数据换出来腾出空间。之后我们还可以把这些数据取回,因为它们都保存在在二级存储器上。那些数据被换出是由替换策略决定的。 Windows NT 使用先进先出(First-In-First-Out,FIFO)的策略。根据这个策略,当空间不够时,最老的数据(即最先取进内存的数据)被换出。
缺页的频率取决于你系统的实际内存的大小和系统的进程数目等因素。例如同时跑着几千个进程的网络服务器,缺页肯定是非常频繁的。
与[[最小代价生成树]]中的prim算法思路、实现几乎一样,区别就在于closest的更新,这个closest是到''源点''的最短路径,而不是到u集合的最短路径
在实现中要注意下面的问题:
>1、如果两个点之间无边,则edges的值设为int的最大值,而在更新closest时,要对边的值做加法,这是可能会''超出int的范围'',变成负数,所以要先判断

源码见这里:[[代码发芽网|http://fayaa.com/code/view/5314/#]]
''方法一''
IE下可使用其私有的html属性:hideFoucs,在标签的结构中加入hidefocus="true"属性。即:
>{{{<a href="http://www.17css.com" hidefocus="true" title="17css-青色's Blog">17css-青色's Blog</a>}}}

而在 Firfox 浏览器中则相对比较容易,直接给标签 a 定义样式 outline:none; 就可以了,即:
>{{{.HideFocus {outline:none;}
}}}

''方法二''
也可以使用''CSS expression''来控制,但''不推荐''使用,毕竟expression在''性能''上有问题。
>{{{.HideFocus {
hide-focus: expression(this.hideFocus=true);  /* for ie 5+ */}}}
>{{{outline: none;  /* for firefox 1.5 + */
}
}}}
除链接外,该CSS同样适用于input和button标签。(''注:''这里的hide-focus是自己随便取的名字)

''方法三''
将以下代码保存为link.htc文件:
><public:attach event="onfocus" onevent="hscfsy()"/>
><script language="javascript">
>function hscfsy(){
>this.blur();
>}
></script>

链接样式中加入:
>a {
>behavior:url(link.htc);
>}

IE中已经没有问题,但是在FF中虚线框依然存在。再增加一条样式定义来解决此问题:
>a:focus {
>outline:0;
>}
这样IE、FF中虚线都不存在了。

''方法四''
通过JavaScript遍历实现
>window.onload=function()
>{
>for(var ii=0; ii document.links$[$ii$]$.onfocus = function(){this.blur()}
>}
''注:''暂时不懂 ==!
*[[cplusplus|http://www.cplusplus.com/doc/tutorial/]]绝对是个好地方啊,东西写得''简洁''、''清楚''
一句话就是指针的指针
具体见[[这里|http://forum.byr.edu.cn/wForum/elite.php?file=%2Fgroups%2Fsci.faq%2FCPP%2FC%2Fpointer%2FM.1207279974.b0]]
''source:''[[here|http://songfei.org/blog/2008/12/30/%E5%8F%98%E9%87%8F%E5%9C%A8%E5%86%85%E5%AD%98%E4%B8%AD%E5%AD%98%E5%82%A8%E7%BB%93%E6%9E%84/]]
小程序测试:
{{#include <stdio.h>

int g=1;

int fun()
{
    int a=2,b=3;
    printf("In Function fun()\n");
    printf("&a=%p\n&b=%p\n",&a,&b);
    printf("\n");
}
 
int main(int argc, char *argv[])
{
    int a=4,b=5,c=6,d=7;
    static f=8;
    printf("&g=%p\n&d=%p\n",&g,&d);
    printf("\n");
    fun();
    printf("In Function main()\n");
    printf("&a=%p\n&b=%p\n&c=%p\n&d=%p\n",&a,&b,&c,&d);
    printf("\n");
    fun();
    printf("a=%d\nb=%d\n",a,b);
    printf("*(&b+1)=%d\n",*(&b+1));
    return 0;
}

运行结果如下:

$ ./main
&g=0x80497fc
&d=0xbfd0b994
 
In Function fun()
&a=0xbfd0b974
&b=0xbfd0b970
 
In Function main()
&a=0xbfd0b9a0
&b=0xbfd0b99c
&c=0xbfd0b998
&d=0xbfd0b994
 
In Function fun()
&a=0xbfd0b974
&b=0xbfd0b970
 
a=4
b=5
{{*(&b+1)=4

这里看到了在main()函数中定义的普通变量(auto)在内存中是在栈中存放的

看到了它的地址是倒序的,越先定义的变量,内存地址越在后面

在函数中定义的局部变量在函数执行完后就释放了

所以两次调用fun()分配的变量地址是一样的

更多的资料,参考《unix环境高级编程》里面说:

C程序的存储空间布局

由于历史原因,C程序一直由下列几部分组成:
''正文段''
      这是由CPU执行的机器指令部分。通常,正文段是可共享的,所以即使是经常执行的程序(如文本编辑程序、C编译程序、shell等)在存储器中也只需有一个副本,另外,正文段常常是只读的,以防止程序由于意外事故而修改其自身的指令。

''初始化数据段''
      通常将此段称为数据段,它包含了程序中需赋初值的变量。例如, C程序中任何函数之外的说明:int maxcount = 99;使此变量以初值存放在初始化数据段中。

''非初始化数据段''
      通常将此段称为bss段,这一名称来源于早期汇编程序的一个操作符,意思是“block started by symbol(由符号开始的块)”,在程序开始执行之前,内核将此段初始化为0。函数外的说明:
      long sum[1000] ;使此变量存放在非初始化数据段中。

''栈''
      自动变量以及每次函数调用时所需保存的信息都存放在此段中。每次函数调用时,
      其返回地址、以及调用者的环境信息(例如某些机器寄存器)都存放在栈中。然后,新被调用的函数在栈上为其自动和临时变量分配存储空间。通过以这种方式使用栈, C函数可以递归调用。

''堆''
      通常在堆中进行动态存储分配。由于历史上形成的惯例,堆位于非初始化数据段顶
      和栈底之间。

[img[memory|http://songfei.org/blog/wp-content/uploads/2008/12/memory.gif]]

图中显示了这些段的一种典型安排方式。这是程序的逻辑布局—虽然并不要求一个具体实现一定以这种方式安排其存储空间。
!!!非递归版本
参见《数据结构与算法<交大版>》上的解释
>''关键'':不断增加步长,直至超过整个序列;
>''易错'':
>>''边界问题'':如果最后长度不足一个步长(begin+step>=size),无法分成两段,那么跳过,作为总会解决的
>>''合并序列'':始终当心边界问题(还是)
代码见这里:[[代码发芽网|http://fayaa.com/code/view/5241/]]
这里的一些讨论:[[C++ - making a graph|http://www.edaboard.com/ftopic95823.html]],有

!!!画图(plot)
*gnuplot:
>Linux:[[使用''popen''调用|http://coding.derkeiler.com/Archive/C_CPP/comp.lang.cpp/2003-10/4656.html]]
>Windows(Visual studio):编译,见[[Compiling gnuplot 4.1(CVS) for windows with Visual Studio/MinGW32|http://thinkingfish.wordpress.com/2006/02/09/compiling-gnuplot-41cvs-for-windows-with-visual-studio-2003but-not-full-featured/]]
*Octave:类似Matlab的开源程序
>visual studio集成:下载Windows安装包([[这里|http://www.math.sfu.ca/~cbm/ta/octave.html]]),再看[[这里|http://octave.1599824.n4.nabble.com/How-to-use-Octave-with-Visual-Studio-2008-td1633294.html]]的讨论
>这里有介绍如何在C\C++中使用:[[howto-octave-c++.ps|http://www.mathias-michel.de/download/howto-octave-c++.ps]]
*[[CGRAPH|http://www.codeguru.com/Cpp/controls/controls/chartingandanaloguecontrols/article.php/c2211/]]:貌似功能不全
>一些语法介绍:[[Octave:矩阵计算的新宠|http://icl.pku.edu.cn/member/yujs/BSDFiles/html/octave.html]]

!!!图像处理
*介绍:
>''imagemagick++'', ''cimg'', ''opencv'':http://mail.ustc.edu.cn/~ahbi/faq.htm
*一些资源
>[[freeprogrammingresources|http://www.freeprogrammingresources.com/imglib.html]]
*挂代理(GAppEngine,FreeGate等)上首页
*八哥
*官方API,见OneNote中Google App Engine那节
*自写程序,利用第三方API
**[[twitter4j|http://twitter4j.org/en/index.html]]
''SRC'':[[here|http://www.unixresources.net/linux/clf/program/archive/00/00/69/38/693804.html]]

1)先查在哪个包,比如Ubuntu下查命令ftp:

>''$ls -l /usr/bin/ftp''
>{{{.../usr/bin/ftp -> /etc/alternatives/ftp}}}

>''$ls -l /etc/alternatives/ftp''
>{{{.../etc/alternatives/ftp -> /usr/bin/netkit-ftp}}}

>''$dpkg -S /usr/bin/netkit-ftp''
>{{{ftp: /usr/bin/netkit-ftp}}}

2)知道了在ftp包里,用apt-get下源码到~目录
>''$apt-get source ftp ''

3) 下载下来后进入目录,用下面命令来查找需要的文件
>''find . -name "COMMAND"''
有BF、KMP、BM算法,具体有篇文论比较的
BM算法最为高效和简单,具体实现见AlgorithmGossip
思路:构建一个大小为256的ASCII字符前进表,失配时查找前进表,得到前进的距离。
*lsyncd工具
参考张教主的[[文章|http://42qu.com/zuroc/note/12/txt/618]]
*Hash Tree的思想
参照[[大量小文件的实时同步方案|http://blog.daviesliu.net/2008/04/24/sync/]]
文件系统本省就是个树状结构
>''不停地获取根目录的修改时间并顺着目录结构往下找即可''
原题见[[YSSY|http://bbs.sjtu.edu.cn/bbstcon,board,C,reid,1253289638.html]]
最后可以扩展到m*n+1规模,方法有三种:
1、partition select
>参照快速排序,任意找一个pivot,删除与pivot相同的点(如果没有,那么pivot就是要找的点),同时小于pivot的都放在pivot左边,大于pivot的放右边,这样最后左边或右边的长度一个模m为0,另一个模m为1,去掉模m为0的那边;对另一边继续相同的过程;
2、巧妙的位运算
>画出真值表,或状态转换图,构造位转换过程,详见[[这个帖子|http://bbs.sjtu.edu.cn/bbscon,board,C,file,M.1252853693.A.html]]
3、参照m=2的情况,只不过在做位加法的时候用m进制来算
>详见[[这个帖子|http://bbs.sjtu.edu.cn/bbscon,board,C,file,M.1253026038.A.html]]

全部的讨论见这个帖子的讨论:[[3n+1个数,除了一个数都是三个一组出现|http://bbs.sjtu.edu.cn/bbstcon?board=C&reid=1252759776&file=M.1252759776.A&page=1]](2009.09.12,可能会被合集)
同主题阅读:大家都用什么工具来profile C/C++程序
[版面:葵花宝典] [首篇作者:JasonTsai] , 2009年04月29日00:32:37
[分页:1 ]
	JasonTsai
进入未名形象秀
	我的博客
		
	[ 1 ]

发信人: JasonTsai (Jason), 信区: Programming
标 题: 大家都用什么工具来profile C/C++程序
发信站: BBS 未名空间站 (Wed Apr 29 00:32:37 2009)

最近需要分析一个程序的性能瓶颈,所以需要profile这个程序,分析每个function里
花的时间
以前没怎么弄过,请教大家什么工具最方便易用而且准确?gprof如何?

先谢过各位猛将~
--

※ 来源:·WWW 未名空间站 海外: mitbbs.com 中国: mitbbs.cn·[FROM: 70.240.]
	
	[ 2 ]

发信人: TaiYouCai (有才), 信区: Programming
标 题: Re: 大家都用什么工具来profile C/C++程序
发信站: BBS 未名空间站 (Wed Apr 29 10:20:26 2009), 转信

aqtime

【 在 JasonTsai (Jason) 的大作中提到: 】
: 最近需要分析一个程序的性能瓶颈,所以需要profile这个程序,分析每个function里
: 花的时间
: 以前没怎么弄过,请教大家什么工具最方便易用而且准确?gprof如何?
: 先谢过各位猛将~

--

※ 来源:·BBS 未名空间站 海外: mitbbs.com 中国: mitbbs.cn·[FROM: 38.106.]
		
	[ 3 ]

发信人: wdong (cybra), 信区: Programming
标 题: Re: 大家都用什么工具来profile C/C++程序
发信站: BBS 未名空间站 (Wed Apr 29 14:30:34 2009), 转信

gprof对C++基本失效。我以前用过vtune,基本达到目的。不知道aqtime怎么样。

【 在 JasonTsai (Jason) 的大作中提到: 】
: 最近需要分析一个程序的性能瓶颈,所以需要profile这个程序,分析每个function里
: 花的时间
: 以前没怎么弄过,请教大家什么工具最方便易用而且准确?gprof如何?
: 先谢过各位猛将~

--

※ 来源:·BBS 未名空间站 海外: mitbbs.com 中国: mitbbs.cn·[FROM: 128.112.]
	
		
	[ 4 ]

发信人: hubai (泡饭VIII号), 信区: Programming
标 题: Re: 大家都用什么工具来profile C/C++程序
发信站: BBS 未名空间站 (Wed Apr 29 23:23:25 2009)

google profiler
【 在 JasonTsai (Jason) 的大作中提到: 】
: 最近需要分析一个程序的性能瓶颈,所以需要profile这个程序,分析每个function里
: 花的时间
: 以前没怎么弄过,请教大家什么工具最方便易用而且准确?gprof如何?
: 先谢过各位猛将~

--

※ 来源:·WWW 未名空间站 海外: mitbbs.com 中国: mitbbs.cn·[FROM: 97.90.]
	
		
	[ 5 ]

发信人: mlwei (pumpkin), 信区: Programming
标 题: Re: 大家都用什么工具来profile C/C++程序
发信站: BBS 未名空间站 (Fri May 1 00:00:51 2009)

To find which function is using most of the time (hot functions) use gprof.
It'll create a trace file and you can use gprof to generate a report later
on.

For a particular hot function, if you'd like to know whether it is spending
time on memory / floating point or integer instructions, use intel VTune.

If most of the time is spent in memory instructions, cache optimizations are
important (tiling, prefetching).

If there are a lot of floating point instructions, compiling it to 64 bit
binary could help, because that'll allow the processor to use SSE registers
for your your code.

If the code is computationally intensive, you may consider some SIMDization.


【 在 JasonTsai (Jason) 的大作中提到: 】
: 最近需要分析一个程序的性能瓶颈,所以需要profile这个程序,分析每个function里
: 花的时间
: 以前没怎么弄过,请教大家什么工具最方便易用而且准确?gprof如何?
: 先谢过各位猛将~

--

※ 来源:·WWW 未名空间站 海外: mitbbs.com 中国: mitbbs.cn·[FROM: 98.234.]
	
		
	[ 6 ]

发信人: JasonTsai (Jason), 信区: Programming
标 题: Re: 大家都用什么工具来profile C/C++程序
发信站: BBS 未名空间站 (Fri May 1 00:04:15 2009)

Thanks a million!

【 在 mlwei (pumpkin) 的大作中提到: 】
: To find which function is using most of the time (hot functions) use gprof
.
: It'll create a trace file and you can use gprof to generate a report later
: on.
: For a particular hot function, if you'd like to know whether it is
spending
: time on memory / floating point or integer instructions, use intel VTune.
: If most of the time is spent in memory instructions, cache optimizations
are
: important (tiling, prefetching).
: If there are a lot of floating point instructions, compiling it to 64 bit
: binary could help, because that'll allow the processor to use SSE
registers
: for your your code.
: ...................

--

※ 来源:·WWW 未名空间站 海外: mitbbs.com 中国: mitbbs.cn·[FROM: 70.240.]

		
	[ 7 ]

发信人: cosmo2003 (cosmo2003), 信区: Programming
标 题: Re: 大家都用什么工具来profile C/C++程序
发信站: BBS 未名空间站 (Fri May 1 02:44:33 2009)

If using Mac, I found shark to be very useful:

http://developer.apple.com/tools/sharkoptimize.html

【 在 JasonTsai (Jason) 的大作中提到: 】
: 最近需要分析一个程序的性能瓶颈,所以需要profile这个程序,分析每个function里
: 花的时间
: 以前没怎么弄过,请教大家什么工具最方便易用而且准确?gprof如何?
: 先谢过各位猛将~

--

※ 来源:·WWW 未名空间站 海外: mitbbs.com 中国: mitbbs.cn·[FROM: 128.12.]
	
		
	[ 8 ]

发信人: thrust (祝阳阳早日康复), 信区: Programming
标 题: Re: 大家都用什么工具来profile C/C++程序
发信站: BBS 未名空间站 (Fri May 1 13:51:47 2009)

You don't really need 64-bit to enable SSE/2/3. gcc have separate option for
this. 64-bit just enable them by default (as it's also required by ABI).
【 在 mlwei (pumpkin) 的大作中提到: 】
: To find which function is using most of the time (hot functions) use gprof
.
: It'll create a trace file and you can use gprof to generate a report later
: on.
: For a particular hot function, if you'd like to know whether it is
spending
: time on memory / floating point or integer instructions, use intel VTune.
: If most of the time is spent in memory instructions, cache optimizations
are
: important (tiling, prefetching).
: If there are a lot of floating point instructions, compiling it to 64 bit
: binary could help, because that'll allow the processor to use SSE
registers
: for your your code.
: ...................

--

※ 来源:·WWW 未名空间站 海外: mitbbs.com 中国: mitbbs.cn·[FROM: 76.234.]
	
		
	[ 9 ]

发信人: mlwei (pumpkin), 信区: Programming
标 题: Re: 大家都用什么工具来profile C/C++程序
发信站: BBS 未名空间站 (Fri May 1 14:26:55 2009)


【 在 thrust (祝阳阳早日康复) 的大作中提到: 】
: You don't really need 64-bit to enable SSE/2/3. gcc have separate option
for
: this. 64-bit just enable them by default (as it's also required by ABI).

Thanks. good to know


: .
: spending
: are
: registers

--

※ 来源:·WWW 未名空间站 海外: mitbbs.com 中国: mitbbs.cn·[FROM: 216.239.]
	
		
	[ 10 ]

发信人: zhangfei (Leo Kamis), 信区: Programming
标 题: Re: 大家都用什么工具来profile C/C++程序
发信站: BBS 未名空间站 (Sat May 2 12:46:16 2009), 转信

To be frank, this is one most difficult problem.

If in windows platform:
- If it is Intel CPU, intel vtune.
- If it is AMD CPU, AMD's free profiler (forgot the name, codeanalyst?)
- Microsoft's free kernrate tool

If it is windows platform, IO limited or problem is not in your own code (
like
graphic driver problem).
- use system internal's process explorer profiler, give u call stacks.

If it is in Linux
- oprofile
- valgrid?

If you are almost sure where is your problem.
- just use -- timerstart(), ..., timerend(), printf().
in windows, it is queryperformancecounter() and queryperformancefrequency
()


Good luck

【 在 JasonTsai (Jason) 的大作中提到: 】
: 最近需要分析一个程序的性能瓶颈,所以需要profile这个程序,分析每个function里
: 花的时间
: 以前没怎么弄过,请教大家什么工具最方便易用而且准确?gprof如何?
: 先谢过各位猛将~

--

※ 来源:·BBS 未名空间站 海外: mitbbs.com 中国: mitbbs.cn·[FROM: 71.112.]
 
	
		
	[ 11 ]

发信人: shaoyi (一休), 信区: Programming
标 题: Re: 大家都用什么工具来profile C/C++程序
发信站: BBS 未名空间站 (Sun May 31 01:30:42 2009)

xperf非常好,你可以试试。
不过想要profile memory,基本没戏。。。
【 在 JasonTsai (Jason) 的大作中提到: 】
: 最近需要分析一个程序的性能瓶颈,所以需要profile这个程序,分析每个function里
: 花的时间
: 以前没怎么弄过,请教大家什么工具最方便易用而且准确?gprof如何?
: 先谢过各位猛将~

--

※ 来源:·WWW 未名空间站 海外: mitbbs.com 中国: mitbbs.cn·[FROM: 71.231.]
	
		
	[ 12 ]

发信人: cuixue (我是勤劳勇敢聪明熊), 信区: Programming
标 题: Re: 大家都用什么工具来profile C/C++程序
发信站: BBS 未名空间站 (Sun May 31 18:46:14 2009)

On windows, XPerf is also a very good tool.
【 在 zhangfei (Leo Kamis) 的大作中提到: 】
: To be frank, this is one most difficult problem.
: If in windows platform:
: - If it is Intel CPU, intel vtune.
: - If it is AMD CPU, AMD's free profiler (forgot the name, codeanalyst?)
: - Microsoft's free kernrate tool
: If it is windows platform, IO limited or problem is not in your own code (
: like
: graphic driver problem).
: - use system internal's process explorer profiler, give u call stacks.
: If it is in Linux
: ...................
*算法中的''折半''
在很多算法中都会用到''折半''(或者叫二分)这个技巧,和所有算法一样,在实现时的一个难点就是边界问题。在折半中,low和high的值不断接近,最终不满足''low<=high''(注意@@color(red):有等于@@)的条件,但是跳出循环后,最后定位到的点到底是最后的low的值还是最后high的值呢?
在不满足''low<=high'',即low>high的前一瞬间,low=high,mid=(low+high)/2=low=high,然后分两种情况讨论:(下面假设最终要的是递增序列)
>1、''arr[mid]>value'',则high=mid-1,跳出循环;此时,二分查找的位置就应该在low那个位置;
>2、''arr[mid]<value'',则low=mid+1,跳出循环;此时,二分查找的位置还是应该在low那个位置;
>>需要注意的是:1、这里说的''查找的位置'',指的是第一个不满足有序的点的位置,将点插入那个位置之前要把那个位置以后(@@color(red):包括那个位置@@)的点都往后移一位;(如果你的''“查找的位置”''的定义不同,那也许就不是low,而是high了)2、递减序列也是同理的
>>>具体代码见这里:[[代码发芽网|http://fayaa.com/code/view/5374/]]
*''while循环''
很多算法都涉及循环过程,特别是回溯法。一般,在while的条件里写上最终''跳出循环的条件'',而在while循环体中,每次循环''只做一步'',按照这个思路写的话会顺畅很多。例子如皇后算法,见[[代码发芽网|http://fayaa.com/code/view/5441/]]
快速排序根据''参照点不同''主要有三类,一个是总是以''最左边的点''为参照;另一个是总是以''中间点''为参照;第三类是总是以''最右边的点''为参照点(和第一个类似);根据''指针移动的方向''可以分为两类:一个是''相向''的,即面对面的;另一个是''同一方向的'';(具体见Algorithm Gossip)

这类问题(排序),特别是递归的时候,最麻烦的就是''边界问题'':
*以最左边的点为参照(相向)
>由于有可能所有右边的点''都小于''参照,那么在++的时候就会数组越界,所以在left和right指针不断++(或{{{--}}})之前''要判断是否越界''
*以中间点为参照(相向)
>用一个''中间变量保存参照'',所以‘’参照点加入排序‘’。也正因为如此,left和right指针在比较时不会越界,最终肯定会在参照点"相会";(具体见Algorithm Gossip)<位置指针加减的位置还是很有讲究的,写一遍就知道了>
*同向移动
>由于同向移动时是顺序遍历,所以''边界很好控制'',推荐使用。(具体见Algorithm Gossip)
<<<
because of the limitations of MBR partition tables, which restrict a disk partition's size to a maximum of 2.19 TB (2.19 × 1012 bytes) . GPT allows for a maximum disk and partition size of 9.4 ZB (9.4 × 1021 bytes) .(参考[[wikipedia|http://en.wikipedia.org/wiki/GUID_Partition_Table]])
<<<
<code bash>
[root@localhost ~]# parted /dev/sdb
<parted> mklabel gpt  #这一步是设定你要做的分区的type
<parted> print
<parted>mkpart primary 1 267350 #设置分区容量,单位是M
<parted> print
<parted> quit
[root@localhost ~]# mkfs.ext3 /dev/sdb1
[root@localhost ~]# mount /dev/sdb1 /mnt/xxx
[root@localhost ~]# df -h
</code>
*Ref
#[[parted管理分区|http://www.turbolinux.com.cn/turbo/wiki/doku.php?id=%E7%B3%BB%E7%BB%9F%E7%AE%A1%E7%90%86:parted]]
#[[Linux支持大于2T硬盘总结|http://www.stwind.org/zzchm2/0827.html]]
[[快速排序]]
[[合并排序(merge sort)]]
参考一:[[Windows平台|http://sunxiunan.com/?p=1543]]
1,[[WinMerge|http://winmerge.org/]]
2,[[Sysinternals|http://technet.microsoft.com/en-us/sysinternals/default.aspx]]套件,windows开发必备。
3,[[Windbg|http://www.microsoft.com/whdc/Devtools/Debugging/default.mspx]],windows调试必备。
4,[[Debug Diagnostic Tool|http://www.microsoft.com/downloadS/details.aspx?FamilyID=28bd5941-c458-46f1-b24d-f60151d875a3&displaylang=en]],检查memory leak很好用。
5,[[bitnami stacks|http://bitnami.org/stacks]],如果你搞什么php,ruby,python,mysql之类的web开发,这里面的集成安装包必有一款适合你。不想安装的还可以下载 vmware镜像文件。
6,[[VNC|http://portableapps.com/apps/utilities/teamviewer_portable]]类的软件
7,Picpick,抓屏软件,非常推荐。
8,版本管理工具,可以用subversion或者[[git|http://github.com/guides/using-git-and-github-for-the-windows-for-newbies]]。github算是个不错的选择。我经常把小代码片段贴到gist中。其中 [[visualsvn|http://www.visualsvn.com/]]有免费服务器程序下载。
9,网络相关开发,可以下载抓包工具[[wireshark|http://www.wireshark.org/]](原名ethereal)。http也可以试试这个Fiddler
10,VMWare虚拟机,最好搞一个,里面装上Debian,玩玩Linux,另外装个干净的windowsXP,压缩起来备用,测试中经常会用到。
安装w32codecs后,理论上就可以播放大部分格式的影片了,但是如果碰到如题的问题,可按照如下步骤解决:
#在中断下播放,查看输出信息
>mplayer *.rmvb 
#针对错误,进行处理。比如我输出的信息其中有一段是:
>Opening audio decoder: [faad] AAC (MPEG2/4 Advanced Audio Coding)
>FAAD: compressed input bitrate missing, assuming 128kbit/s!
    所以,问题处在音频输出上。
#验证问题。此处验证是否是处在audio上,运行
>mplayer *.rmvb -nosound
    结果,电影就能正常播放了,说明问题就是处在音频输出上
#运行一下命令,查看可用的音频输出
>mplayer *.rmvb -ao help
    输出的结果是:
>Available audio output drivers:
>	oss	OSS/ioctl audio output
>	alsa	ALSA-0.9.x-1.x audio output
>	arts	aRts audio output
>	esd	EsounD audio output
>	pulse	PulseAudio audio output
>	jack	JACK audio output
>	nas	NAS audio output
>	sdl	SDLlib audio output
>	openal	OpenAL audio output
>	mpegpes	DVB audio output
>	v4l2	V4L2 MPEG Audio Decoder output
>	null	Null audio output
>	pcm	RAW PCM/WAVE file writer audio output
#一个个尝试,更改mplayer的音频输出(我是在它的图形界面上该的),最终设为alsa能正常播放了。

Linux下很多问题都能按照这个思路解决。调式,查看信息,控制变量等等都是很有用的方法。
!!!Index Layer设计
主要有两部分:Heap File和B+树
Heap File是用来保存record的结构(具体为什么叫heap还有待发掘),即保存数据库内容的地方

关于heap file可能是这么理解的,我这层维护一个heapfile的结构,里面保存的是record的信息和内容,对record的读和写由heapfile这一层转发,变成对相关page的读和写,我只要传给你tableID(文件名)和pageID(page号)。
总结来看就是
插入:读取上次写的page,看能都装的下,是则跟新page内容并写回,否则向storage申请新页并写回 -> 在B+树中插入新节点,内容是PageID和RID(page中的偏移)
查找:根据B+树查找RID(page中的偏移)和PID ---> 从B+树跟节点取得TableID,和PageID一起向storage读取page  --->根据RID读到record的内容
windows下参照:[[六款主流数据恢复软件(绿色版)下载|http://hi.baidu.com/zhaodx/blog/item/bad20f46203f08086b63e558.html]],但恢复前可先用Everything扫一下文件是不是真的删掉了。
参考:[[这里|http://kangyunqiang.blog.51cto.com/674292/145969]]
1、linux系统函数调用(待测试):
>{{{int fd = open("file.txt", O_RDONLY);}}}
>{{{int i=read(fd, buf, length);}}}
>{{{另:open需要include  <sys/types.h>  <sys/stat.h>  <fcntl.h> , 而read,write只需要#include   <unistd.h>就行了}}}

2、ANSI C的stdio.h中定义的结构(流式)
>用{{{FILE *fp}}}来定义一个流,以后的操作就都可以在这个流“对象”上了
>{{{fputs("string" ,fp);}}}
>{{{fgets(buf, len,fp);}}}
>{{{fread(buf,  size, n, fp);}}}
>{{{fwrite(buf,  size, n, fp);}}}
>其他见cplusplus的[[文档|http://www.cplusplus.com/reference/clibrary/cstdio/fgets/]],它有针对文件和标准输入输出的两套API,但是基本类似

3、CPP的stream类
>打开:{{{fstream file;  file.open("filename", ios::in|ios::binary,0)}}}
>文本读写:
>>用流操作符号,还可以格式化{{{file2<<"I Love You";    file1<<setprecision(5)<<3.1415926}}}
>>读取行:{{{std::getline(file, str)}}},或者{{{file.getline(charArr, arrLen);}}};总结见[[这里|http://www.cnblogs.com/JCSU/articles/1190685.html]]
>按字节读:
>>1、一个字节:{{{file.get(); file.put('c');}}}
>>2、多个:{{{file.read(buf,  num);  file.write(buf,  num);}}}
>''注意'':
>>考虑''缓存'',及时''flush'',或者''close''即可。
>>eof的问题,具体见[[这里|http://www.daniweb.com/forums/post155265-18.html]]和[[这里|http://www.daniweb.com/forums/thread159024.html]];但在VS2008上试了下没问题,不过还是尽量别用eof来判断结束
两种方法:
1、''prim''算法
>考虑''点''
>''维护的数据结构'':所有边(edge[NUM*NUM]),已取得的点(u),待取的点(v),v中每个点到u的最短距离值(closest[]),每次取得的最小边的值(value)
>''初始情况'':任取一个点
>''演算'':有closest得到最小边(从v到u)的值 -> 将点x从v中取出,放到u中  -> 更新在v中与x有关的点的closest值
>''适用'':稠密图

2、''kruscal''算法
>''考虑边''
>''维护的数据结构'':边(edge struct<x,y,weight>),边的集合(以边的weight排序的multimap),DisjointSet类(判断回边),保存结果(vector按顺序保存)
>''初始情况'':无
>''演算'':不断从multimap中得到最小边,判断是否是回边(DisjointSet结构,用root来代表同一连通分量),加入result或舍弃
>''适用'':稀疏图
>其他:DisjointSet的简易结构见[[这里|http://www.cppblog.com/lzmagic/archive/2009/04/10/79542.html]]

两者代码见这里:[[代码发芽网|http://fayaa.com/code/view/5310/#]]或者[[githup|http://gist.github.com/176973]](这两个都是贴代码的地方)
!!!STL
对于map、set等不允许有重复key或元素的容器来说,insert操作如果遇到重复的,则是''不做任何操作'',而''不是覆盖''

!!!IO
#''cin.get(char*, num);'' 读到num个字符或换行符,如果读到换行符,那么这个''换行符还留在输入buffer''中,用cin.ignore函数去除(见[[这里|http://www.java-samples.com/showtutorial.php?tutorialid=455]]);如果遇到流错误(failbit或badbit),那在''ignore之前'',必须''先恢复流'',因为ignore只在流正常的时候忽略字符,见[[这里|http://www.daniweb.com/forums/thread212120.html]]
''Source:''  [[here|http://blog.chinaitlab.com/html/21/318121-176176.html]]

!!一、格式化数字字符串
sprintf 最常见的应用之一莫过于把整数打印到字符串中,所以,spritnf 在大多数场合可以替代itoa。

如:
//把整数123 打印成一个字符串保存在s 中。
sprintf(s, "%d", 123); //产生"123"可以指定宽度,不足的左边补空格:
sprintf(s, "%8d,%8d", 123, 4567); //产生:" {{{     123,    4567}}}"当然也可以左对齐:
sprintf(s, "%-8d,%8d", 123, 4567); //产生:"{{{123     ,    4567}}}"

也可以按照16 进制打印:
sprintf(s, "%8x", 4567); //小写16 进制,宽度占8 个位置,右对齐
sprintf(s, "%-8X", 4568); //大写16 进制,宽度占8 个位置,左对齐

这样,一个整数的16 进制字符串就很容易得到,但我们在打印16 进制内容时,通常想要一种左边补0 的等宽格式,那该怎么做呢?很简单,在表示宽度的数字前面加个0 就可以了。
sprintf(s, "%08X", 4567); //产生:"000011D7"
上面以"%d"进行的10 进制打印同样也可以使用这种左边补0 的方式。


这里要注意一个符号扩展的问题:比如,假如我们想打印短整数(short)-1 的内存16 进制表示形式,在Win32 平台上,一个short 型占2 个字节,所以我们自然希望用4 个16 进制数字来打印它:
short si = -1;
sprintf(s, "%04X", si);
产 生"FFFFFFFF",怎么回事?因为spritnf 是个变参函数,除了前面两个参数之外,后面的参数都不是类型安全的,函数更没有办法仅仅通过一个"%X"就能得知当初函数调用前参数压栈时被压进来的到底 是个4 字节的整数还是个2 字节的短整数,所以采取了统一4 字节的处理方式,导致参数压栈时做了符号扩展,扩展成了32 位的整数-1,打印时4 个位置不够了,就把32 位整数-1 的8 位16 进制都打印出来了。

如果你想看si 的本来面目,那么就应该让编译器做0 扩展而不是符号扩展(扩展时二进制左边补0 而不是补符号位):
sprintf(s, "%04X", (unsigned short)si);
就可以了。或者:
unsigned short si = -1;
sprintf(s, "%04X", si);

sprintf 和printf 还可以按8 进制打印整数字符串,使用"%o"。注意8 进制和16 进制都不会打
印出负数,都是无符号的,实际上也就是变量的内部编码的直接的16 进制或8 进制表示。

!!二、控制浮点数打印格式

浮点数的打印和格式控制是sprintf 的又一大常用功能,浮点数使用格式符"%f"控制,默认保
留小数点后6 位数字,比如:
sprintf(s, "%f", 3.1415926); //产生"3.141593"
但有时我们希望自己控制打印的宽度和小数位数,这时就应该使用:"%m.nf"格式,其中m 表
示打印的宽度,n 表示小数点后的位数。比如:
sprintf(s, "%10.3f", 3.1415626); //产生:" 3.142"
sprintf(s, "%-10.3f", 3.1415626); //产生:"3.142 "
sprintf(s, "%.3f", 3.1415626); //不指定总宽度,产生:"3.142"

注意一个问题,你猜
int i = 100;
sprintf(s, "%.2f", i);
会打出什么东东来?"100.00"?对吗?自己试试就知道了,同时也试试下面这个:
sprintf(s, "%.2f", (double)i);
第一个打出来的肯定不是正确结果,原因跟前面提到的一样,参数压栈时调用者并不知道跟i相对应的格式控制符是个"%f"。而函数执行时函数本身则并不知道当年被压入栈里的是个整数,于是可怜的保存整数i 的那4 个字节就被不由分说地强行作为浮点数格式来解释了,整个乱套了。不过,如果有人有兴趣使用手工编码一个浮点数,那么倒可以使用这种方法来检验一下你手工编排的结果是否正确。

!!三、字符
/Ascii
码对照

我们知道,在C/C++语言中,char 也是一种普通的scalable 类型,除了字长之外,它与short,int,long 这些类型没有本质区别,只不过被大家习惯用来表示字符和字符串而已。(或许当年该把这个类型叫做"byte",然后现在就可以根据实际情况,使用byte 或short 来把char 通过typedef 定义出来,这样更合适些)于是,使用"%d"或者"%x"打印一个字符,便能得出它的10 进制或16 进制的ASCII 码;反过来,使用"%c"打印一个整数,便可以看到它所对应的ASCII 字符。以下程序段把所有可见字符的ASCII 码对照表打印到屏幕上(这里采用printf,注意"#"与"%X"合用时自动为16 进制数增加"0X"前缀):
for(int i = 32; i < 127; i++) {
printf("[ %c ]: %3d 0x%#04X\n", i, i, i);
}

!!四、连接字符串

sprintf 的格式控制串中既然可以插入各种东西,并最终把它们"连成一串",自然也就能够连接字符串,从而在许多场合可以替代strcat,但sprintf 能够一次连接多个字符串(自然也可以同时在它们中间插入别的内容,总之非常灵活)。比如:
char* who = "I";
char* whom = "CSDN";
sprintf(s, "%s love %s.", who, whom); //产生:"I love CSDN. "
strcat 只能连接字符串(一段以"结尾的字符数组或叫做字符缓冲,null-terminated-string),但有时我们有两段字符缓冲区,他们并不是以 "结尾。比如许多从第三方库函数中返回的字符数组,从硬件或者网络传输中读进来的字符流,它们未必每一段字符序列后面都有个相应的"来结尾。如果直接 连接,不管是sprintf 还是strcat 肯定会导致非法内存操作,而strncat 也至少要求第一个参数是个null-terminated-string,那该怎么办呢?我们自然会想起前面介绍打印整数和浮点数时可以指定宽度,字符串也一样的。比如:
char a1[] = {'A', 'B', 'C', 'D', 'E', 'F', 'G'};
char a2[] = {'H', 'I', 'J', 'K', 'L', 'M', 'N'};
如果:
sprintf(s, "%s%s", a1, a2); //Don't do that!
十有八九要出问题了。是否可以改成:
sprintf(s, "%7s%7s", a1, a2);
也没好到哪儿去,正确的应该是:
sprintf(s, "%.7s%.7s", a1, a2);//产生:"ABCDEFGHIJKLMN"
这可以类比打印浮点数的"%m.nf",在"%m.ns"中,m 表示占用宽度(字符串长度不足时补空格,超出了则按照实际宽度打印),n 才表示从相应的字符串中最多取用的字符数。通常在打印字符串时m 没什么大用,还是点号后面的n 用的多。自然,也可以前后都只取部分字符:
sprintf(s, "%.6s%.5s", a1, a2);//产生:"ABCDEFHIJKL"
在许多时候,我们或许还希望这些格式控制符中用以指定长度信息的数字是动态的,而不是静态指定的,因为许多时候,程序要到运行时才会清楚到底需要取字符数组 中的几个字符,这种动态的宽度/精度设置功能在sprintf 的实现中也被考虑到了,sprintf 采用"*"来占用一个本来需要一个指定宽度或精度的常数数字的位置,同样,而实际的宽度或精度就可以和其它被打印的变量一样被提供出来,于是,上面的例子 可以变成:
sprintf(s, "%.*s%.*s", 7, a1, 7, a2);
或者:
sprintf(s, "%.*s%.*s", sizeof(a1), a1, sizeof(a2), a2);
实际上,前面介绍的打印字符、整数、浮点数等都可以动态指定那些常量值,比如:
sprintf(s, "%-*d", 4, 'A'); //产生"65 "
sprintf(s, "%#0*X", 8, 128); //产生"0X000080","#"产生0X
sprintf(s, "%*.*f", 10, 2, 3.1415926); //产生" 3.14"

!!五、打印地址信息

有时调试程序时,我们可能想查看某些变量或者成员的地址,由于地址或者指针也不过是个32 位的数,你完全可以使用打印无符号整数的"%u"把他们打印出来:
sprintf(s, "%u", &i);
不过通常人们还是喜欢使用16 进制而不是10 进制来显示一个地址:
sprintf(s, "%08X", &i);
然而,这些都是间接的方法,对于地址打印,sprintf 提供了专门的"%p":
sprintf(s, "%p", &i);
我觉得它实际上就相当于:
sprintf(s, "%0*x", 2 * sizeof(void *), &i);
利用sprintf 的返回值
较少有人注意printf/sprintf 函数的返回值,但有时它却是有用的,spritnf 返回了本次函数调用最终打印到字符缓冲区中的字符数目。也就是说每当一次sprinf 调用结束以后,你无须再调用一次strlen 便已经知道了结果字符串的长度。如:int len = sprintf(s, "%d", i);对于正整数来说,len 便等于整数i 的10 进制位数。下面的是个完整的例子,产生10 个[0, 100)之间的随机数,并将他们打印到一个字符数组s 中,以逗号分隔开。
#include
#include
#include
int main() {
srand(time(0));
char s[64];
int ffset = 0;
for(int i = 0; i < 10; i++) {
offset += sprintf(s + offset, "%d,", rand() % 100);
}
s[offset - 1] = '\n';//将最后一个逗号换成换行符。
printf(s);
return 0;
}
设想当你从数据库中取出一条记录,然后希望把他们的各个字段按照某种规则连接成一个字符串时,就可以使用这种方法,从理论上讲,他应该比不断的strcat 效率高,因为strcat 每次调用都需要先找到最后的那个''的位置,而在上面给出的例子中,我们每次都利用sprintf 返回值把这个位置直接记下来了。

!!六、使用

sprintf的常见问题

sprintf 是个变参函数,使用时经常出问题,而且只要出问题通常就是能导致程序崩溃的内存访问错误,但好在由sprintf 误用导致的问题虽然严重,却很容易找出,无非就是那么几种情况,通常用眼睛再把出错的代码多看几眼就看出来了。

缓冲区溢出
第一个参数的长度太短了,没的说,给个大点的地方吧。当然也可能是后面的参数的问题,建议变参对应一定要细心,而打印字符串时,尽量使用"%.ns"的形式指定最大字符数。
忘记了第一个参数低级得不能再低级问题,用printf 用得太惯了。//偶就常犯。
变参对应出问题
通常是忘记了提供对应某个格式符的变参,导致以后的参数统统错位,检查检查吧。尤其是对应"*"的那些参数,都提供了吗?不要把一个整数对应一个"%s",编译器会觉得你欺她太甚了(编译器是obj 和exe 的妈妈,应该是个女的,:P)。

!!七、其他

strftime
sprnitf 还有个不错的表妹:strftime,专门用于格式化时间字符串的,用法跟她表哥很像,也是一大堆格式控制符,只是毕竟小姑娘家心细,她还要调用者指定缓冲区的最大长度,可能是为了在出现问题时可以推卸责任吧。这里举个例子:
time_t t = time(0);
//产生"YYYY-MM-DD hh:mm:ss"格式的字符串。
char s[32];
strftime(s, sizeof(s), "%Y-%m-%d %H:%M:%S", localtime(&t));
sprintf 在MFC 中也能找到他的知音:CString::Format,strftime 在MFC 中自然也有她的同道:
CTime::Format,这一对由于从面向对象哪里得到了赞助,用以写出的代码更觉优雅
!!!模板与多文件工程 (Templates and multiple-file projects)
原文章:[[这里|http://www.prglab.com/cms/pages/c-tutorial/advanced-concepts/templates.php]]
从编译器的角度来看,模板不同于一般的函数或类。它们在需要时才被编译(compiled on demand),也就是说一个模板的代码直到需要生成一个对象的时候(instantiation)才被编译。当需要instantiation的时候,编译器根据模板为特定的调用数据类型生成一个特殊的函数。

当工程变得越来越大的时候,程序代码通常会被分割为多个源程序文件。在这种情况下,通常接口(interface)和实现 (implementation)是分开的。用一个函数库做例子,接口通常包括所有能被调用的函数的原型定义。它们通常被定义在以.h 为扩展名的头文件 (header file) 中;而实现 (函数的定义) 则在独立的C++代码文件中。

模板这种类似宏(macro-like) 的功能,对多文件工程有一定的限制:函数或类模板的实现 (定义) 必须与原型声明在同一个文件中。也就是说我们''不能再将接口(interface)存储在单独的头文件中'',而''必须''将接口和实现放在使用模板的''同一个文件''中。

回到函数库的例子,如果我们想要建立一个函数模板的库,我们不能再使用头文件(.h) ,取而代之,我们应该生成一个模板文件(template file),将函数模板的接口和实现 都放在这个文件中 (这种文件没有惯用扩展名,除了不要使用.h扩展名或不要不加任何扩展名)。在一个工程中多次包含同时具有声明和实现的模板文件并不会产生链接错误 (linkage errors),因为它们只有在需要时才被编译,而兼容模板的编译器应该已经考虑到这种情况,不会生成重复的代码。

--@@color(red):暂时还不清楚怎么构建模板类@@,目前解决办法就把声明和实现放在同一.h文件中吧--
详见STL的源码,它是典型的模板库,我们平时引入的都是如<vector>这样的文件,但看vector文件中存的是什么呢?其实它就是负责引入<str_vector.h>这个头文件,而这个文件里面是模板函数、类的原型加上它们的实现。所以模板声明和实现肯定是要在一起的。STL只不过是重命名了一下,间接导入,这样文件也好管理一些。
这个问题还是有一定[[故事背景|http://en.wikipedia.org/wiki/Tower_of_Hanoi]]
''递归实现''
问题的递归解答出奇地简单:(假设有a,b,c三个柱子,要从a移到c)
>''归纳基础:''n为1,只要把盘子从a移动到c即可
>''归纳过程:''
>>1、将a上的前n-1个盘子移到b(temp)
>>2、将a的第n个(最底下的)盘子移到c,即这个盘子完成移动
>>3、将b上的n-1个盘子移到c,即递归执行,此时a成了temp
具体解释参考[[这里|http://catouse.com/post/62.html]]

''非递归实现''
盘子的移动时有''规律''的,总结如下:(假设是要从A移动到C)
>总共有两种情况,一种是盘子个数n为偶数的,另一种是n为奇数;想象,将3个柱子排成品字形,如果n是偶数,那么顺序是A、B、C,否则顺序是A、C、B;重复进行如下步骤即可:(以下是''规律'',没有为什么,多移动几次就知道了)
>>1、将最小的盘子(即1号盘子)向右移动
>>2、对剩下的两个柱子,如果我空的,那么把不空的那个柱子上的最顶端的盘子移到空柱子;否则比较两个柱子最上的盘子的值,把小的移到大的那里(本质是维护hanoi的结构——小的要叠在大的上面)
具体解释及程序源代码见[[这里|http://blog.minidx.com/2008/01/30/457.html]]
*康佳IS96(7)N
**[[介绍|http://roll.sohu.com/20110217/n303241806.shtml]]
**[[京东|http://search.360buy.com/search?keyword=LC40IS96N&w=1]]
*TCL mitv
**与CNTV合作

@@color(red):Points@@
*是否能看央视和地方台
*网速是否够,是否给力
*是否需要第三方附件(如体感游戏等)
*附加功能(wifi,USB,外置存储格式<FAT?NTFS?>,挂壁<承重墙?>)

@@color(red):Ques@@
*mitv目前是否集成了CNTV
*是否需要外置配件
**[[海尔与搜狐的合作|http://www.cheaa.com/Product/DH/HangQing/2009-4/131095_5.html]]
!!!My Configuration
># /etc/fstab: static file system information.
>#
># <file system> <mount point>   <type>  <options>       <dump>  <pass>
>proc            /proc           proc    defaults        0       0
># /dev/sda5
>UUID=e11f3e42-bb72-4567-ad87-ef453dfeeb81 /               ext3    relatime,errors=remount-ro 0       1
># /dev/sda6
>UUID=91c59827-0bb3-4da2-8bd3-fccc197535c2 none            swap    sw              0       0
># /dev/sdb5
>UUID=48BE-9243 /media/G vfat user,auto,exec,rw,suid,async,umask=007,uid=1000,codepage=936,iocharset=cp936 0    0
># /dev/sdb6
>UUID=22FA-4B84 /media/H vfat user,auto,exec,rw,suid,async,umask=007,uid=1000,codepage=936,iocharset=utf8 0    0
># /dev/sdb7
>UUID=DA3B-B89D /media/I vfat user,auto,exec,rw,suid,async,umask=007,uid=1000,codepage=936,iocharset=utf8 0   0 
># /dev/sdb8
>UUID=917D-25B2 /media/J vfat user,auto,exec,rw,suid,async,umask=007,uid=1000,codepage=936,iocharset=utf8 0   0
># /dev/sda1
>UUID=40E6-FCD6 /media/C vfat user,auto,exec,rw,suid,async,umask=007,uid=1000,codepage=936,iocharset=utf8 0    0
># /dev/sda3
>UUID=886C94EE6C94D7F0 /media/D ntfs user,auto,exec,rw,suid,async,umask=007,uid=1000,codepage=936,iocharset=utf8 0    0
># /dev/sda4
>UUID=0054A3CF54A3C5AE  /media/E ntfs user,auto,exec,rw,suid,async,umask=007,uid=1000,codepage=936,iocharset=utf8 0    0
>/dev/scd0       /media/cdrom0   udf,iso9660 user,noauto,exec,utf8     0    0
''注:iocharset=utf8可可解决中文乱码问题,网上说cp936也行,但对我来说不行。//另//,utf8极其容易写成uft8,很囧的错误''


!!!Some useful command
''Show uuid of each partition''
>ls -al /dev/disk/by-uuid/
''Show the mount information of partitions at present''
>df -h
''Show the format of each partition''
>sudo fdisk -l
''check on more details on the device''
>sudo vol_id /dev/sda3

!!!reference
#[[fstab with uuid|http://linux.byexamples.com/archives/321/fstab-with-uuid/]]
#[[ How to edit and understand /etc/fstab|http://www.tuxfiles.org/linuxhelp/fstab.html#one-two]]
#[[How to mount you NTFS volume|http://www.linux-ntfs.org/doku.php?id=howto:mount]]
#[[iocharset&codepage|http://www.linuxfromscratch.org/lfs/view/6.4/chapter08/fstab.html]]
#[[只有root用户才能挂载的问题|http://hi.baidu.com/aztack/blog/item/e69ac0ce1abd370192457ecd.html]]
*''简体中文TiddlyWiki相关网站:''
>TiddlyWiki使用与工具网站:
##以渐进步骤说明,综合了很多资源与问题:[[TiddlyWiki说明书|tiddlywiki.html]]
##以推进TiddlyWiki在大陆的使用为任务的:[[TiddlyWiki入门|http://www.tiddlywiki.cn]]
##一个开源项目研究小组,目前更新较慢:[[TiddlyWiki中文化|http://gf.cs.hit.edu.cn/projects/tiddlywiki]]
##blog的形式讲述TiddlyWiki:[[总而言之,统而言之|http://jiangzhanyong.com/projects/tiddlywiki-chs]]
##最新的简体繁体中文版本下载,以及耐心的版主指点:[[tiddlywiki中文支持google group|http://groups.google.com/group/TiddlyWiki-zh]]
>TiddlyWiki应用相关网站:
##DNN(Dotnetnuke)教程网:[[Dotnetnuke教程|http://dnn.linklib.cn]]
##教你如何做美食,提供订阅服务哦:[[菜谱网|cookbook.linklib.cn]]。
##关于新鲜web2.0/business2.0观察的网站:[[web2.0观察|bs2.linklib.cn]]。
##记录作者学车中考虑的问题和对菜鸟的提示:[[学车记|driver.linklib.cn]]。
##关于头发行业的信息和知识,尤其是定制型真人发:[[定制型真人发/织发补发|hair.linklib.cn]]。
##作者对于硬币收藏和知识研究:[[硬币/分币|coin.linklib.cn]]。
##参与2008奥运,将奥运旗帜送上珠穆朗玛峰:[[奥运旗帜上珠穆朗玛峰|link8848.linklib.cn]]。
*''繁体中文TiddlyWiki相关网站:''
**自然的,Bram Chen的网站被我放在第一位,我从他哪里得到太多的东西,感谢他。[[PrinceTiddlyWiki|ptw.sourceforge.net/]]。
**[[MilchFlasche 的 TiddlyWiki之美|http://linshi.twbbs.org/usr/m/milchflasche/TiddlyWiki.html]]。
**老猫的介绍文章:[[TiddlyWiki真好玩|http://b-oo-k.net/blog/post/1/400]] 和 [[TiddlyWiki安装与使用指南|http://b-oo-k.net/blog/post/1/401]]。
**从这里也得益良多,基于内容的使用指南:[[中文使用教学|http://web.nlhs.tyc.edu.tw/wiki/TiddlyWikiTutorialTW.html]]。
**~TiddlyWiki 的[[中文 google group|http://groups.google.com/group/PrinceTiddlyWiki]]。
*''英文网站:''
**[[TiddlyWiki 官方网站|http://www.tiddlywiki.com]]和[[TiddlyWiki的另一官方网站|http://www.tiddlywiki.org]]
**~TiddlyWiki 的[[英文 google group|http://groups.google.com/group/TiddlyWiki]]。
**官方推荐教学网站:[[TiddlyWikiTutorial|http://www.blogjones.com/TiddlyWikiTutorial.html]]。
**官方推荐 ~TiddlyWiki 好用 Tips 网站:[[TiddlyWikiTips|http://tiddlywikitips.com/]]。
**官方推荐另一个好用的 Tips 网站:[[zRenard's personal web notebook|http://www.zrenard.com/tiddlywiki/tiddlywiki.html]]
**有很多插件的[[Lewcid|ttp://tw.lewcid.org/]]
**教我们将Google Adsense添加到TiddlyWiki的,虽然我用了没有成功:[[Adsense in TiddlyWiki|http://15black.bluedepot.com/twtests/adsense.html]]
**很多好看的主题和皮肤的 [[tiddlythemes|http://tiddlythemes.com/#Home]]
**主页很好看的[[冯正青个人主页|http://knightfeng.org/]] 
*''更多使用或者正在研究TiddlyWiki的人们:''
**<<tiddler TiddlyWikiAdaptations>>
*''更多资源来源:''
**<<tiddler ResourceLinks>>
一个硬盘最多能有四个主分区,或者三个主分区+一个扩展分区。所以在刚开始分区的时候,注意
#不要用满上面的限制
#扩展分区尽量大一点,逻辑分区尽量多一点,方便今后更改分区
>这次就遇到有两个主分区+一个很小的扩展分区,然后剩下的那块只能分割成主分区,但他要装linux,需要两个分区,这时就囧了。

参考:[[这里|http://baike.baidu.com/view/55597.htm]]
''Reference:''[[here|http://ppsly.blogspot.com/2009/04/zzgrub.html]]

文章的''前提''是在宿主系统是''Windows'',如果是Linux的话就不用装Grub了,因为它默认的启动管理器就是grub。
1、安装WinGrub,详细介绍见[[这里|http://ppsly.blogspot.com/2009/04/zzgrub.html]]和[[这里|#]],使Grub成为Windows的默认启动管理器
2、下载IOS文件(据说Live CD可能有问题,要用alternative CD,未测试),放到某''FAT32''分区的''根目录''下
3、''仍然''在那个FAT32分区下(另一个说法没强调同一FAT32分区,未测试),建立目录,如linux,从ISO文件中解压vmlinuz和initrd.img到linux目录''不要放其他文件'',否则可能中途退出(未测试)。
4、编辑Wingrub的menu.lst,如c:\boot\grub\menu.lst,代码如下:
>timeout 10
>############################这是第一种写法 
>title fc4install
>root&nbsp; &nbsp; (hd0,1)
>kernel (hd0,1)/linux/vmlinuz 
>initrd (hd0,1)/linux/initrd.img
>
>############################这是第二种格式的写法
>title fc4install
>root&nbsp; &nbsp; (hd0,1)
>kernel /linux/vmlinuz&nbsp;&nbsp;ro root=/dev/hda2
>initrd /linux/initrd.img
>
>#######################
>title WindowsXP
>root (hd0,0)
>makeactive
>chainloader +1
[[不用临时变量,交换两个数的值]]
''Source:''[[here|http://songfei.org/blog/2008/12/28/%E5%85%B3%E4%BA%8E%E7%BB%93%E6%9E%84%E4%BD%93%E6%8C%87%E9%92%881%E7%9A%84%E9%97%AE%E9%A2%98/]]
在读Linux 0.11 内核源代码的时候

linux/kernel/sched.c第26行

>void show_task(int nr,struct task_struct * p)
>{
>    int i,j = 4096-sizeof(struct task_struct);
> 
>    printk("%d: pid=%d, state=%d, ",nr,p->pid,p->state);
>    i=0;
>    while (i<j && !((char *)(p+1))[i])
>        i++;
>    printk("%d (of %d) chars free in kernel stacknr",i,j);
>}

这里面出现了((char *)(p+1))[i]表示形式

分析如下:

首先,p是指向 task_struct 结构的一个指针

所以p+1指向 p+sizeof(task_struct) 这个地址

然后把它进行了强制类型转换,转换成为字符型,这时候就可以用[]按字节进行下标访问了。

注意优先级顺序

(char *)(p+1)

和

(char *)p+1

是不一样的。

这里给出一个程序

>栈顶
>.....
>高地址 q——-
>ABCD {{{//}}}(p+1)指向A所在地址 (char*)q+1指向B所在地址
>EFGH
>低地址 p——-
>abcd{{{//}}}(q-1)指向a所在地址
>efgh

测试程序:

>{{#include <stdio.h>
>struct t {
>       char p[10];
>      char p2[10];
>}t1,t2;
>int main(void)
>{
>       struct t *q=&t1;
>       struct t *p=&t2;
>
>       strcpy(q->p,"ABCD");
>       strcpy(p->p,"abcd");
>       strcpy(q->p2,"EFGH");
>       strcpy(p->p2,"efgh"); 
>       printf("%sn%sn", p,(char *)(p+1));
>      {{{//}}}这里第二个参数打印ABCD,正好是前一个结构题
>       printf("%sn%sn", q,(char *)q+1);
>       {{{//}}}这里第二个参数打印BCD,说明跳过了一字节
>
>       printf("%dn",sizeof(struct t ));
>       printf("%pn%pn",q,q+1);
>       {{{//}}}这两个结果为0X14,正好是十进制的20,即结构体的大小
>       return 0;
>}

运行结果:

$ ./a.out
abcd
ABCD
ABCD
BCD
20
0x804a034
0x804a048

那为什么要指向下一个结构单元呢?

这个函数的主要功能是统计内核栈剩余空间大小,用于内核调试

在老版本内核中,内核堆栈是这么定义的:

union task_union 
{
       struct task_struct task;
       unsigned long stack[INIT_TASK_SIZE/sizeof(long)];
};

内核为每个进程分配一个task_struct结构时,实际上分配两个连续的物理页面(8192字节)底部用作task_struct结构(大小约为1K字节),结构的上面用作内核堆栈(大小约为7K字节)。

上面那段代码是统计unsigned long stack[INIT_TASK_SIZE/sizeof(long)]的为0 的大小的函数。

具体为:

p是task_struct类型的指针,p+1就是p的值加上sizeof(task_struct),也就是说p+1是指定任务数据结构之后的第一个字节

(char *)(p+1)将p+1转换为char类型指针,那么(p+1)[i]实际就是一个char类型数组的第i个元素了,char占一个字节,因此

{{{!}}}((char*)(p+1))[i] = true的条件是任务数据结构以后第i个字节为0。
写得相当轻松的,从编码历史入手的[[字符编码方式轻松解读|http://hi.baidu.com/zou_wei/blog/item/f8cf366d90e37cfc43169426.html]]
阮一峰的[[字符编码笔记|http://www.ruanyifeng.com/blog/2007/10/ascii_unicode_and_utf-8.html]]
基本同[[硬盘安装Linux]]
只不过要下载下载的特殊的文件:
*Ubuntu从这个地址:http://ftp.sjtu.edu.cn/ubuntu/dists/gutsy/main/installer-i386/current/images/netboot/ubuntu-installer/i386/
下载linux和initrd.gz这两个文件,分别对应[[硬盘安装Linux]]中的vmlinuz和initrd.img,相应替换即可。
*Fedora从这个地址:http://ftp.sjtu.edu.cn/fedora/linux/releases/8/Fedora/i386/os/isolinux/
下载vmlinuz和initrd.img。

在grub启动时,选择网络安装的启动项,根据提示一步步走。注意的是:
#''不能用无线'';
#IP如果DHCP不成功的话手动配置;
#源''手动选择'':ftp.sjtu.edu.cn(''不要加ftp://'');
#目录就默认(/ubuntu)
思想是''动态规划'',动态规划的本质是''问题可以被不断分解'',''从0开始,保存子问题的解决方案''
有两中形式:
1、包内所装物品价值最大化
>方法是''“每步最优化”'',这每步最优解就是''子问题的解决方案''
>>见AlgorithmGossip上有很通俗、直观的解释。
2、能将包填满
>方法是''“拆分问题,保存结果矩阵”''
>>见《算法引论》P79
!!!自排序的容器(如map,set等)
两种方法:1、初始化时候指定less方法;2、自定义仿函数
!!!指定less(比较函数)
为什么是只要一个less函数,也就是"<"就可以了呢呢?其实是有道理的。因为只要定义了一个"<"的函数,就可以比较出大于、小于和等于。如下:
>{{{bool less_than(Type &a, Type &b){}}}
>{{{return a<b;}}}
>{{{}}}}
所以,
>if {{{(less_than(x ,y) == true)}}},then ''x<y''
>else if{{{( less_than(y, x) == true )}}},then ''x>y''
>else ''x=y''
而STL内部实现的就是less(当然我们也可以自己实现一个库,用的是larger)
>Ref:[[YSSY|http://bbs.sjtu.edu.cn/bbstcon,board,C,reid,1249661588.html]]和[[cplusplus的例子|http://www.cplusplus.com/reference/stl/multimap/multimap/]]和MSDN上的[[文档|http://msdn.microsoft.com/en-us/library/s44w4h2s.aspx]](见最后一段)。

!!!自定义仿函数
其实是个类,英文是Functor,具体介绍可以看《''The C++ Standard Library''》
它的原理是用一个自定的类,只不过里面肯定会重载"''()''"操作符,所以最主要的还是这个重载函数,它实现的其实也是小于运算。
>Ref:[[cppreference的例子|http://www.java2s.com/Code/Cpp/Map-Multimap/Mapcomparison.htm]]和上面''cplusplus''的例子

其实现在看来,两张方法思路是一样的:''一、''在初始化的时候都要有一个''比较类型''(暂且这么叫它),第一种方法中一般是自己定义的比较函数的类型,用typedef来定义这个类型;第二种方法中这个类型就是Functor了;''二、''都需要一个比较函数,第一种是直接定义的,在初始化的时候赋给它;第二种不用初始化赋值,why?因为这个函数已经包含在类型(Functor)中了

两种方法都实现的例子:[[这里|http://blog.csdn.net/tenglongxun2/archive/2009/07/31/4396915.aspx]]

@@color(blue):跟新理解@@:如内部排序时,调用比较函数时,比较函数的两个对象分别是A、B(按出现的顺序),那么,''它不管你是什么比较函数''(大于、还是小于等),如果比较函数返回true,那么它在容器中就按照A、B顺序(即原顺序)排;如果返回false就按B、A排;这样的效果就是,如果我们定义的是小于函数,那么结果它''正好''是小于的效果(当然也是故意这么设计的)。

!!!序列容器vector,list等
这些容器在排序时,需要显式地调用--algorithm中的--(vector没有自带sort,但是list是自带sort函数的,只需传入一个compare函数)sort排序函数。所以要自定义比较函数的时候只需给sort传入第三个参数(比较函数或Functor''实例对象'')。

!!!其它
实际上STL自带有两个比较函数类(functor),分别是默认的less(不指定即可)和greater,两者都是模板类,使用时要指定类型,如''less<int>()''。而这两个functor具体调用的应该是''<'',''>'',''==''操作符,所以可以在类中重载<或>或==操作符,同样达到自定义的效果。具体见《数据结构与算法C++版》窦延平等 交大出版社版P316。
问题描述见[[这里|http://en.wikipedia.org/wiki/Bin_packing_problem]]
与操作系统中的内存分配算法类似,有如下几种方法:
#First Fit
#Next Fit
#Worst Fit
#Best Fit
#First Fit
……
具体可以见[[这里|http://www.developerfusion.com/article/5540/bin-packing/]]的一系列文章

更复杂是2D装箱算法:
问题描述见[[这里|http://www.cs.sunysb.edu/~algorith/files/bin-packing.shtml]],相关资源见[[豆瓣|http://www.douban.com/note/34766741/]]
*@@bgcolor(#66cc33):P(precision), R(Recall), F(F-measure)@@
参考''Ref1''
*@@bgcolor(#66cc33):AP(Average Precision)@@
它是针对某一个查询q来说,公式如下(参考''Ref1'')
>[img[http://upload.wikimedia.org/math/f/3/4/f347083708617f471ef1129d5dd1c66c.png]]
>>@@''r''@@是结果的rank值(排名)
>>@@''N''@@为检索返回的结果个数
>>@@''rel()''@@是一个''二值''(0,1)函数(结果与查询相关则为1)
>>@@''P(r)''@@的值如下,是当前的在''当前排名之前''的Precision值
>>>[img[http://upload.wikimedia.org/math/e/c/0/ec00cb72e09fa467eaf610b2226f25c8.png]]
{{{
这个指标的评价的是:''Average of precision at each relevant document retrieved''
}}}
举个例子(或者见''Ref3''的8.4.1小节)来说:搜索语句q:''上海交通大学''。返回下面这样一个排序列表(共获取5个结果)
| !排名(rank) | !获取的结果文档 | !是否相关 |
| 1 | a1 | 0 |
| 2 | a2 | 1 |
| 3 | a3 | 0 |
| 4 | a4 | 0 |
| 5 | a5 | 1 |
则''{{{ AP = ( 0/1*0 + 1/2*1 + 1/3*0 + 1/4*0 + 2/5*1 ) / 5}}}''
{{{
这个指标评价的是:检索任务要找到尽量多的相关文档
}}}
*@@bgcolor(#66cc33):MAP(Mean Average Precision)@@
他是对于Q个查询q,计算这Q个AP的平均值,公式如下,不解释:
>[img[http://upload.wikimedia.org/math/9/8/f/98f072c60e0dc953b943b99d019729b3.png]]
{{{
这个指标评价的是:基于检索池的相关性判断。常用于对整个检索任务评价其检索出相关文档的能力。
}}}
*@@bgcolor(#66cc33):MRR(Mean Reciprocal Rank)@@
''Reciprocal Rank''定义为第一个相关文档的排名的倒数,公式如下,另参考''Ref2''
>[img[http://upload.wikimedia.org/math/2/d/7/2d7879c5c9fa7ac7d39c5620d18a1026.png]]
{{{
该指标对排序位置十分敏感,表示的把第一个答案排在尽量前面的能力
}}}
*@@bgcolor(#66cc33):P@10@@
它表示的是在某个排序位置(如10)上的准确率,这个指标有下面两个考虑(更多参考''Ref3'')
{{{
1.该指标评价的是:检索任务是要在某排序位置上找出尽可能相关的文档,而不是找到尽可能多的文档;
2.在某排序位置上,一个检索结果的准确率比另一个说,那么他的召回率也更高的。
}}}
*@@bgcolor(#66cc33):召回率增加0.1时精度的变化,插值(Interpolation)法@@
它是在P-R图上的改进(因为不同检索结果的P-R图形状不一样,没比较价值),公式如下
>[img[http://nlp.stanford.edu/IR-book/html/htmledition/img536.png]]
然后构建11点插值P-R图(11-point Interpolated Average Precision 见''Ref4''),他们的形状是类似的,具体的例子参见''Ref3''的8.4.2小节和''Ref4''。
{{{
1. 该指标评价的是:各个检索结果之间的P-R曲线宏观对比;
2. 将各条插值后的P-R曲线做平均,得出一条平均的P-R曲线,用于评价整个检索任务(见Ref3的8.4.2小节);
3. 宏平均(Macroaverage)和微平均(Microaverage)(见Ref3的8.4.2小节页脚的注释)
}}}
*@@bgcolor(#66cc33):DCG(Discounted Cumulative Gain)@@
公式如下,参考''Ref1''和''Ref3''的8.4.3小节
>[img[http://upload.wikimedia.org/math/d/f/5/df5560ab4a13fbe3a4bd3b07b61f7d75.png]]
便于平均多个查询的评价值,需要对结果进行归一化,归一化因数是一个理想化的DCG,参考''Ref1''和''Ref3''的8.4.3小节,公式如下
>[img[http://upload.wikimedia.org/math/c/6/6/c66e4f0c861568bbcdaa22b86446b8a0.png]]
该指标基于假设
{{{
1. 高相关性的文档比边缘相关的文档要有用得多;
2. 相关文档排序越靠后,对用户的价值越低(体现在公式中的衰减因子log(i))
}}}
*@@bgcolor(#66cc33):Reference@@
Ref1:[[IR@Wikipedia|http://en.wikipedia.org/wiki/Information_retrieval]]
Ref2:[[MRR@Wikipedia|http://en.wikipedia.org/wiki/Mean_reciprocal_rank]]
Ref3:《搜索引擎:信息检索实践》or 《Search Engines Information Retrieval in Practice》
Ref4:[[Evaluation of ranked retrieval results|http://nlp.stanford.edu/IR-book/html/htmledition/evaluation-of-ranked-retrieval-results-1.html#fig:trec-11-point]]
1、具体的例子
一步步的教程,前面的引子比较有趣,狂点[[这里|http://www.codeproject.com/KB/library/py_embed.aspx]]
较简单的:见[[这里|http://coredump.blog.bokee.net/bloggermodule/blog_printEntry.do?id=909014]](或者[[这里|http://coredump.blog.bokee.net/bloggermodule/blog_printEntry.do?id=909014]]一样的)
稍微复杂的:见[[CodeProject|http://www.codeproject.com/KB/cpp/embedpython_1.aspx]]上
更复杂的的关于multi thread:上面那篇文章的[[姊妹篇|http://www.codeproject.com/KB/cpp/embedpython_2.aspx]]

2、调用python方法的集中分类
见[[这里|http://blog.csdn.net/jzp_cn/archive/2005/10/24/515034.aspx]]
在线版本:http://www.voicebase.com
某个研究机构的(需要申请,支持中文):http://www.vocapia.com/technos.html
微软的接口:[[Speech SDK 5.1|http://www.microsoft.com/downloads/en/details.aspx?FamilyID=5e86ec97-40a7-453f-b0ee-6583171b4530&displaylang=en#Top]]
按照[[这里|http://zustytq.blog.ubuntu.org.cn/2007/09/21/vsftp%E5%AE%89%E8%A3%85%E9%85%8D%E7%BD%AE/]]配置就好了
用户上传后,那个用户无法下载(因为上传后文件属性是600),需要server端的人手动设置他的mod为555才行。

下次搞个下载目录,用户不能上传,看看怎么弄。

参考:很全(太全)的[[教程|http://linux.chinaitlab.com/server/725476.html]],[[参数详细(太详细)的作用|http://blog.163.com/mike_homis/blog/static/20104948200951604542326/]]
src:[[Reloading profile - how to reload Unix profile|http://www.ivorde.ro/Reloading_profile__how_to_reload_Unix_profile-76.html]]
Use the following command to reload a unix profile (/etc/profile, ~/.profile, ~/.bash_profile ...):
>{{{$ . ~/.profile}}}
>{{{$ . /etc/profile}}}

Notice: . (dot) is a command that originates from source command. On some unix flavours (FreeBSD 6 for example) source command works still:
>{{{$ source ~/.profile}}}
>{{{$ source /etc/profile}}}