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

SEARCH KEYWORD -- Check



  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

  My frequently used Linux commands

In our day to day work. We may have many chances working on Linux/Unix systems. There are many things we may need to do, checking logs, navigating in directories, creating file or installing software. We may use many commands to complete the work, such as ls, mkdir, cd etc. Below are my frequently used Linux commands or programs recently: pwd : print working directory, sometimes I need to check which working directory I am in in order to know where to go next. ls : List current directory files,...

   Linux,Command,Program     2012-08-16 15:09:42

  How to check whether a struct implements an interface in GoLang

Unlike other programming languages like Java, when implementing an interface in GoLang, there is no syntax like below to explicit tell the relationship: type I interface { } type A struct implements I { } When looking at the code or running the code in GoLang, it might lead to a case one doesn't know whether a struct implements interface before trying to use it as some interface. According to GoLang spec, as long as a struct implements all functions of an interface, it is considered as having i...

   GOLANG,INTERFACE,IMPLEMENTATION,CHECK     2020-05-03 00:05:54

  Steps to connect to MySQL on Windows Command Line

To connect to MySQL database on Windows through Command line, there are some steps to be followed.1. You need to start the MySQL service, you can go to Start->Control Panel->System and Securities->Administrative Tools->Component Service->Services(local), then on the right panel, you can find one service name called MySQL and you should start this service2. Go the the MySQL installation folder, which is something like this : C:\Program Files\MySQL\MySQL Server 5.1. In this folder, ...

   MySQL,Window,Command line,Connection,mysqld     2011-11-05 08:22:39

  JS code to check different mobile devices

Today I come across a code snippet which uses JavaScript to check different mobile devices and then loads different CSS files accordingly. As we know that there are mobile devices with different screen sizes, it's always troublesome for web developers to develop cross browser and cross device compatible codes. Hope this one can help those who develop web apps on mobile devices. // Check whether it's a mobile device // wukong.name 20130716 if(/AppleWebKit.*Mobile/i.test(navigator.userAgent) || (...

   JavaScript,Mobile device,Detection     2013-11-28 05:25:10

  Check out YouTube new design

Recently, YouTube has developed its new design, but is is still not officially released. But you can check out the new design now by following the steps below:1. Open http://www.youtube.com on your Chrome or Firefoc2. Press Ctrl + Shift and J in Chrome to open the Developer Tools and Press Ctrl+Shift and K in    Firefox3. On the bottom part of the development tool, you can type some commands there. Copy the following code and paste on the console window on the bottomdocument.cooki...

   YouTube,New design,Chrome,Firefox,How to     2011-11-20 11:38:58

  JavaScript tips both novice and veteran developers can benefit from

In this post, we will share some less known but powerful JavaScript tips which can benefit both novice and veteran JavaScript developers. 1. Truncate array with array length We all know that object are passed by reference in JavaScript, but we may be bitten by this rule. Please check below example: var arr1 = arr2 = [1, 2, 3]; //Change arr1 arr1 = []; // arr2 will still be [1,2,3] arr1 and arr2 point to the same array [1,2,3] initially, later when arr1 repoints to [], the reference to arr2 is n...

   JavaScript,Array,push     2013-08-21 04:09:10

  Macro to change text color conditionally in Excel

Macros are small but very powerful VBA programs in Microsoft Office software. They can help us complete some repeated tasks automatically. Today, I will show you one macro example which is to change the text color conditionally. The excel file has a work sheet which contains some records of request. I want to check the status of each request, if the status of a request is approved, the text color of the status should be green; if the status of a request is rejected, the text color of the status ...

   Macro,Excel,Text color,Conditionally     2012-07-07 12:53:28

  Ways to check existence of JavaScript object

The design of JavaScript is not so sophisticated. It's very easy for us to make mistakes if we are not very careful when using JavaScript. For example, to check the existence of JavaScript object. Now we want to check whether a global object myObj exists or not, if it doesn't exist, we declare it. The pseudo code for this is : if(myObj not exist){ declare myObj; } You may think it's very easy to write the code. In fact, it is much more difficult than we may think. Juriy Zaytsev says there are m...

   JAVASCRIPT,OBJECT,EXISTENCE     2020-09-12 02:14:02

  Frequently used Git commands

Git configuration git config --global user.name "robbin" git config --global user.email "fankai@gmail.com" git config --global color.ui true git config --global alias.co checkout git config --global alias.ci commit git config --global alias.st status git config --global alias.br branch git config --global core.editor "mate -w" # Configure Editor to use textmate git config -l #List all configurations User's git configuration file : ~/.gitconfig Frequently used Git commands Check、add...

   Git,Command     2013-03-11 19:41:06