EvoTalk

Archive for the ‘程式設計’ Category

1. 安裝「python-2.5.4」
2. 安裝「PyGtk, PyOpenGL, PyGtkGlExt, PyWin32 all in one installer」
使用 「Glade」拉界面 ,「Pythonwin」  IDE  debug,

13 十月, 2009

Perl Here Document

Posted by: asd In: Code Snippet| Perl| 程式設計

Use Perl here documents to print multiple lines of output
example:
view plain

PERL:

print <<FOO;

Perl offers a convenient way of printing multiple lines of output through an interesting feature known as a "Perl here document".

 

A multiline Perl here document works like this:

<ol>

    <li>The first line of your command will include the two characters <code>&lt;&lt;</code> followed by a [...]

12 十月, 2009

XPath

Posted by: asd In: Web| 程式設計

xml data
view plain

CODE:

&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt;

&lt;catalog&gt;

  &lt;cd country="USA"&gt;

    &lt;title&gt;Empire Burlesque&lt;/title&gt;

    &lt;artist&gt;Bob Dylan&lt;/artist&gt;

    &lt;price&gt;10.90&lt;/price&gt;

  &lt;/cd&gt;

  &lt;cd country="UK"&gt;

    &lt;title&gt;Hide your heart&lt;/title&gt;

    &lt;artist&gt;Bonnie Tyler&lt;/artist&gt;

    &lt;price&gt;10.0&lt;/price&gt;

  &lt;/cd&gt;

  &lt;cd country="USA"&gt;

    &lt;title&gt;Greatest Hits&lt;/title&gt;

    &lt;artist&gt;Dolly Parton&lt;/artist&gt;

    &lt;price&gt;9.90&lt;/price&gt;

  &lt;/cd&gt;

&lt;/catalog&gt;

XPath expressions

/catalog
selects the root element

/catalog/cd
selects all the cd elements of the catalog element

/catalog/cd/price
selects all the price elements of all the cd elements of the catalog [...]

30 七月, 2009

Sort Map Value

Posted by: asd In: C++| Code Snippet| 程式設計

use stl set to simulate map
view plain

CODE:

#include &lt;iostream&gt;

#include &lt;vector&gt;

#include &lt;algorithm&gt;

#include &lt;set&gt;

#include &lt;map&gt;

using namespace std;

 

class compare

{

public:

 

 //the error is over here

 bool operator()(pair&lt;int, int&gt; p1, pair &lt;int, int&gt; p2) const

 {

  if (p1.second == p2.second)

   return p1.first &lt;p2.first;

  else

     return p1.second &lt;p2.second;

 }

};

 

typedef set&lt;pair&lt;int, int&gt;, compare&gt; MMap;

 

void main(int argc, char* argv[])

{

 MMap D;

 D.insert(make_pair&lt;int, int&gt;(1, 10));

 D.insert(make_pair&lt;int, int&gt;(2, 2));

 D.insert(make_pair&lt;int, int&gt;(3, 2));

 D.insert(make_pair&lt;int, int&gt;(4, 3));

 D.insert(make_pair&lt;int, int&gt;(5, 6));

 

 MMap::const_iterator iter(D.begin());

 MMap::const_iterator [...]

Tags:

10 七月, 2009

Redirection

Posted by: asd In: Unix| 程式設計

Reference  3. All about redirection
redirect stdout to a file 
     ls -l > ls-l.txt
 
redirect stderr to a file 
     grep da * 2> grep-errors.txt
 
redirect stdout to a stderr
    grep da * 1>&2
 
redirect stderr to a stdout 
    grep * 2>&1
 
redirect stderr and stdout to a file 
    rm -f $(find / -name core) &> /dev/null


Page 2 of 4512345...Last »