Snippet IT IT News, Programming, Internet and Blogging

25Apr/090

PHP: Format integer into number of decimal places

Previous I have written an article about formating interger into number of decimal places in Java. The main reason to store money value in integer in to prevent loss in precision. For example the actual value for 12.33 in float could be 12.3333333333...; while 1233 in integer is always 1233.

Today I will be showing you the same code but in PHP language. I know you can do the same thing with PHP's number_format(), but you will need to cast the integer into float first before past the money value into the number_format() function. Therefore there are possibles of lose in precision.

22Apr/090

How to Request Reconsideration for Inclusion in Google Search Results

When a site's traffic from Google search engine dropped significantly or new site with a new domain has no traffic at all from Google search engine, you can expect that your site is no longer appear in Google's search results.

19Apr/090

How to Monetize Your Youtube Video

If you have an Youtube account, always upload videos to Youtube and receive quite a lot of feedback on your Youtube video. Then you can make some money from your video. What? Earn money by publishing video? Yes, you can!

If you already have an Google Adsense account, you can add Video Unit to your video. Video Units are embedded, customizable video players featuring content from categories, individual content providers, or automatic keyword-based targeting. To setup the video play, you will first need to link your Google Adsense account with Youtube account.

Youtube-Adsense 

19Apr/090

How to Add Advertisement Code to Wordpress Theme’s Sidebar

This may sound very simple to most of the bloggers who already have a Wordpress blog and running ads on their blog. One who of my friend who just new to Wordpress and having difficulty in adding advertisement codes to Wordpress Sidebar.

18Apr/090

C#: Unix Time to .Net DateTime and Vice Versa

For some reasons, some programmer might store time values as Unix timestamp in database instead of standard SQL DateTime data type. The main reason to store time values as Unix timestamp is unknown but what I guess is for maximum database compatibility. Some old database does not support SQL DateTime data type.

13Apr/090

Gmail: Inserting Images

Gmail provides no way to embed images, Youtube videos, sophisticated table layouts, Flash animation movies, inline podcast players like odeo, and etc. There is a copy and paste tricks that allow you to embed images into your rich text email in Gmail. You are actually copying a rendered HTML from either an existing web page or WYSIWYG HTML editor.

Gmail-Inserting-Images 

13Apr/090

How Do You Know When Your Site Get Indexed in Google Search Engine?

How do you know when your site get indexed in Google search engine. You can actually use Google search engine to find out how your site is indexed. For example:

  • to know the indexed pages in www.snipetit.com, simply query site:www.snippetit.com at Google search engine.
  • to know the pages that link to your www.snipetit.com's front page, simply query link:www.snippetit.com at Google search engine.
  • to know the current cache of www.snipetit.com's front page, simply query link:www.snippetit.com at Google search engine.
  • to know the information of www.snipetit.com's front page, simply query info:www.snippetit.com at Google search engine.
  • to know the pages that are similar to www.snippetit.com, simply query related:www.snippetit.com at Google search engine.
12Apr/090

Java: Randomly sort values in a array (the generic way) in single pass

Few years back (yes, about 4 years back), I wrote an article about randomly sort query results in MySQL. The main problem in randomly sort query results is that when you have a very large data in your database and the statement to sort the result may change the data execution plan causing DMBS does not choose the right plan. Therefore, sometime it is more wise to sort it in your own program instead of too depending on DBMS's decision which may affect the overall performance of a program.

20Mar/091

Java: Format integer into number of decimal places and performance

For certain reasons (e.g. precision issue), some programmer may store a float value (e.g. money) in integer variable. For example -12345678.90 is stored as -1234567890. To convert the integer value to number with number of decimal places is a problem.

There are several way to do it. You can simply use the Java's String.format(), DecimalFormat or Float.toString(). Most of them does not meet my requirements: Simple, fast, precise and with thousand separator. Therefore I wrote a simple class that ease myself.

20Mar/090

Java Static Constructor

Recently I wrote a Java class that maps ISO 3166-1-alpha-2 country code to country name and encountered a static constructor initialization problem. My code is as following: