12 十一月, 2009
Create PyGtk Programming Environment on Windows
Posted by: asd In: Code Snippet| Script| Unix| 程式設計
1. 安裝「python-2.5.4」
2. 安裝「PyGtk, PyOpenGL, PyGtkGlExt, PyWin32 all in one installer」
使用 「Glade」拉界面 ,「Pythonwin」 IDE debug,
12 十一月, 2009
Posted by: asd In: Code Snippet| Script| Unix| 程式設計
1. 安裝「python-2.5.4」
2. 安裝「PyGtk, PyOpenGL, PyGtkGlExt, PyWin32 all in one installer」
使用 「Glade」拉界面 ,「Pythonwin」 IDE debug,
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><<</code> followed by a [...]
xml data
view plain
CODE:
<?xml version="1.0" encoding="ISO-8859-1"?>
<catalog>
<cd country="USA">
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<price>10.90</price>
</cd>
<cd country="UK">
<title>Hide your heart</title>
<artist>Bonnie Tyler</artist>
<price>10.0</price>
</cd>
<cd country="USA">
<title>Greatest Hits</title>
<artist>Dolly Parton</artist>
<price>9.90</price>
</cd>
</catalog>
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 [...]
use stl set to simulate map
view plain
CODE:
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
using namespace std;
class compare
{
public:
//the error is over here
bool operator()(pair<int, int> p1, pair <int, int> p2) const
{
if (p1.second == p2.second)
return p1.first <p2.first;
else
return p1.second <p2.second;
}
};
typedef set<pair<int, int>, compare> MMap;
void main(int argc, char* argv[])
{
MMap D;
D.insert(make_pair<int, int>(1, 10));
D.insert(make_pair<int, int>(2, 2));
D.insert(make_pair<int, int>(3, 2));
D.insert(make_pair<int, int>(4, 3));
D.insert(make_pair<int, int>(5, 6));
MMap::const_iterator iter(D.begin());
MMap::const_iterator [...]
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