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

SEARCH KEYWORD -- Front-end



  How to use Chome dev tool to find event handler bound to an element

As a front end developer, there is frequent need to debug JS code and sometimes need to find out what event handler has been bound to a HTML element. In this post, we will show how to find out the click event handler bound to a HTML element, this same applies to other events as well. Nowadays, a web application is usually very complicated and there are lots of JS codes which makes it difficult to find out what click event handler has been bound to a HTML element, especially when the JS source co...

   JAVASCRIPT,CHROME,CHROME DEV TOOL,EVENT LISTENER     2019-08-17 22:14:36

  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

  + operation on JavaScript objects

In JavaScript, there are two types of values: primitive and object. Primitives consist undefined, null, boolean, number and string. Other values such as array and function are objects. When applying + operation on different type of values, there would be three kinds of type conversion. Primitive conversion Number conversion String conversion There three type conversions have corresponding abstract operations in JavaScript: ToPrimitive(), ToNumber(), ToString(). For number additi...

   JAVASCRIPT,PROGRAMMING     2018-10-12 22:19:12

  Stop programming

You probably program too much. Just when you've really gotten into your work, when your brain is entirely wrapped around your code, when your hands, eyes, and thoughts are working in harmony, stop. Look up. Think about when you're going to finish for the day. Look forward to shutting off your computer. Get outside a little. ...

   Programming,Tips     2011-06-30 02:50:14

  When will Google be back to China?

There will be news about Google returning back to China every now and then since the search giant left China in 2010. Every sign of change about Google in China will give people big hope on its return. But Chinese are still waiting for the dream to become true though nothing real happen until now. On Thursday, it seems there is "proof" again that Google is going back to China. In the morning, many Chinese noticed that the official Google China weibo(China's Twitter) account uploaded a photo with...

   GOOGLE,CHINA,SEARCH ENGINE,BAIDU     2017-03-02 09:39:51

  Generate first N prime numbers

Recently I am taking an online course named "Startup Engineering" on coursera. There is one assignment which is to use NodeJS to write a program to generate the first 100 prime numbers. This may be very easy for many people. Here I just want to share with you the code to generate not only the first 100 prime numbers. but also any number of prime numbers. Below is the code snippet: //Helper class to generate prime numbers var PrimeProcessor=(function(){ var primeArray=[]; functio...

   Algorithm,Prime number,NodeJS,coursera,JavaScript     2013-06-29 22:08:22

  The new Google Search By Voice

Along with the new announcement of the new Google logo, there is a new change to the Google search -- The Google Search By Voice. When you use Google in a browser, you will see below color mic icon now:   With this, you can search by speaking in front of your computer,  OK, Google will listens to what you are saying and do the search for you.  As described by Google, this change: A colorful Google mic help you identify and interact with Google whether you’re talking, tap...

   Google, Google voice, Google logo     2015-09-02 11:07:13

  gethostbyname vs getaddrinfo

getaddrinfo is slower than ping when resolving domain names. I think ping uses gethostbyname to resolve a domain name. The question becomes whether getaddrinfo is slower than gethostbyname. After testing with both functions, we find that getaddrinfo is really slow compared to gethostbyname. By strace tracking,  we find getaddrinfo will communicate with DNS server 10 times and gethostbyname will communicate with DNS server communication twice.gethostbyname is an old way to resolve domain nam...

   C++,network,DNS     2012-08-15 14:06:34

  How to write your own DSL in Ruby

DSL(Domain Specific Language) is a language defined to fulfill some domain specific requirements to ease people's work. It can be used to define attributes and actions of a domain easily and cleanly. And it is often created based on some common observations or micro patterns of some domain. In Ruby world, there are quite a few places people can find DSL. For example, Ruby itself, Chef recipes. To create a class in Ruby, the traditional OOP way would look like. class User @name = nil @email =...

   RUBY,DSL,TUTORIAL     2017-03-04 09:40:34

  App's user value doesn't necessarily bring business value

There is an old saying in Internet world, you can get business value as long as you can achieve user value. Is this statement outdated in mobile Internet era? This statement originated from PC Internet era, but now the time users spend on PC drops and user behavior tends to be stable and conservative. In contrast, people are more willing to stay on mobile devices. The difference between PC and mobile is that users are freely to move around on PC end. People can navigate from one link to another ...

   App,Business value,User value     2013-06-25 10:52:12