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

SEARCH KEYWORD -- Code snippet



  Regular expression to get html meta description

When we need to process a HTML page source code, we often need to retrieve the meta description of the page besides the links in the page. This description is usually located in <meta> tag of a HTML page. The meta description is very useful for search engine index. How can we retrieve the meta description? If we use a regular expression, we can easily get the meta description. In JavaScript, the regular expression looks like : var pattern = /<meta.*?name="description".*?content="(.*?)"....

   Regular expression,meta description,HTML,JavaScript     2012-07-03 10:09:20

  Bing now supports code search

In programmer's daily life, much time is spent on searching Google or StackOverflow for code snippets which can help them understand how the code works. Now there is one more option. Microsoft's Bing now adds a new feature which support code snippet search. With this new feature, you can search code snippet and execute them directly within the search results. For example, if you type "quick sort java", you will see below search result : This feature now supports a few popular programming langua...

   BING,CODE SEARCH,HACKERRANK     2016-04-09 02:49:25

  If PHP Were British

When Rasmus Lerdorf first put PHP together, he - quite sensibly, despite his heritage - chose not to write it in Greenlandic or Danish. Good job too - that would have been rather unpleasant to work with. He opted instead, being in Canada at the time, for the local tongue. No, not French - that bastard dialect of the Queen's English commonly referred to as "US English"1. PHP developers in Britain have been grumpy about this ever since. What was he thinking? And more importantly, how do we ...

   PHP,British,Class,Statement,Engilish like     2011-12-01 02:36:55

  Some short code snippets which use all JavaScript keywords

In JavaScript, keywords are reserved and cannot be used as variable or function names. For example void, function and this are JavaScript keywords, they are keywords which are reserved for special use. Here is list of the keywords in JavaScript. We also show you some short code snippets which use all the keywords in JavaScript.void function() {//abcd   do break;while(typeof delete this);  for(var a;;)  if (true)  with(null)  try{}catch(a){}finally{} else throw new 1;&nbs...

   Code snippet,JavaScript,keyword     2012-07-16 12:12:05

  Singleton Design Pattern in Java

Singleton is frequently used in applications where resource may be expensive to create and no instance specific state needs to be maintained. For example, when creating database connection, a singleton may be needed. Today we will share the famous Singleton design pattern in Java. 1. Definition Singleton design pattern is a design pattern that restricts the instantiation of a class to one object. It is one of the most well-known design patterns. 2. Application Singleton ...

   DESIGN PATTERN,SINGLETON,MULTITHREAD,JAVA     2020-04-11 02:16:28

  Empty slice vs nil slice in GoLang

In Go, there is a type called slice which is built on top of array. It's a very convenient type when we want to handle a group of data. This post will explain a subtle but tricky difference between empty slice and nil slice. A nil slice is a slice has a length and capacity of zero and has no underlying array. The zero value of slice is nil. If a slice is declared like below, it is a nil slice. package main import "fmt" func main() { var a []string fmt.Println(a == nil) } The output will be t...

   GOLANG,JSON,EMPTY SLICE,NIL SLICE     2018-10-18 09:25:21

  Guide to Implement an SSH Client Using Golang

SSH, short for Secure Shell, is a network protocol used for securely remote logging into other computers on a network. I believe most backend developers are familiar with SSH. Common shell tools used for logging into servers, such as Xshell, SecureCRT, and iTerm2, are all based on the SSH protocol. In Golang, the crypto/ssh package provides functionality for implementing an SSH client. In this article, we will explain in detail how to implement an SSH client using Golang. Creating SSH Client Con...

   SSH CLIENT,GUIDE,SSH,GOLANG     2023-11-11 09:19:29

  QScrollArea Scrollbar Display Solution

Qt framework is a popular C++ GUI framework developed by Nokia. And it is also cross platform compatible. Many developers are using Qt to develop C++ GUI programs. In Qt, some important components are deserved our close attention. Many developers faced the problem when they put some widgets in a QScrollArea widget and they want it to display scroll bars when the widgets inside the QScrollArea overflows. After many experiments, I propose a way which can show scroll bars as you expected. The...

   C++,Qt,GUI,QScrollBar,ScrollBar,Not display,Solution     2012-03-03 07:48:36

  var in JavaScript

Geoff published an article sometime ago--"How one missing var ruined our launch". This article described one case where MelonCard uses Node.js as their backend system, suddenly there was a small registration peak period--50-100 people registered concurrently, then the entire website stopped responding and many other strange problems showed up. When they were investigating the source of the problem, they found one missing var in the following code.app.all(‘/apps/:user_id/status’, fun...

   JavaScript,Scope,variable     2012-05-26 12:35:36

  Can two new objects point to the same memory address in GoLang?

Do you have any idea what the output will be for below GoLang snippet? package main import ( "fmt" ) type obj struct{} func main() { a := &obj{} fmt.Printf("%p\n", a) c := &obj{} fmt.Printf("%p\n", c) fmt.Println(a == c) } Many people would think that a and c are two different object instances which have different memory addresses. Hence a == c will be false. But if you try to run the above program, you would see below output 0x5781c8 0x5781c8 true To get to know the reason wh...

   GO,GOLANG,VARIABLE ESCAPE,ZEROBASE     2019-04-06 01:19:52