Red Theme Green Theme Blue Theme
RSS Feeds:
Posts
Comments

Believe it or not, if you do this in JavaScript: 103 x 67.12, you will get 6913.360000000001. This happens on both Microsoft Internet Explorer and Firefox. Try this your self.


Basic Math Errors in JavaScript

The calculation… Should equal… Your browser’s
  answer…
81.66 * 15 1224.9
103 * 67.12 6913.36
24.88 + 4.35 29.23

In terms of mathematical accuracy, 81.66 times 15 unequivocally equals 1224.9, as any sixth grader with a pencil and a piece of paper can demonstrate. But computer is in binary world. it has to convert decimal to binary number before calculation and there may be a problem to convert floating point decimal to binary. This is same for all computer languages. To avoid this, you need to know the scale (the number of decimal positions). Then you can convert the floating point decimal to an integer and scale it back at the end. i.e. (67.12 * 100) * 103 / 100. In Java, BigDecimal can be used to setup the scale.

JavaScript has a built-in method - toFixed, can be used to fix this issue easily as well.

amount = 103 * 67.12;
result = amount.toFixed(2);

So don’t forget this when you deal with a floating point decimal even for addition or multiplication.

There is an issue in Microsoft’s latest SP1 for Visual Studio 2008. If you have a partial class with Using statement at the top of the file for a Linq-To-SQL Data Classes context object. You will get above error. Visual Studio will delete the corresponding “.designer.cs” file for your data context and nothing will be compiled.

 To solve this issue, you may have to move “Using” statements inside namespace declaration. This is a workaround provided by Microsoft.

I ran into an issue earlier when trying to serialize an object return by LINQ. After Googling it, I found following blog which is very helpful.

LINQ to SQL and Serialization

I believe this is a common issue for LINQ objects and hope this blog can save time for somebody.

When you attempt to login to your database using SQL Server Authentication and you get an error message that says:

Cannot open user default database. Login failed. Login failed for user ‘usrLogin’. (Microsoft SQL Server, Error: 4064)

It might possibly be due to the fact that the database that was set up to be the default for that specific login has been deleted. 

What you need to do is update the login to have a default database that you know exists. Here’s how to fix it. Open a command prompt and type the following:

For SQL 2005:
osql -S SQL01 -d master -U usrlogin -P usrpassword
ALTER LOGIN usrlogin WITH DEFAULT_DATABASE=new_default_db    

For SQL 2000:
isql -S SQL01 -d master -U usrlogin -P usrpassword
(opens query analyzer, type the next line in there)
sp_defaultdb ‘usrlogin’, ‘ new_default_db’   

If this didn’t fix the problem… try this link:
http://benharrell.wordpress.com/2007/01/15/cannot-open-user-default-database-login-failed-login-failed-for-user-username-microsoft-sql-server-error-4064/

Kiosk applications and other self-service systems are rapidly growing business area.  Internet connectivity, a greater variety of interface equipment and prices that continue to drop are enabling the cost-effective deployment of an ever widening array of applications. Hardware is available for a wide spectrum of requirements. Vendors such as NCR and 5point can meet most any need

Kiosk Software application development is relatively straightforward. Many kiosk applications now use an ordinary PC attached to various more specialized interface equipment such as touchscreens, card readers, special keyboards, and trackballs. Equipment and kiosks can be purchased for either indoor or outdoor usage, outdoor equipment is noticably more expensive.  Outdoor kiosks have special needs due to weather, water and sunlight.  

Usually either .NET or Java is used as an application language. The operating system is either Linux or Windows XP. Kiosk applications can be a specialized web site program or more traditional client application.  There are special security programs for controlling access and monitoring the kiosks (such as Kioware). These programs prevent access to the computer or any application other than those specifically permitted.

Touchscreen applications are much like any other except the interface elements typically have to be much larger. This can be especially challenging when working with spreadsheet like programs or interfaces. Most interface hardware available today has a well defined software API and can usually interact seamlessly with the programming.

