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

SEARCH KEYWORD -- Snippet



  HeartBleed: Inside the heart, what causes the bleeding?

Just after a few weeks since Apple's famous goto fail bug, there is one bug in OpenSSL which catches the attention from the world again. The bug is named HeartBleed, found in OpenSSL library, a famous open source library supporting lots of  SSL/TLS communication among server/client applications. The reason why this bug catches the attentions from the world is it affects almost all sites which are using the affected OpenSSL library, these includes many applications like Nginx server, some v...

   OpenSSL,HeartBleed     2014-04-09 05:47:30

  Google search now highlights search text in target link page

It seems Google is slowly releasing a new feature to highlight search text when user opens a matching search result link through its search engine.  Now for example if you type something in the Google search bar, you will see normal search results. But when you click the link, e.g, the first search result to Stackoverflow, you will see something like below after the link is opened. The searched text is highlighted and the page automatically scrolls to the position where the search text ap...

   GOOGLE SEARCH,FEATURED SNIPPET,TECH NEWS     2020-06-13 06:09:38

  Will nil == nil be true in GoLang

There is some interview question may ask whether nil == nil be true in GoLang. Wil it be true. false or compilation error? To know the answer, some knowledge about nil in GoLang needs to be explained first. nil definition According to Go's official documentation, the definition of nil is // nil is a predeclared identifier representing the zero value for a // pointer, channel, func, interface, map, or slice type. var nil Type // Type must be a pointer, channel, func, interface, map, or slice type...

   GOLANG,NIL,NIL EXPLANATION     2021-08-08 02:54:15

  Use downcase! with caution in Ruby

Ruby provides ! to change state of some object in place. Hence if you see some functions have ! appended, it means the state of the caller of the function is expected to be changed. This is a very interesting Ruby feature. But sometimes one should be cautious when using this kind of functions because you would get unexpected behavior if using improperly. Let's take an example of String#downcase!. According to the documentation. Downcases the contents of str, returning nil if...

   RUBY,EXCLAMATION MARK,DOWNCASE     2017-02-10 06:34:44

  this in JavaScript

this is a keyword in JavaScript. It refers to an internal object created automatically when a function executes, it can only be used in a function. For example:        function test(){     this.x = 1;   }The this keyword will change when a function is called in different situations. However, the general rule is : this refers to the object which calls the function.Next we discuss the use of this in 4 different situatio...

   this,keyword,use,JavaScript     2012-05-05 12:47:37

  Let browser prompt for storing password when doing AJAX login

In Web 2.0 era, more and more web applications are using AJAX to replace the traditional HTML form element to perform user login. This usually provides a better user experience than form submission. But it also brings a side effect to the end users. That is the browser will not prompt the user whether s/he wants to save the password so that s/he no needs to enter the username/password again when visiting the same site next time. Below is the code snippet which does the AJAX login.  <scri...

   AJAX,Browser,Login,Password     2015-06-04 10:02:46

  Implement struct no copy in GoLang

There is some case where some of the struct in GoLang which is not meant to be copied. For example, sometimes a global configuration which should have only one version passed around the whole application and should not be copied and modified. In GoLang, there is no intuitive solution on preventing copying of struct. But there is still some way which can be leveraged to help prevent this while developing the code. The trick is to define some struct implementing sync.Locker interface and has this ...

   GO VET,NOCOPY,NO COPY     2020-09-04 22:24:58

  Memory related exception analysis in Java

Java Virtual Machine Specification divides the memory of JVM into several areas : Heap, Stack, The Program Counter register and Method area etc. In HotSpot JVM, heap is composed of Young, Tenured and Perm. There are different OutOfMemory error can happen in different memory area. Next is an overview of some of these OOM errors. StackOverflowError The JVM will allow only a specified number of stacks created nested. An JVM option -Xss can be set to determine the maximum stack size. If the num...

   Java, Memory model, Memory exception, OOM     2015-01-19 06:54:27

  10 super useful PHP snippets you probably haven’t seen

When working with PHP, it is very useful to have a “toolbox” of handy functions and code snippets that can save lots of time when needed. Today, I’m going to show you 10 super useful code snippets that you probably never heard of. Text messaging with PHP using the TextMagic API If for some reason, you need to send text messages to your clients cell phones, you should definitely have a look to TextMagic. They provide an easy API which allow you to send SMS to cell...

   PHP,Code,Snippet,Useful code segment     2012-01-19 11:07:16

  Be careful about nil check on interface in GoLang

nil check is frequently seen in GoLang code especially for error check since GoLang's special error handling convention. In most cases, nil check is straight forward, but in interface case, it's a bit different and special care needs to be taken. Take a look at below code snippet and guess what the output will be. package main import ( "bytes" "fmt" "io" ) func check(w io.Writer) { if w != nil { fmt.Println("w is not nil") } fmt.Printf("w is %+v\n", w) } func main() { var b *bytes.B...

   INTERFACE,GOLANG,NIL CHECK,NIL TYPE,NIL VALUE     2019-04-06 07:47:07