June
11th

Links to sample code for the Windows Phone 7

I’ve got this big list from the official MSDN forums and thought would be nice to post here. It’s a comprehensive list of sample code and resources to help get up to speed with Windows Phone 7 programming.

Below the full and useful list of links:

Accelerometer; Simulating accelerometer data in the Windows Phone 7 Emulator

http://blogs.silverarcade.com/silverlight-games-101/27/silverlight-simulating-accelerometer-data-in-the-windows-phone-7-emulator/

Animation; Ptorr Slides, Video and Code (Page Turn animation etc.)

http://blogs.msdn.com/ptorr/archive/2010/03/18/slides-video-and-code.aspx

Audio; Audio Recording in WP7

http://mobileworld.appamundi.com/blogs/peterfoot/archive/2010/03/26/audio-recording-in-wp7.aspx

Comms; Accessing WCF Data Services from WP7 CTP

http://blogs.msdn.com/priozersk/archive/2010/03/19/accessing-wcf-data-services-from-wp7-ctp.aspx

Comms; Calling Web Services with Silverlight 2 (general example)

http://timheuer.com/blog/archive/2008/03/14/calling-web-services-with-silverlight-2.aspx

DB; Siaqodb on WindowsPhone7 (a local object database)

http://siaqodb.com/?p=202

External; Sample image encoders, decoders (png, gif, bmp)

http://blogs.msdn.com/jstegman/archive/2008/10/30/updated-source-for-image-samples.aspx

Foursquare; Foursquare for Windows Phone 7

http://4square.codeplex.com/

Games; Physics Games in Silverlight on Windows Phone 7

http://www.andybeaulieu.com/Home/tabid/67/EntryID/194/Default.aspx

General; Africangeek.com: A collection of WP7 samples (navigate, WCF, Blend)

http://www.africangeek.com/

General; MSDN; Code Samples for Windows Phone

http://msdn.microsoft.com/en-us/library/ff431744(VS.92).aspx

General; Silverlight Toolkit

http://silverlight.codeplex.com/releases/view/36060#DownloadId=93513

Geo; Simulate Geo Location

http://timheuer.com/blog/

Graphics; Free icons (Archetype)

http://archetype-inc.com/yard/fundamentals/icons/

Graphics; Icons for Windows Phone 7

http://www.wp7series.net/blog.asp

Graphics; MSDN: Application Bar Icons for Windows Phone 7 Series

http://www.microsoft.com/downloads/details.aspx?FamilyID=369b20f7-9d30-4cff-8a1b-f80901b2da93&displaylang=en

InkPresenter; Silverlight for Mobile on Windows Phone 7 InkPresenter fun

http://www.nickharris.net/2010/03/silverlight-for-mobile-on-windows-phone-7-inkpresenter-fun

LINQ; Creating LINQ Data Provider for WP7 (Part 1)

http://blogs.msdn.com/priozersk/archive/2010/04/14/creating-linq-data-provider-for-wp7-part-1.aspx

LINQ; Reactive Framework (Rx) Wiki Samples

http://rxwiki.wikidot.com/101samples

Manipulation; Blog;WPF Manipulation Basics

http://blogs.msdn.com/llobo/archive/2009/12/21/wpf-manipulation-basics.aspx

Manipulation; Simple Gesture Sample

http://blogs.msdn.com/ptorr/archive/2010/03/23/simple-gesture-sample.aspx

Manipulation; Simulating Multitouch on the Windows Phone 7 Emulator

http://jonas.follesoe.no/SimulatingMultitouchOnTheWindowsPhone7Emulator.aspx

Map; Sample: Using the Bing Maps Silverlight control on the Windows Phone 7

http://silverlighthack.com/post/2010/03/21/Using-the-Silverlight-Bing-Maps-control-on-the-Windows-Phone-7.aspx

Misc; Coding4Fun: Windows Phone Cannon

http://blogs.msdn.com/coding4fun/archive/2010/03/16/9979874.aspx

MVVM; Galasoft MVVM LightToolkit

http://www.galasoft.ch/mvvm/getstarted/

ODATA; Developing a Windows Phone 7 Application that Consumes ODATA

http://blogs.msdn.com/phaniraj/archive/2010/03/19/developing-a-windows-phone-7-application-that-consumes-odata.aspx

ODATA; Odata Client Library for WP7