Unidev recently completed two separate kiosk applications. One was an application which allowed visitors to search a large database of products and images to obtain detailed information about the products and pricing. By automatically providing this information on a round the clock basis, the vendor is able to interact with all potential customers even when salespeople are not available.

 The other application provides an automated method for filling out and validating data entry forms by customers. This application saves a considerable amount of labor as well as ensures the data is correctly filled out and validated while the customer is on site saving considerable rework.

Both of these applications communicate with a central server for obtaining updates of both code and data, sending report information to the server and monitoring. The server applications provide a central data collection point for management reports.

Self-service kiosks have proven themselves to be a cost effective tool for both labor savings and improving service levels to customers.

2007 saw continued growth and expansion of the web marketing and web design service lines of The Net Impact business unit.  The web development team went through a number of process changes over the year as staff was added. A new formal development methodology was implemented in conjunction with a new enterprise project management system. These changes allowed for much improved communications with customers and with other teams in the company. The Net Impact formed several strategic partnerships in the 4th quarter that will both expand the potential client base as well as significantly increase the sales efforts for the services.

The software development and outsourcing groups had the strongest growth for the Unidev business unit. Outsourcing development, production support and maintenance continues to be a strong and growing revenue contributor. The software development team primarily used .NET and J2EE this last year.  We saw very little demand for other technologies. An important goal for 2007 was to improve development methodologies and processes in order to deploy products more rapidly. The software group implemented a much improved enterprise project management system tool as well as organizational and process changes to successfully meet this goal.  

2007 was a year of significant growth and change within the company as The Net Impact became a fully integrated business unit. 2008 should be a great year as we continue to build and improve on 2007. For 2008 we will be working to increase our commercial applications integration services, developing new and improved technology solutions to web marketing and increasing our mobile applications development efforts.

Java - Find a given date belongs in which quarter:
SimpleDateFormat sdf = new SimpleDateFormat();
sdf.applyPattern(”MM/dd/yyyy”);
Calendar calendar = Calendar.getInstance();
Date processDate = sdf.parse(”4/10/2007″);
calendar.setTime(processDate);
Date date1 = calendar.getTime();
int quarter = TestDate.getQuarter(date1);
System.out.println(”Quarter for the date : “+sdf.format(calendar.getTime())+” is : “+quarter);
Prints the following Result :
Quarter for the date : 04/10/2007 is : 2

