TopBar

You are viewing the archive for the ‘programming’ category.

VI Mug

0
October 4, 2008

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)

VN:F [1.9.3_1094]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.3_1094]
Rating: 0 (from 0 votes)

Posted in: programming |

Summary of reading 2.5 chapter 2 for Unix™ Systems Programming: Communication, Concurrency, and Threads

0
December 17, 2007

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.

  1. Make use of return values to communicate information and to make error trapping easy for the calling program.

  2. Do not exit from functions. Instead, return an error value to allow the calling program flexibility in handling the error.

  3. Make functions general but usable. (Sometimes these are conflicting goals.)

  4. Do not make unnecessary assumptions about sizes of buffers. (This is often hard to implement.)

  5. When it is necessary to use limits, use standard system-defined limits rather than arbitrary constants.

  6. Do not reinvent the wheel—use standard library functions when possible.

  7. Do not modify input parameter values unless it makes sense to do so.

  8. Do not use static variables or dynamic memory allocation if automatic allocation will do just as well.

  9. Analyze all the calls to the malloc family to make sure the program frees the memory that was allocated.

  10. 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.)

  11. Analyze the consequences of interruptions by signals.

  12. 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. ^_^

VN:F [1.9.3_1094]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.3_1094]
Rating: 0 (from 0 votes)

Posted in: programming |

a test for code hight light plugin

1
October 10, 2007

[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]

VN:F [1.9.3_1094]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.3_1094]
Rating: 0 (from 0 votes)

Posted in: My life - programming |