There are a lot of methods to get the path of a script in Python, but the following method always work, even you use py2exe or PyInstaller to compile the script to binary executable file.
My Emacs Configure File
Open the file named “.emacs” in your home folder. (if it doesn’t exist, create one.) Copy the following code and paste it into the opening file. Save the file and restart Emacs.
POJ 1260 Pearls Report
View the problem at POJ. It’s a problem from a contest in Northwestern Europe, 2002.
This is a classical Dynamic-Programing problem. The sate transformation equation is:
POJ 1009 Edge Detection Report
View the problem at POJ: 1009 Edge Detection.
The answer should be in format of Run Time Encoding. Let val[i] be the value, and len[i] be the length of the i-th pair. There is a corresponding location for each pair, ie the start point, and let row[i] be the row, and col[i] be the column of the start point for the i-th pair.
How to Test if a Host Is Active
Sometimes, we would like to check if a remote host is reachable before we establish a connection. This is much like the function of the ping
command in terminal. Well in Cocoa programing, you can use the function SCNetworkReachabilityCreateWithName()
.
Here is the code:
How to Redirect to a New Page
This is an example that shows how to redirect (forward) to a new page in PHP.
POJ 1129 Channel Allocation Report
View this problem on POJ: 1129 Channel Allocation This problem involves the following knowledge:
POJ 2001 Shortest Prefixes Report
View the Problem.
This problem can be solved by 2 methods.
POJ 1190 Birthday Cake Report
View this problem on POJ: 1190 Birthday Cake (生日蛋糕)
There is no good methods, maybe dynamic programing is feasible, but it’s too complex for me to construct the transformation equation.
I have to use DFS (Depth First Search) to solve this problem. After the TLE (Time Limit Exceeds) appeared enough times, I worked it out. Pruning is very important for this problem.
POJ 1838 Banana Report
View this problem on POJ: 1838 Banana.
This problem can be categorized as the Union-Find problem.
POJ 2104 K-th Number Report
View the problem description here: 2104 K-th Number .
To solve this problem, you need to learn the following knowledge first.
- Segment Tree
- Binary Search
- Merge Sort
If you know all the above, it’s easy to solve this problem.
Config File for Compaq Evo N610c on Gentoo
Wow, Compaq Evo N610c…It’s really an old machine… I searched the configure file for this machine, and fond only one page, but it’s too old to work for the latest Gentoo system. Here is my configure file, which costs me days of work.
POJ 1990 MooFest Report
View this problem on POJ: 1990 MooFest.
Here is my resolution:
POJ 2184 Cow Exhibition
This problem can be solved by two methods
- Deepth First Search (DFS)
- Dynamic Programming (DP)
POJ 2231 Moo Volume
Here is my pseudo code
Configuring Gentoo With English Interface and SCIM
To install SCIM, follow the following steps:
STL Function: Binary_search()
In some cases, we just want to if an element exists in a sorted list, then we can use the STL function: binary_search()
.
To use this function, you must include the header <algorithm>
.
Note before we use binary_search()
, the list must be sorted, either in ascending order or in descending order.
……
Here is a simpler example explaining how to use this function.
__int64 vs Long Long
long long
is a standard C++ type, so if you use gcc, you can use this type without any problem.
But on Windows, as some old Microsoft C++ compilers don’t support the type long long
, you have to use the non-standard type: __int64
.
The following example shows how to input and output an __int64
type of variable.
Force the Mail.app to Use UTF-8 Encoding on Macintosh
Open a terminal, and run the following command:
1
defaults write com.apple.mail NSPreferredMailCharset "UTF-8"
Remove SVN Info From a Folder
1
find . -name .svn -exec rm -rf {} ;