http://www.microsoft.com/downloads/details.aspx?FamilyID=b251b247-70ca-4887-bab6-dccdec192f8d&displaylang=en

Orientation; Strategies for Dealing with Orientation Changes

http://blogs.msdn.com/ptorr/archive/2010/03/27/strategies-for-dealing-with-orientation-changes.aspx

Panorama; Building the Elusive Windows Phone Panorama Control

http://blogs.claritycon.com/blogs/design/archive/2010/03/30/building-the-elusive-windows-phone-panorama-control.aspx

Panorama; Panoramic Navigation on WP7 (gestures Multitouch)

http://aimeegurl.com/2010/03/18/panoramic-navigation-on-windows-phone-7-with-no-code/

Panorama; Windows Phone 7 Panorama Control sample

http://blogs.msdn.com/stephanc/archive/2010/04/04/windows-phone-7-panorama-control-sample.aspx

Push; MSDN; Developing an Application for Push Notifications

http://msdn.microsoft.com/en-us/library/ff402552(VS.92).aspx

RSS; Windows Phone 7 Series RSS reader

http://www.silverlightshow.net/items/Windows-Phone-7-Series-RSS-Feed-app.aspx

Silverlight; Silverlight Documentation Samples

http://samples.msdn.microsoft.com/Silverlight/SampleBrowser/index.htm#/

Silverlight; Silverlight Toolkit (Silverlight 2)

http://silverlight.net/content/samples/sl2/toolkitcontrolsamples/run/default.html

Silverlight; Silverlight Toolkit (Silverlight 3 extended controls)

http://silverlight.net/content/samples/sl3/toolkitcontrolsamples/run/default.html

Tilt; Sample: Tilt Effect for Windows Phone Controls

http://blogs.msdn.com/ptorr/archive/2010/03/23/tilt-effect-for-windows-phone-controls.aspx

Twitter; Sample: Building a Windows Phone 7 Twitter Application using Silverlight

http://weblogs.asp.net/scottgu/archive/2010/03/18/building-a-windows-phone-7-twitter-application-using-silverlight.aspx

WebSite; MSDN; Designing Web Sites for Phone Browsers

http://go.microsoft.com/?linkid=9713253

WPF; WPF Samples

http://msdn.microsoft.com/en-us/library/ms771633.aspx

WrapPanel; Sample: Silverlight Toolkit and the Windows Phone: WrapPanel, and a few others

http://www.jeff.wilcox.name/2010/03/toolkit-and-the-windows-phone/

WriteableBitmap; Render XNA content into Silverlight Writeable Bitmap

http://www.uta.fi/~tp79800/Silverlight/WindowsPhoneApplicationXNA.zip

XNA; Space Rocks game (step 7)

http://blogs.silverarcade.com/silverlight-games-101/30/silverlight-space-rocks-game-step-7-moving-the-ship/

June
10th

How to install Windows Phone 7 Developer Tools on Windows XP

Workaround for installing Windows Phone 7 Developer Tools on Windows XP:

  1. Download the Windows Phone Developer Tools 
  2. Extract the contents of the setup package by running vm_web.exe /x and choosing a path to extract to
  3. Go to the folder you extracted to in step 2 and open the file baseline.dat in notepad
  4. Look for the section named [gencomp7788]
  5. Change the value InstallOnLHS from 1 to 0
  6. Change the value InstallOnWinXP from 1 to 0
  7. Save and close baseline.dat
  8. Run setup.exe /web from the folder you extracted to in step 2
September
22nd

How to solve Internet Explorer 8 (IE8) slow problem to open a new tab

You just installed Windows and all your software, only to discover that you’ll need another browser because Internet Explorer is damn slow to open a new tab?

You have no more, since I have the solution here for you.

What happens is an incompatible add-on installed by Java and that takes almost half a second or more to load EVERY TIME you open a new tab.

That can be annoying. Really. So let’s get rid of that.

Go to Tools menu and click on “Manage Add-Ons“.

On the new window that opens, under “Toolbars and Extensions,” scroll to “Java(tm) Plug-In SSV Helper.” Click on it and then click on the “Disable” button.

It’s a Java add-on for controling versioning and it won’t affect you too much on a daily basis. If by any chance you hit a page with a Java Applet that doesn’t work then you can enable this add-on temporarily and disable it afterwards.

And you’re done! Restart IE8 and I’m so sure you’ll be much more happy on your internet browsing. :)

java ssv addon

September
9th

