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

SEARCH KEYWORD -- Assign default value



  Basic Patterns for Everyday Programming

For most of you the patterns mentioned below should be nothing new. These are very basic stuff we slap into our code everyday and at times feels they are actually code smells than smart patterns. However, I've been doing some code reviewing lately and came across many code that lacks even these basic traits. So I thought of writing them down as a help for novice developers who would want to get a better grasp at these.These patterns are commonly applicable in most general purpose programming lan...

   Pattern,Code,NULL,Function,JavaScript,Assign default value     2011-11-23 08:03:55

  Understand this in JavaScript

In JavaScript, this is always pointing to the owner of a function or a method. Function Let's check out function first. function introduce() {      alert("Hello, I am Laruence\r\n"); } For this function, what does this point to? In JavaScript, a global function's owner is the current page, i.e, the window object. Because its a method of the window object if we define a global function. Now you should know the this will point to the window object in the above function. ...

   JavaScript,this,event,call     2013-04-03 04:10:03

  Android create button tutorial

This tutorial assumes that you already have an activity and are using an XML layout. Open the layout XML and add the button element.  Assign an ID with the “@+id” operator.  The + tells Android to generate an ID for this element so that you can reference it in your Java files. This is an example. Your layout and text elements will probably be very different. In this example case, the ID of the button is “close”. <Button android:id="@+id/close" android:lay...

   Android,Simulator,Button,XML,Tutorial     2014-11-07 08:30:10

  Deep clone of JavaScript object

In JavaScript world, it's frequently seen object clone. Normally when creating a clone of an object, it's only the reference being cloned but not all contents. In some scenarioes, it's desired to clone all the content instead of just the reference such that any change made to the cloned object will not change the original object. Differences between shallow clone and deep clone can be as simple as: Shallow clone : Only the object reference is cloned but not the content Deep clone : Clone all co...

   JAAVSCRIPT,DEEP CLONE,DEEP COPY,SHALLOW CLONE,SHALLOW COPY     2016-10-31 00:27:24

  strange thing in PHP session variable and local variable

A few minutes ago, I noticed one strange thing when I did my PHP web application development.The situation is described below:I want to display a user's profile using a query parameter user=user_id as the parameter. And also the session variable when user logs in  is $_SESSION["user"].So before displaying the user's profile, I need to either get the query string parameter user and create a local variable called $user and assign value to it as $user=$_REQUEST["user"].Here comes the strange t...

   PHP,session,variable name,change automat     2011-06-13 12:23:59

  Fix 'this authentication plugin is not supported' issue while using Go to connect MySQL 8

MySQL 8 has changed its default authentication plugin from mysql_native_password to caching_sha2_password to improve its security. However many third party libraries seem act slowly to catch up with this change. This causes some compatible issues with their connection to MySQL. One of the issues is seen in Go libraries while it's trying to connect to MySQL 8. The specific error has been observed is "this authentication plugin is not supported". The root cause of this issue is that the go-sq...

   MYSQL,GO,MYSQL 8,AUTHENTICATION PLUGIN     2018-07-11 08:55:02

  How to commit code to OpenStack

If you want to make contributions to OpenStack, the best way to start is to help the community with blueprint or submit bug fix. To commit codes, you need to conform to some rules in the community. Work flow Register an OpenID Apply for a CLA certificate Apply for company CLA certificate Update contributor list Join OpenStack Contributors group and OpenStack group Set up SSH Keys Get a blueprint/bug git clone codes to local disk. Configure user name and user email and openid Modify codes in a l...

   OpenStack,Contribution     2013-08-04 23:04:45

  Run executable jar on double click on Windows

Normally after installing Java, there will be an association between .jar and the javaw.exe. This enables the executable jar to be opened on double click. You can check the association by going to Control Panel -> Programs -> Default Programs -> Associate a file type or protocol with a program. The default program of a file type can be changed in this dialog. However sometimes there are cases where the file association for .jar may be altered after a third party application instal...

   JAVA,WINDOWS,JAR,EXECUTABLE JAR     2016-05-12 03:05:04

  Top 10 Go Coding Traps and Tips

Go is currently the most common programming language in cloud development. Though I use it very much in my work, I am still repeating certain mistakes. This article is more a record of these errors, figuring out the causes and solutions so that people who read this article will save themselves time when coming across the same problems. Let’s cut through to the tips. Don’t rely on index var in the for loop The most common mistake we make is that we often create goroutine&nbs...

   TIPS,GOLANG,NIL INTERFACE     2021-07-03 23:45:51

  Emacs adventures

I have been using Emacs for over a year now. I actually didn’t learn a lot when I started using it (just the basics to get going and then some relatively common keyboard shortcuts), but lately I have been reading and learning much more about it. I’m so grateful by everything I’ve learned from different people on the net that I wanted to share a couple of things I’ve learned, and a simple major mode for editing AsciiDoc documents. As a long-time VIM user, I f...

   Editor,Linux,Emacx,VIM,Shortcuts     2011-11-30 11:56:49