I saw a mug cup with VI snipped commands on thinkgeek. It costs $12.99 that it nearly equals 89 RMB. I will order it if I am a fool! But I wanna it, so DIY. U can buy a mug cup every where, the point is the image file which contains the VI commands. I create a clone version of the image file by using Photoshop, because the pixies of the image file from website is so low and I am not sure whether it can print perfectly.
The file blew is the JPEG format
or U can download the psd file and customize it as your wish.
vim mug psd format (124)
Posted in: programming |
Summary of reading 2.5 chapter 2 for Unix™ Systems Programming: Communication, Concurrency, and Threads
After reading this section of chapter, I found that more and more things need to think a through at some time, especially for the guideline listed below.
-
Make use of return values to communicate information and to make error trapping easy for the calling program.
-
Do not exit from functions. Instead, return an error value to allow the calling program flexibility in handling the error.
-
Make functions general but usable. (Sometimes these are conflicting goals.)
-
Do not make unnecessary assumptions about sizes of buffers. (This is often hard to implement.)
-
When it is necessary to use limits, use standard system-defined limits rather than arbitrary constants.
-
Do not reinvent the wheel—use standard library functions when possible.
-
Do not modify input parameter values unless it makes sense to do so.
-
Do not use static variables or dynamic memory allocation if automatic allocation will do just as well.
-
Analyze all the calls to the malloc family to make sure the program frees the memory that was allocated.
-
Consider whether a function is ever called recursively or from a signal handler or from a thread. Functions with variables of static storage class may not behave in the desired way. (The error number can cause a big problem here.)
-
Analyze the consequences of interruptions by signals.
-
Carefully consider how the entire program terminates.
I can understand most but the not entries. I need more time to think about them. Just share the guide to you all. ^_^
Posted in: programming |
[sourcecode language='cpp']
char* __stdcall UnicodeToUtf8( const WCHAR* wstr )
{
const WCHAR* w;
// Convert unicode to utf8
int len = 0;
for ( w = wstr; *w; w++ )
{
if ( *w < 0×0080 )
{
len++;
}
else
{
if ( *w < 0×0800 )
{
len += 2;
}
else
{
len += 3;
}
}
}
}
[/sourcecode]
Posted in: My life - programming |

