Free as Freedom, not Free as Free Pizza!” />

-

Udruženje Informatičara BiH - Cross-platform and Portable Development With PHP, LAMP/WAMP development, AJAX and Javascript, ASP, dot NET, C sharp, C++, C, VB, Oracle, tutorials and tips...
Free as Freedom, not Free as Free Pizza!


 
Web http://www.uibih.co.nr

Add to Google

Wednesday, November 08, 2006

Apple releases new Core 2 Duo MacBooks

Apple today unveiled its new MacBook featuring Intel Core 2 Duo processors and offering double the memory as well as greater storage capacity than the previous generation. The one-inch thin laptops are up to 25 percent faster than the previous generation, according to Apple, and maintain the built-in iSight video camera for on-the-go video conference ... [more]

component returned failure code 0xc1f30001 (ns_error_not_initialized)

Today I will talk about a popular bug in AJAX, if you use AJAX on your site and you have a slow server you will encounter this problem, it is the problem when Firefox freezes out and do not do anything if you request an AJAX before the last one ends, if you view it in a debugger we will have this error line “component returned failure code 0xc1f30001 (ns_error_not_initialized)”...


First let us take a look at the problem, I do not want to give you a direct solution so you can copy and paste it, I will give it you at end, but let us see what is the problem. AJAX is a request from the client-side to the server-side without reloading the page, so if we use AJAX it will send a request in the background and receive what we need, and by using JavaScript elementary code it will change the content of our page. Because AJAX is a JavaScript in the first place, it will not work on JavaScript disabled browsers, so please check if your browser is blocking JavaScript, then continue with us.


As a JavaScript code, AJAX will make first a request object, this object depends if our browser is an IE or other browser, so we mostly make a function which will test which browser we are using and then call the right object. Why we are talking about the object? It is because it is the cause of the bug, and let me tel you how. When the browser sends a request we are using this object, and we can not use it in the same time until we finish using it, so if we call it we got the error we have, so we must wait for the end of it's process and then send the next request. If we are working on a slow server or with a slow connection, the client will have a problem, and the application will not work, so we need to somehow fix this problem.


The solution will be simple, logically we need a second object which will not conflict the first, and third which will not conflict the first two, and so on ... How ?

Simple, we make a unique object every time we request a page. We can use an Array of objects, so every time we request an object we auto increment our array and use it's address to follow the request, let me show you by an example:


function createRequestObject()

{

var request_;

var browser = navigator.appName;

if(browser == "Microsoft Internet Explorer")

{

request_ = new ActiveXObject("Microsoft.XMLHTTP");

}else{

request_ = new XMLHttpRequest();

}

return request_;

}

var http = new Array();