Java - Code for getQuarter() function:
public static int getQuarter(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
int year = calendar.get(Calendar.YEAR);
int[] months = { 3, 6, 9, 12 };
int count = 0;
do {
calendar.set(year, months[count++], 1);
Date tempDt = calendar.getTime();
if(date.compareTo(tempDt)
return count;
} while(count
return 0;
}

Java - Find previous quarter begin and end dates for a given date:
SimpleDateFormat sdf = new SimpleDateFormat();
sdf.applyPattern(”MM/dd/yyyy”);
Calendar calendar = Calendar.getInstance();
Date processDate = sdf.parse(”4/10/2007″);
calendar.setTime(processDate);
Date date1 = calendar.getTime();
int quarter = TestDate.getQuarter(date1);
String currentQuarterBeginDate = “”;
String fromDt=”";
String toDt=”";
if ( quarter ==1){
currentQuarterBeginDate = “01/01/”+calendar.get(Calendar.YEAR);
}
if ( quarter ==2){
currentQuarterBeginDate = “04/01/”+calendar.get(Calendar.YEAR);
}
if ( quarter ==3){
currentQuarterBeginDate = “07/01/”+calendar.get(Calendar.YEAR);
}
if ( quarter ==4){
currentQuarterBeginDate = “10/01/”+calendar.get(Calendar.YEAR);
}
calendar.setTime(sdf.parse(currentQuarterBeginDate));
calendar.add(Calendar.MONTH, 3*-1);
fromDt = sdf.format(calendar.getTime());
String formmatedQuarterBeginDate = sdf.format(calendar.getTime());
calendar.setTime(new java.util.Date(formmatedQuarterBeginDate));
calendar.add(Calendar.MONTH, 3);
calendar.add(Calendar.DAY_OF_MONTH, -1);
toDt = sdf.format(calendar.getTime());
System.out.println(”Previous Quarter Begin Date : “+fromDt);
System.out.println(”Previous Quarter End Date : “+toDt);

Prints the following Result :
Previous Quarter Begin Date : 01/01/2007
Previous Quarter End Date : 03/31/2007

Java - Find previous Date for a given date:
SimpleDateFormat sdf = new SimpleDateFormat();
sdf.applyPattern(”MM/dd/yyyy”);
Calendar calendar = Calendar.getInstance();
Date processDate = sdf.parse(”4/10/2007″);
calendar.setTime(processDate);
calendar.add(Calendar.DAY_OF_MONTH, -1);
String previousDate = sdf.format(calendar.getTime());
System.out.println(”Previous Date is :”+previousDate);
Prints the following Result :
Previous Date is :04/09/2007

Java - Find previous Sunday for a given date:
SimpleDateFormat sdf = new SimpleDateFormat();
sdf.applyPattern(”MM/dd/yyyy”);
Calendar calendar = Calendar.getInstance();
Date processDate = sdf.parse(”4/24/2007″);
calendar.setTime(processDate);
int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK);
calendar.add(Calendar.DAY_OF_MONTH,-1*(dayOfWeek-1));
calendar.setTime(calendar.getTime());
String endDt = sdf.format(calendar.getTime());
System.out.println(”Previous Sunday is :”+endDt);
Prints the following Result :
Previous Sunday is :04/22/2007

Enjoy!!!!

Do you have performance issue on your ASP.NET website? Do you want to boost your site’s scalability? Do you know the bottleneck of your site? Do you want your site performs well under 100 times more traffic? Here are some good posts about this:

10 ASP.NET Performance and Scalability Secrets

Boost ASP.NET performance with deferred content loading

Keeping a medium sized contract programming company up to speed on the latest technologies is a daily challenge. With a wide variety of technologies and skillsets in use at any given time and with the future technology needs of the company being very customer driven, it can be very difficult to put together individualized training plans. Our solution was to develop a more ‘university’ environment where we constantly have optional classes on a wide variety of new and current technologies. In this way, employees are able to choose which directions they feel works best for them and they are able to investigate a variety of choices without having to commit to a particular path. In our experience, this has worked quite well with a number of surprises about which directions people choose. With an array of topics such as J2EE, C# .NET, Web Marketing methods, HTML, Project Management, RAD and Network Architecture, employees can explore many possibilities. Unidev has a number of types of work including software developers who work on customer projects at the development center, technology consultants who work both at the customer site and in-house, Web marketing consultants and IT staffing personnel who augment customer development teams. This variety of work along with the various technologies employed makes for a very interesting learning environment.

We have a project which needs to show foreign language, like Chinese, on a web page. And we are using RICO 2.0, PHP, MySQL & ASP.NET in the project. To achieve this, we decide to use UTF-8 character set and the following changes need to be done:

  • MySQL:

To store UTF-8 in a table field, you need to set column’s charset => utf8 and collate => utf8_unicode_ci

  • Web Page:

To show foreign language in a web page, the page file has to be saved as encoding UTF-8

  • PHP:

The default encoding for PHP 5 is UTF-8, so it supports foreign language. But if you use PHP to retrieve UTF-8 characters from MySQL, you must add mysql_query(’SET NAMES utf8′); after connecting to MySQL database for setting up the connection encoding.

  • RICO:

As for RICO Live gird, Ajax response must start with <?xml version=”1.0″ encoding=”utf-8″?>

  • ASP.NET:

First make sure you have following line in you web.config
<globalization requestEncoding=”utf-8″ responseEncoding=”utf-8″ fileEncoding=”utf-8″/>
Second, keep both .aspx and code behind file save as the same encoding UTF-8
If you need to access the UTF-8 characters in MySQL database, be sure to use MySQL Connector/Net 5.0 or up with undocumented setting: charset=utf8 in connection string. We tried ODBC driver for MySQL, it doesn’t work properly with UTF-8.

Older Posts »

Indoor Lighting | Cyprus Villas | Walk in Baths | Vista Themes
Close
E-mail It