How to setup NetBeans as a C++ programming IDE

 Recently I discovered NetBeans as a free IDE solution for my open source programming needs. Although I rather stick with Visual Studio which is a soberb tool and programming environment, there’s case where it can’t be used like when I’m programming in PHP or I want to use ANSI C++ through Cygwin environment.

Here I will teach how to setup Netbeans for C++ use and in the next post, for PHP.

It’s pretty simple, so let’s get started;

  1. Go to http://www.netbeans.org/downloads/index.html and download latest version with the C/C++ plugin package. After finishing the download, install it.
  2. We’re already half way through (I told you it was simple), now we have to download and install the Cygwin programming environment. Head for www.cygwin.com and click on “Install or update now” (picture below, marked in red)
  3. cygwin page

  4. Now, run the setup.exe, select the download location and hit next, it will show the package selection screen. You’ll have to select at least the following (click on “skip” to select):
    * gcc-core: C compiler
    * gcc-g++: C++ compiler
    * gdb: The GNU Debugger
    * make: the GNU version of the ‘make’ utility.
  5. Any necessary package is selected automatically when you select the ones above.
  6. Click install and wait (it may take several minutes depending on your internet connection)
  7. Finished the installation, you have to add the Cygwin Bin folder to Windows Path environment variable. Open Control Panel -> System -> Advanced System Settings -> Environment Settings… Select “Path” on the System Variables listing and click “Edit…” (picture below)
    windows path settings
  8. Add the Bin folder of your Cygwin installation (usually “C:\Cygwin\Bin”).  Click Ok to close the dialog.
  9. Now run NetBeans, create a new Sample Project (select the Welcome Project) and try to run it. Afterwards, put the cursor on any code line go to Debug -> Toggle Line Breakpoint and hit Ctrl + F5 to start debug. It should stop on that breakpoint.
    netbeans cpp
  10. If everything went fine you should now be able to program in C++ using NetBeans. Sweet!

Next post I will teach how to setup NetBeans as PHP IDE, stay tuned!

September
6th

How to fix PHP error: php Failed to initialize storage module: files (path: )

If you face this error after you install PHP (following my tutorial for example) here’s the fix.

This error is triggered on a call to the function session_start(). The problem is that PHP doesn’t know where to save your session variables and data. For what I read, this is particularly true in a Windows environment.

That said, open up your favorite text editor, open php.ini on it (mine is found on C:Php) and search for the setting: session.save_path

Probably it is commented out. Uncomment it (remove the ; in front of the line) and assign a writable path to it. I’ve put C:WindowsTemp here and it worked.

It should look like:

session.save_path = “C:WindowsTemp”

After that, open IIS and restart your application pool for the settings to take effect. Do not forget to give IIS user write access to that folder!

Enjoy PHP!

September
3rd

Stevie Wonder plays with Chick Corea and Stanley Clarke

Yesterday I had the pleasant surprise of watching Stevie Wonder play a superb piece of jazz with the all-star team of Chick Corea, Stanley Clarke and Lenny White and singer Chaka Khan at the Hollywood Bowl.

Chaka was singing while all of a sudden Stevie came to the stage. The musicias were surprise as were us the audience. Nobody knew what to do and the show must go on. Stevie got out his harmonica and started playing along’em. Then he grabbed one of the mics and started singing along Chaka for the pleasure of all hundreds of people present there that night. Next, he played a piece of jazz along with Chick and Clarke.

Truly awesome, Stevie is terrific, even more live! I’m very happy of having the opportunity of watching him live!

Below is a picture of him playing:

Stevie Wonder plays.

Stevie is da shit!

September
2nd

Loop Optimization – Conditions

In this article I will discuss some techniques and ways to optimize a loop that contains “if” conditions.

I always say that, after writing a considerable piece of code or function, stop for at least 5 minutes and think about it, what errors it might have or how can you optimize it further. After a while doing this you’ll see that 5 minutes will be enough to get you redoing part of it or optimizing something. That makes you a better programmer!

Anyways, one thing I read on the book “Programming Pearls” is that “An efficient inner loop should contain as few tests as possible, and preferably only one.” How many times we found ourselves writing a few bunch of ifs as conditions to exit the loop while we could have done it in a different and more efficient way?

So consider a loop like this:

for(int n = 0; n < 10; n++) {
   if(n == 7)
      doSomething();
   else if (n == 5)
      doSomethingElse();
   else
     doAnotherSomething();
}

 Could we had used a single switch instead of the if…else series? Absolutely YES! And I tell you what: that’s better.

I’ll show you.

for(int n = 0; n < 10; n++) {
   switch (n) {
   case 7:
      doSomething();
   case 5:
      doSomethingElse();
   }
}

Now let’s look the assembler code necessary to run both of this excerpts of code.

The ifs would become something like:

cmp eax,7;
jz  doSomething;
cmp eax,5;
jz  doSomethingElse;

While the switch would become:

jmp [VECTOR_LIST+eax];

As you can see, switchs are highly optimized by the compiler. It generates a jump instruction using a list of pointers to the address of the start of the doSomething and doSomethingElse functions.

So whenever you can, use a switch instead of several ifs!

September
2nd

Gmail Offline

gfail whale

Yesterday panic spread across a large number of internet users: Gmail was down.

Was it terminated? Is the earth being invaded by aliens? What happened? Google offline: it must be the beginning of the end of the world.

user desperateWho lives without email today? Almost nobody, right? So, during the 100 minutes that Gmail was offline, what all these users were doing? What were we supposed to do without our beloved email client?

It’s a shame how our lives depend so much today on technology. If we count how much time we (including me) spend on the virtual world of internet, we’ll see that we live more on a virtual world than on real life itself. Maybe in the next centuries, technology will allow one to transfer his mind to some sort of receptacle where our mind can exist and interact with other minds and we won’t need our body anymore. A great number of people today wouldn’t notice the difference…

Now, enough of all this nonsense, let’s take a look on official Google explanation about the incident:

“However, as we now know, we had slightly underestimated the load which some recent changes (ironically, some designed to improve service availability) placed on the request routers — servers which direct web queries to the appropriate Gmail server for response. At about 12:30 pm Pacific a few of the request routers became overloaded and in effect told the rest of the system “stop sending us traffic, we’re too slow!”. This transferred the load onto the remaining request routers, causing a few more of them to also become overloaded, and within minutes nearly all of the request routers were overloaded. As a result, people couldn’t access Gmail via the web interface because their requests couldn’t be routed to a Gmail server. IMAP/POP access and mail processing continued to work normally because these requests don’t use the same routers.”

As you can see, it was an overload problem with their routers, looks like their contingency plan wasn’t very well elaborated. And yesterday all hell broke loose after the routers stopped because of a high load.

After this episode one thing is for sure: next time you face yourself without your favorite email client you may:

1) Read a book

2) Go outside and take a sun bath

3) Go to the gym

4) Talk to others!

5) Fire up yout secondary email client and start sending your messages from it! (we are, indeed, a lost case!) :)

August
26th

FLV playback works on local system but not on web server

 I had an assignment on my job to create a small FLV movie stream playback for a commercial movie from one of the companie’s product.

I started the task, everything was working fine, I managed to create an AVI from the DVD provided to me, I used the movie playback component from Flash and blend it all together to create the final result. So far so good, all success. Easy task, even easier accomplished.

The problem started when I uploaded the HTML and the FLV resulting file to our server.

All I got was a blank screen and it took me, incredibly, almost 2 hours to figure out what the heck was happening with something that was working flawless on my machine.

So, to save everybody some time, here’s the secret: You have to create a new MIME type on the IIS of the web server. Probably I didn’t have to do that on my local machine as Flash was installed already and maybe it took care of these steps for me.

  1. Open IIS and navigate to the website.
  2. Right click it and open up the “Properties” dialog.
  3. Click on the HTTP Headers tab, select “File Types” and under MIME map click “New Map”. If you are using the new IIS, click on the website and on the right side panel, double click the MIME Types button. On the next screen, click the “Add…” link on the far right side panel.
  4. Type “.flv” as the extension and “video/x-flv” as the content type.
  5. Click OK, close the windowand you’re all set!

iis screenshot

August
26th

Historic Cars Race

This weekend I had the opportunity to watch a Historic Cars Race at Sonoma, CA before the Indycar Race.

That was awesome, it was like a dream comming true to see those old Formula 1 cars running around, the awesome roar of the engines and better, to get closer by and touch a 1980 Ferrari!

I could see McLaren, Ferrari, Shadow, Lotus, Brabham, March and a Penske. That was very exciting!

Here are some pictures for you:

ferrariferrrari 2mclaren

ferrari wheellotusrace