function getInfo(){

var curDateTime = new Date();

http[curDateTime] = createRequestObject();

http[curDateTime].open(\'get\', \'refresh.php\');

http[curDateTime].onreadystatechange = function()

{

if (http[curDateTime].readyState == 4)

{

if (http[curDateTime].status == 200 || http[curDateTime].status == 304)

{

var response = http[curDateTime].responseText;

document.getElementById(\'view_ajax\').innerHTML = response;

}

}

}

http[curDateTime].send(null);

}


As you can see, we will create an array “http” which will carry the object, then in the request we make a unique string, we can use the time, because it is always unique from the before “var curDateTime = new Date();”, and then we call the function and create the request in the array as a unique key for it “http[curDateTime] = createRequestObject();” ...


This is how simply we can beat this bug, no need to wait Firefox to fix this bug..

Like.com Visual Search

Over at Riya’s Like.com, interesting things have been happening. The site now presents a visual search engine that looks for the likeness of two given pictures. For example, they show off how they kind find a specific handbags within a set of celebrity photos.

I got some errors – a file-not-found pointing to shopping.riya.com, and I also you also can’t zoom into pics using their rectangle functionality for the first minute or so when you load a page – but this looks like an interesting twist to image search. Right now Like.com is restricted to pre-selected fashion items, though... this would get really cool only if I’m allowed to upload my own pics to search for similar pics on the web.

Official Wal-Mart launch details - PS3


Joystiq has been in contact with Wal-Mart corporate to get Wii and PS3 launch details. We've got something old, something new, something rumored and a bunch of stuff true.

The old: We can confirm almost everything from our previous post on Wal-Mart Wii and PS3 launch details from the "Wal-Mart Wire." The dates, the times and the ticket information is on point. The Wal-Mart stores should only give out the number of tickets for units they have. No word yet on official numbers per store, but Wii numbers should be no less than 20.

The new: Wal-Mart corporate says, "We currently have plans for a Thursday, Nov. 16 midnight event to launch PS3. In addition, Wal-Mart store #890 in Orlando, FL will host the Playstation Patrol truck Friday-Sunday." As for the Wii, Wal-Mart corporate says they are currently not accepting online pre-orders due to the popular demand, but are evaluating options for additional pre-orders before the official launch on Nov. 19. The Wii pre-order is online only, not in stores. They will let Joystiq know when a decision is made regarding the pre-order. Although the "Wal-Mart Wire" speaks directly to a midnight launch for the Wii, as does the poster above, details and confirmation can not be given at this time.

The rumor, not confirmed by corporate: If there isn't one already, all Wal-Mart stores should have a cardboard display case with free books called a "Wii Buyer's Guide" within the next couple of days. These will be replaced with the "Playstation 3 Buyer's Guide" by the 17th or when all the "Wii Buyer's Guide" are taken. The picture above is from the December issue of the Wal-Mart monthly flyer (tab) and pertains to electronic items from Nomember 12-19 (not to be confused with the weekly sale ones). A Wal-Mart employee tells us, "My store has already cleared shelf space for the PS3 and Wii accessories. Something interesting to note is that they have also restarted carrying Gamecube accessories, right next to the space cleared for the Wii. It's the first time I've seen Wavebirds on sale in over a year."

All the information regarding Wal-Marts launch details are not ironed out, but we'll update as we receive and gather more info.

Google CEO: Take your data and run

November 08, 2006 (IDG News Service) -- Google Inc. wants to make the information it stores for its users easily portable so they can export it to a competing service if they are dissatisfied, the company's CEO said yesterday.

Making it simple for users to walk away from a Google service with which they are unhappy keeps the company honest and on its toes, and Google competitors should embrace this data portability principle, Eric Schmidt said at the Web 2.0 Conference in San Francisco.

"If you look at the historical large company behavior, they ultimately do things to protect their business practices or monopoly or what have you, against the choice of the users," he said. "The more we can, for example, let users move their data around, never trap the data of an end user, let them move it if they don't like us, the better."

Schmidt, who answered questions from conference chairman John Battelle and from audience members, also championed the hosted, software-as-service model, calling it superior to the packaged software model, a clear swipe at rival Microsoft Corp.

He has believed this for 20 years, but only recently have PC and server technology and data center infrastructure become solid enough to make it feasible for people to access an application and its data remotely via the Internet, Schmidt said. "Finally now the architecture works," he said.

The hosted application model provides a more convenient experience for users because it is more robust and reliable and simpler to maintain. It also makes it easier for users to search for data across applications and share documents with each other, he said. Users also like that these applications are free, as opposed to the fee-based packaged software, he said.

This is why Google has entered this market with its word processing, calendaring, Web mail and spreadsheet hosted applications, Schmidt said. The company recently bought hosted wiki provider JotSpot Inc.

However, he cautioned that Google's hosted applications aren't "an office suite" in the style of Microsoft's ubiquitous Office and that Google isn't trying to offer a replacement for the Microsoft suite. Google's hosted applications are intended to be an organic part of people's everyday lives, he said.

Regarding Google's acquisition of YouTube Inc., Schmidt said it is likely Google will keep the video-sharing site as a separate service, instead of merging it with the similar Google Video. The reason is that YouTube is focused on the social networking and community aspect of video sharing, and Google wants it to retain that emphasis.

Java 6 JSRs Pass

osted by: Joseph Ottinger on November 08, 2006
Java 6's component JSRs have passed, along with the Java 6 umbrella JSR, which solidifies the official release components and clears the way for Java 6 to be finalized and released. Important JSRs here include JDBC 4.0, the Compiler API, the scripting interface, and the common annotations.

It's a good time to consider Java 6's future. With a new license potentially on its way, and Java 6's feature set getting finalized (along with working implementations of the feature set), Java 6 might be mature enough and open enough to have a broad impact on the industry. However, one has to consider the current installed base of older versions of Java, many of which are effectively immovable (still using 1.3 or older, or 'updated' to 1.4, for example.)

What are your opinions of the Java 6 release? If you're planning on using it, what's your deployment environment? Do you see production environments updating any time soon? Why or why not?

Belkin's Ultrawideband Hub Wins Award, But Still a No-Show

November 7, 2006 - http://wifinetnews.com have published :

By Glenn Fleishman

Popular Science gave the not-yet-shipping hub a “Best of What’s New” award: The magazine picks products released between November of the previous year and Oct. 31 of this year, but Belkin’s delivery of this device slipped. Belkin won a Best of What’s New award alongside Airgo for its early MIMO router in Popular Science’s 2004-2005 cycle. I’ve written for Popular Science in the past, so I know that the editors must have had a high degree of confidence that the device would ship by the end of last month.

Belkin’s so-called Cable-Free USB Hub (MSRP $130) will use ultrawideband (UWB) to allow driver-free connections by pairing a UWB dongle that plugs into a USB port on a host computer with a four-port AC-powered hub that can be located elsewhere in a room. In the press release for this award, Belkin doesn’t provide an expected shipping date.

Belkin was originally planning to release this in early 2006, and demonstrated prototypes (or at least brick-o-types: nonfunctioning plastic models) at CES and Macworld Expo. Their first design was based on Freescale’s UWB chips, which have not yet appeared in a shipping product. Freescale was sold to an investment consortium recently, and I have expected to see their UWB line dropped in favor of a focus on the company’s vast array of revenue-generating, already-shipping technology.

Uwb HubIn summer, reports appeared (that Belkin later confirmed) that the company was shifting from Freescale to a vendor that’s part of the Intel-led, 200-member-strong WiMedia Alliance. Belkin noted today in their press release that they would use technology from Wisair. Wisair has a USB hub reference design that will obviously be the basis for Belkin’s product. Reference designs are generally fully developed products ready for customization. Because this hub is driver-free, there’s really nothing beyond an injection-molded case and some logo silkscreening that needs to be added.

(I said that Belkin’s hub was “so-called” because Cable-Free is Freescale’s term for USB over UWB; the WiMedia Alliance has a partnership with the USB Implementers Forum, and Wireless USB is the trademarked and supported term that those two organizations will push for USB over UWB. Belkin might change the name for this reason.)

Internet Explorer 7 Open Search Discovering Simpy

Firefox 2.0 is not the only web browser that can auto-discover how a site can be searched (see Firefox 2.0 Open Search Discovering Simpy). Have a look at the screenshot below:

That's right, the newly released Internet Explorer 7 knows how to make use of Open Search to discover how a site can be searched. Go ahead, add that Simpy Search to your IE7 toolbox!

@synchronized swimming

Posted by: Dave MacLachlan, Member of Technical Staff, Mac Team

(Editor's note: today's post is a bit different from our usual fare -- it's aimed at the Mac programmers out there. And if you're not a programmer, you might want to find one to guide you through this peek behind the scenes of how we make our applications fast and reliable.)

At Google, software performance is extremely important. Every millisecond counts, which is why we spend a lot of time using performance tools and other techniques to help make our software faster. I was recently Sharking a piece of multithreaded code and realized we were getting bitten by the use of an @synchronized block around a shared resource we were using:

+(id)fooFerBar:(id)bar {
@synchronized(self) {
static NSDictionary *foo = nil;
if (!foo) foo = [NSDictionary dictionaryWithObjects:...];
}
return [foo objectWithKey:bar];
}

Shark told us without a doubt that we were paying heavily for the @synchronized block each of the millions of times we were calling fooFerBar. We couldn't create the resource in +initialize, because fooFerBar was part of a category, and overriding +initialize in a category is a bad thing. We also couldn't use +load, because other classes could have easily called fooFerBar in their +load, and there's no guarantee on loading order. So our only choice was to minimize the impact of that @synchronized block, and we didn't want to run into the infamous and dreaded double-checked locking anti-pattern.

So, I wondered, how exactly does @synchronized work? And is there a cheaper way of getting the same thread-safe result? I disassembled the code to find out what @synchronized does, and I saw something like this:


...
objc_sync_enter
objc_exception_try_enter
setjmp
objc_exception_extract

my actual code

objc_exception_try_exit
objc_sync_exit
...
objc_exception_throw
...


That's a lot of setup and tear-down for a simple lock around a shared resource. In this case, we don't need to be exception safe. By reading the Objective-C documentation on exception handling and thread synchronization, we learn that not only does @synchronized give us a lock, but it's a recursive lock, which is overkill for this particular usage.

By examining the code (ADC registration required) that implements objc_sync_enter and obc_sync_exit, we can see that on every @synchronized(foo) block, we are actually paying for 3 lock/unlock sequences. objc_sync_enter calls id2data, which is responsible for getting the lock associated with foo, and then locks it. objc_sync_exit also calls id2data to get the lock associated with foo, and then unlocks it. And, id2data must lock/unlock its own internal data structures so that it can safely get the lock associated with foo, so we pay for that on each call as well.

We need to do better than this. It looks like it's time to go back to basics, throw away the @synchronized call, and wrap our code with some pthread locks instead.


#include

+(id)fooFerBar:(id)bar {
static pthread_mutex_t mtx = PTHREAD_MUTEX_INITIALIZER;
if (pthread_mutex_lock(&mtx)) {
printf("lock failed sigh...");
exit(-1);
}
static NSDictionary *foo = nil;
if (!foo) foo = [NSDictionary dictionaryWithObjects:...];
if (pthread_mutex_unlock(&mtx) != 0)) {
printf("unlock failed sigh...");
exit(-1);
}
return [foo objectWithKey:bar];
}


This is ugly stuff, but it's significantly faster, according to Shark. And fast is what we want. We've avoided setting up an exception stack, two excess locks, and a bunch of miscellaneous support code.

So we've achieved our goal of faster code that will work fine, but are there other, cleaner options? After all, if the code is cleaner, there are fewer places for bugs to hide. Tune in for our next post, wherein we'll explore that question.

Posted by: Dave MacLachlan, Member of Technical Staff, Mac Team

Previously we addressed the problem of optimizing around a shared resource. We came up with one solution, but it was kind of messy, and we wondered if there might be a better way. And now: the conclusion.

There is at least one more elegant solution, but it is slightly less safe. So far I've assumed we're using Objective-C, but what happens if we use Objective C++, specifically Objective C++ with gcc 4? According to the GCC4 porting notes:

GCC 4.0 automatically adds locks around any code that initializes local static variables in C++. If you do not need this protection and want to reduce your code size slightly, you can disable the locking behavior by passing the -fno-threadsafe-statics option to the compiler.

This appears to be backed up by the gcc 4.0 release notes and the C++ ABI. So this implies that if we just change our compiler from standard Obj-C to Obj-C++ we should be able to do the following:

+(id)fooFerBar:(id)bar {
static NSDictionary *foo = [NSDictionary dictionaryWithObjects:...];
return [foo objectWithKey:bar];
}

which is certainly nice and clean. Let's take a quick look at the disassembly:

cxa_guard_acquire

my actual code

cxa_guard_release
cxa_guard_abort
Unwind_Resume
...

and by scanning the code for cxa_* (ADC registration required) we can see that it's doing almost exactly what we want. The only pitfalls here are if we somehow attempt to compile with a gcc version less than 4.0 (we can put in guards against this happening) or we use -fno-threadsafe-statics in a threaded environment, in which case we're asking for trouble, and trouble will certainly follow (we won't do that).

So, we've got a thread-safe shared resource that does what we want with a minimal amount of code. One last tiny issue remains. What happens if we accidentally mix our Objective-C @synchronized with C++ dynamic initialization of local statics?

+(id)fooFerBar:(id)bar {
@synchronized(self) {
static NSDictionary *foo = [NSDictionary dictionaryWithObjects:...];
return [foo objectWithKey:bar];
}
}

and the disassembly shows:

...
objc_sync_enter
objc_exception_try_enter
setjmp
objc_exception_extract
cxa_guard_acquire

my actual code

cxa_guard_release
cxa_guard_abort
objc_exception_try_exit
objc_sync_exit
objc_exception_throw
...

Yes, ladies and gentlemen, you get to pay for 4 lock/unlocks and two
exception stacks to protect your wee shared resource, so you may want
to watch for this pattern in your performance-sensitive code when
porting to Objective C++.

Feedback from part 1

Thanks to reader Bill Bumgarner, who came up with an interesting solution to my problem that has a distinctive Obj-C feel to it:

static NSDictionary *foo = nil;

+(id)fooFerBar:(id)bar {
@synchronized(self) {
if (!foo) foo = [NSDictionary dictionaryWithObjects:...];
ReplaceMethodImplementationWithSelector
([self class], @selector(fooFerBar), @selector(fooFerBar2));
}
return [foo objectWithKey:bar];
}

+(id)fooFerBar2:(id)bar {
return [foo objectWithKey:bar];
}

where ReplaceMethodImplementationWithSelector swizzles fooFerBar with fooFerBar2. So, the first time fooFerBar is called we get our slow case, and any later calls get the fast case, assuming the first thread has completed fooFerBar. This solution provides great performance, and you only have to pay for the synchronize once. Very nice!

Dell Launches New OptiPlex Workstations

Dell's new OptiPlex workstations feature AMD and Intel power
Dell continues to roll out new systems based around AMD processors. Just last week it was revealed that Dell was launching the new 15.4” Inspiron 1501 notebook with a choice of mobile Sempron or Turion 64 X2 processors. The company today announced that its new OptiPlex business systems can be equipped with either Intel or AMD processors.

The OptiPlex 740 features AMD's Athlon 64 X2 dual-core processors while the OptiPlex 320 uses Intel Pentium D dual-core processors. Both systems feature:

  • Dell Energy Smart advanced power management
  • Dell Direct Deployment services
  • Dell Client Manager
  • BTX form factor
  • Desktop and mini-tower configurations with tool-less
  • Microsoft Vista Premium-Ready

The OptiPlex 740 will start at $725 while the OptiPlex 320 starts at $585 with a Pentium D 820 processor. Both feature a standard 3-year limited warranty and next-business day on-site warranty service.

With Dell continuing to open the floodgates with more AMD-based products, the current chip shortage that is affecting some AMD partners isn’t likely to get better any time soon. Many smaller system builders and some of AMD’s largest distributors are really feeling the pinch and they are seeing dwindling stocks of popular AMD processors.

'Vote flipping' emerges as continuing problem in e-voting

Are e-voting machines mistakenly giving votes to the wrong candidates?

November 08, 2006 (Computerworld) -- During Tuesday's midterm elections in the U.S., reports emerged from across the nation about a problem called "vote-flipping," where a voter selected a candidate on e-voting hardware -- and the machine counted the vote for an opposing candidate.

The problem has ben reported in U.S. elections since 2004 as more states move to e-voting machines that are supposed to make the vote counting process more accurate. Instead, for many Americans, the process has led to more questions than answers, and suspicions that their votes aren't being counted correctly.

Stanford University computer science professor David L. Dill, who founded the nonprofit Verified Voting Foundation and VerifiedVoting.org, has been looking at vote flipping and yesterday called for investigations to stop the problem.

"People have been way too quick to diagnose the problem," Dill said. Some who have not examined the issue closely quickly call it a touchscreen calibration problem, others point to different causes. "It could be a calibration problem with the touchscreens, but I'm not sure that anyone really knows yet because no one's looked at it. My answer as a computer scientist is that I want facts ... and all I've heard for two years is speculation."

Dill said he's not convinced of one theory -- that the problem is a conspiracy to defraud voters of their votes and give the election to the opposition. Once a voter makes his or her selections on a machine, a review screen shows them for whom their votes will be tallied, which the voter can confirm or at least review. That ability to review the vote before it is ultimately cast, he said, makes it less likely that fraud is involved.

"It seems to me if you were trying to commit fraud, you wouldn't show [the ballot] to the voter," he said.

One of the possible causes of vote flipping may be voters who place their hands on the side of a machine as they vote, perhaps accidentally touching it with their thumb and erroneously making a selection, he said. In other cases, some e-voting machines use a thumb-operated wheel to advance the electronic screens and when it is turned, it highlights a candidate in the next race on the ballot -- possibly giving a voter the impression that an erroneous choice has been made for them, he said.

The way to figure it out, he said, is to bring together a panel of experts to investigate the issue, confirm it, find ways to fix it and then get any fixes out to voting officials, Dill said. Until then, election officials and watchdog groups across the country will continue to hear reports of vote flipping, he said.

"We know it's going to be a major deal," Dill said. If a voter notices the problem on an e-voting machine's review screen, they can try to go back and fix it, he said. Sometimes it takes multiple attempts to correct, according to reports. But if they don't notice it or try to go backward to fix it, their votes are improperly cast, he said.

"This problem, I think, is a national disgrace," Dill said. "There needs to be a serious independent investigation of this problem ... across the country."

Machines that use paper ballots scanned with optical scanning readers are more secure because voters have filled out the ballots themselves and a paper trail is available for any necessary recounts, he said. Although film documentaries are being made about the vote flipping problems -- and potential conspiracy theories -- "I'm not sure I buy that," Dill said. "But we definitely need to get to the bottom of it."

In his home precinct in San Mateo County, Calif., Dill said he voted on an optical scanning machine that automatically "read" the paper ballot he filled out with a pen. He wanted to try one of the new Hart InterCivic eSlate electronic machines the county bought, but the only one in his polling place was in use, he said. The eSlates used by San Mateo County include a paper record of the voter's choices that is printed out, he said.

The machines chosen by his county are not his preference, however. "I have long advocated precinct-scan optical scanning machines" using ballots filled out by voters and then read by scanners.