Today's Question:  What does your personal desk look like?        GIVE A SHOUT

SEARCH KEYWORD -- NEW LINE



  Carriage return and line feed

In programming and document editing, we may frequently encounter carriage return and line feed, i.e the well known CRLF.  But do you know about the history and difference of carriage return and line feed? Before computer came out, there was a type of teleprinter called Teletype Model 33. It can print 10 characters each second. But there is one problem with this, after finishing printing each line, it will take 0.2 second to move to next line, which is time of printing 2 characters. If a new...

   CR,CARRIAGE RETURN,LINE FEED,LF,NEW LINE,CRLF     2017-02-19 08:29:23

  Exit main thread and keep other threads running in C

In C programming, if using return in main function, the whole process will terminate. To only let main thread gone, and keep other threads live, you can use thrd_exit in main function. Check following code: #include #include #include int print_thread(void *s) { thrd_detach(thrd_current()); for (size_t i = 0; i < 5; i++) { sleep(1); printf("i=%zu\n", i); } thrd_exit(0); } int main(void) { ...

   C LANGUAGE,MULITHREAD,MAIN THREAD     2020-08-14 21:20:04

  Fix issue docker-credential-desktop not installed or not available in PATH on Mac

Sometimes you may encounter below issue while running docker-compose on MacOS. Traceback (most recent call last): File "docker-compose", line 6, in <module> File "compose/cli/main.py", line 71, in main File "compose/cli/main.py", line 127, in perform_command File "compose/cli/main.py", line 1085, in up File "compose/cli/main.py", line 1081, in up File "compose/project.py", line 527, in up File "compose/service.py", line 354, in ensure_image_exists File "compose/service.py",...

   MACOS,DOCKER,DOCKER-COMPOSE     2020-06-23 03:25:16

  Cool HTML5 matrix effect

Do you still remember the movie The Matrix? Do you still remember the cool matrix effect in that movie? How is that effect achieved? Shaun Dunne shared a piece of HTML5 code which displays a cool matrix effect. The matrix demo can be found here. Below is the code which he achieves this effect: with var s = window.screen; var width = q.width = s.width; var height = q.height = s.height; var letters = Array(256).join(1).split(''); var draw = function () { q.getContext('2d').fillStyle='rgba(0,0,...

   Matrix,HTML5     2013-08-14 08:03:34

  Using vi key bindings in bash and zsh

Takeaway: If you prefer to use vi or vim for command-line editing, you can configure shells to use vi key bindings instead of emacs-style key bindings. Here’s how. By default, most shells use emacs-style key bindings for command-line editing and modification. For users of vi or vim, however, you can instead configure shells to use vi key bindings instead. This is done by editing ~/.bashrc in the case of bash, or ~/.zshrc in zsh a...

   vi,Linux,Zsh,bash,key binding     2012-02-07 06:22:36

  sorting in C++: 3 times faster than C.

If you don't know C++ well, you might be surprised how fast C++ can be sometimes. This is especially true when code involved is small, because then inlining - which is what C++ is very good at - and templating, which makes excessive inlining possible in the first place - has the most effect. The following code compares C and C++ sorting:  #include <iostream>#include <algorithm>#include <vector>#include "stop_watch.inl" // see https://...

   C++,Sorting,C,faster,efficiency     2012-03-17 12:59:45

  A collection of color schemes for some famous websites in China

Each website has a color scheme which identifies itself. By looking at one color, we can know which website it is for. These color schemes can be identified from their logos, nav-bars, background etc. We collect some color schemes for some famous Chinese websites. Alibaba (#f90)   Baidu (#0000cc)   Huawei (#e30a12)   HTC (#69b40f)   JD (#c91623)   Renren (#105ba3)   Sina (#e4351e)   Sohu (#fdd000)   Taobao (#ff4400)   Tencent (#0397de)   Tmall (#...

   Website,Color scheme,China     2013-08-21 12:32:14

  Art of code comment

Note : This post is just for fun. Please be careful about these tricks. Code comment is to provide complementary comment to abstract codes. We will introduce two comment styles while we are debugging our codes. we should avoid these styles in production codes. 1. if else style Only execute eatKfc() //* eatKfc(); /*/ eatMcdonalds(); //*/ Only execute eatMcdonalds() /* eatKfc(); /*/ eatMcdonalds(); //*/ Execute both //* eatKfc(); //*/ eatMcdonalds(...

   Comment,Style     2013-08-19 04:19:40

  Do you have this kind of comments in your source code?

Writing runnable code is the essential skill of a programmer, writing understandable comment is also a skill a programmer should acquire. There is some famous saying that bad comment is worth than no comment. Usually your code will be maintained by other people, if you provide them some difficult to understand or misguided comments, this will be nightmare to them. While at some other time, programmers may put some funny comments in their codes which may make others laugh. Today we...

   COMMENT,HUMOR     2016-08-01 10:25:14

  Error handling style in C

Following are three error handling styles in C.Which one you like the most? Or you don't like any one?1. /* Problem : Not enough. Easy to be wrong */int foo(int bar){        int return_value = 0;        int doing_okay = 1;        doing_okay = do_something( bar );        if (doing_okay)        { ...

   C,Error handling style,Goto,Nested if     2012-04-24 06:51:00