Thursday, December 18, 2014

Error pushing Node.js app to Heroku


If you are building a Node.js app and have been deploying your app to Heroku and testing it there all along, you might be surprised to see this error next time you try pushing your code to Heroku with the following command...

git push heroku master

The error you might see is:

Push rejected, failed to compile Node.js app

The full error may look like this:

Counting objects: 14, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (8/8), done.
Writing objects: 100% (9/9), 972 bytes | 0 bytes/s, done.
Total 9 (delta 4), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> Removing .DS_Store files
remote: -----> Node.js app detected
remote: -----> Resetting git environment
remote: 
remote:  !     Push rejected, failed to compile Node.js app
remote: 
remote: Verifying deploy...
remote: 
remote: ! Push rejected to project.
remote: 
To https://git.heroku.com/project.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/project.git'

While this is a bit of a generic error and can be caused by several different issues, one of the reasons I face it is that the npm cache is stale, so a very easy way to resolve such an issue is by cleaning your npm cache simply by issuing this command:

npm cache clean

If you require administrative privileges to run this command, adding sudo in front of the command will help, like this...

sudo npm cache clean

Hope this helps...

Until next time,
Paras Wadehra
Microsoft MVP


Sunday, November 16, 2014

My first Microsoft MVP Summit experience

I got to attend my first Microsoft MVP Summit earlier this month in Redmond, Washington. This is a huge benefit of being a Microsoft MVP. Approximately 1,500 MVPs from around the world attended the summit this year, which is an invite-only event.

Microsoft invites its MVPs to not only share news about upcoming stuff from the Redmond mill, but also to gather feedback and hear about what the community expects to see from Microsoft - the MVPs being the ears and eyes of Microsoft around the world inside the community of users who use Microsoft products everyday.

This year, I hear, was bigger and better than the years past. Microsoft hosted a MVP showcase on Sun, Nov-2 where MVPs from different technology groups showcased the stuff they've been working on. There were even some Microsoft teams like the Surface, Azure and Office who were showcasing their products. The main sessions for the summit started on Monday. Microsoft provided buses to and from all the official summit hotels to the main campus and also shuttled around the MVPs from one campus building to another as different sessions were being held in different buildings. One of the biggest benefits of hosting the MVP Summit on the main Microsoft campus is that we get to meet all the different product teams and interact directly with them. Another big benefit is being able to meet and interact with other fellow MVPs, who are all smart and highly regarded people in their respective field.

If you didn't know already, I was awarded the MVP status earlier this year in what is now the Windows Platform Development expertise, which meant I attended the Windows Platform Development related sessions for the most part. While I cannot talk about what we discussed during the sessions, as it is all under NDA - yes, all MVPs have to sign a NDA (Non Disclosure Agreement) with Microsoft in order to be eligible to attend the summit as a lot of not-yet publicly known information is shared during the sessions - I can tell you that we all live in exciting times! Oh, and during one of the sessions I saw an image of myself popup on the screen which made me smile...check it out for yourself below, I am the second one from the left.

Microsoft using my photo in their presentations

The main sessions, side sessions and one-to-one feedback sessions continued till Thursday, but I don't want you to think that it was all talks and no fun. We started out on Sunday with a Product Group event where we all got to split into teams and participate in an The Amazing Race like city-wide fun-run in Seattle. Monday evening we had team dinners, though it left a lot to be desired from a dinner perspective and lot of us had to hunt for food elsewhere. All was redeemed on Tuesday evening though, when the CEO of Microsoft, Satya Nadella, had a private talk with the MVPs followed by dinner. Wednesday evening saw the official MVP Summit Attendee Party at Fremont Studios in Seattle which was a fun social event with enough food and drinks to cater to all along with some karaoke.

Alas, all good things come to an end and with the Summit sessions over on Thursday, it was time for me to get back home. But along with me I brought back memories of some great sessions and great conversations I had over the period of the last 4 days. I got to meet so many folks that I had only interacted with virtually over the Internet via Twitter, Email, LinkedIn, Microsoft forums, etc. before the summit.

Here's hoping that I get to live another day (get to attend another MVP Summit that is).

Regards,
Paras Wadehra
Microsoft MVP
Twitter: @ParasWadehra

Saturday, October 4, 2014

Returning multiple values from a method

During your programming escapades you are sure to come across an instance when you need to return multiple values from a method.

The traditional ways of doing it are:

(i) to create an object of a class, instantiate it and assign values to the object inside the method and then return the object from the method, or

(ii) to assign values to multiple global variables inside the method and then access them elsewhere, or

(iii) to use an out parameter to return the updated value back to the calling method, or

(iv) to use a ref parameter to modify the referenced parameter directly from inside the called method.


Well, there is another lesser-known way in .Net that allows you to return multiple values from a method without having to create an object or multiple variables, it is a feature called Tuple.

Here is some sample code in C# that shows you how to create and use a Tuple to return multiple values from a method:

public Tuple<int, string, string> GetEmployee()
{
    int employeeId = 23;
    string firstName = "John";
    string lastName = "Doe";

    //Create a tuple and return
    return Tuple.Create(employeeId, firstName, lastName);
}

Regards,
Paras Wadehra
Microsoft MVP
Twitter: @ParasWadehra

Thursday, August 21, 2014

How to send email from your Windows Phone 8.1 app

As part of the API changes made in the new Windows Phone 8.1 XAML programming model, the EmailComposeTask - and several other tasks - that were available in the Microsoft.Phone.Tasks namespace in Windows Phone 8 are no longer available.

Most of these have been replaced with a new way of performing the same tasks. For sending an email from within your app, the old way in Windows Phone 8 was as follows:

OLD WAY
========

EmailComposeTask emailComposeTask = new EmailComposeTask();
emailComposeTask.Subject = "Subject";
emailComposeTask.To = "support@developer.com";
emailComposeTask.Show();


The new way in Windows Phone 8.1 to send an email from your app is as follows:

NEW WAY
=========

// Define Recipient
EmailRecipient sendTo = new EmailRecipient()
{
    Name = "Name of Recepient",
    Address = "support@developer.com"
};

// Create email object
EmailMessage mail = new EmailMessage();
mail.Subject = "this is the Subject";
mail.Body = "this is the Body";

// Add recipients to the mail object
mail.To.Add(sendTo);
//mail.Bcc.Add(sendTo);
//mail.CC.Add(sendTo);

// Open the share contract with Mail only:
await EmailManager.ShowComposeNewEmailAsync(mail);


Have fun,
Paras Wadehra
Microsoft MVP - Windows Platform Development
http://twitter.com/ParasWadehra
https://www.facebook.com/WindowsPhoneDeveloper
My WP Apps

Saturday, August 2, 2014

Xamarin Forms Shared project template error

The new Xamarin Forms Shared Project Template has a bug which causes the Windows Phone build to fail out of the box. You might see an error like:

The 'ProductID' attribute is invalid - The value 'b79569cb-1898-4dab-9173-afe40fa8559c' is invalid according to its datatype 'http://WPCommontypes:ST_Guid' - The Pattern constraint failed.

Note that the error message you receive might be a little different depending on what value is not defined properly. You are in luck though, as there is a simple fix for this.

You can fix the issue by modifying the WMAppManifest.xml file in your Windows Phone project. You need to add curly braces (are there any other style?) around the GUID values for the ProductID and PublisherID attributes. In some cases there might be other GUID values that are missing the curly braces too so add them there as well.

And that's it! This should resolve your error and get you on your path to a successfully building application :)

Cheers,
Paras Wadehra
Microsoft MVP - Windows Platform Development
http://twitter.com/ParasWadehra
https://www.facebook.com/WindowsPhoneDeveloper
My WP Apps

Wednesday, June 25, 2014

How to make your Windows Phone app vibrate?

There are 2 simple ways to make your Windows Phone app vibrate the device.

The first method makes use of the VibrateController class in the Microsoft.Devices namespace:

            VibrateController vibrateController = VibrateController.Default;
            vibrateController.Start(TimeSpan.FromSeconds(2));
            vibrateController.Stop();

The second method makes use of the VibrationDevice class in the Windows.Phone.Devices.Notification namespace:

            VibrationDevice vibrationDevice = VibrationDevice.GetDefault();
            vibrationDevice.Vibrate(TimeSpan.FromSeconds(3));
            vibrationDevice.Cancel();

In both these instances, the vibration will automatically stop after the amount passed as TimeSpan has elapsed.

You can call the corresponding Stop or Cancel method of the class to stop the vibration before the TimeSpan passed has elapsed.

Regards,
Paras Wadehra
Microsoft MVP
Twitter: @ParasWadehra

Wednesday, May 14, 2014

System.UnauthorizedAccessException: Access is denied

So you are coding up your next big app and cruising along, but suddenly you face an error like the following:

{System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()

Fear not, my friend, this is a simple case of Missing Capabilities.

For example, if you are trying to fetch the geolocation of a user, that means you are missing the ID_CAP_LOCATION capability. If you are coding a Windows Phone app, you need to open WMAppManifest.xml file in the designer in Visual Studio and then go to the Capabilities tab and select the checkbox next to ID_CAP_LOCATION.

Similarly, if you try to access other features and the corresponding capabilities are are not enabled you might see this error message as well.

Remember, there are 3 things that matter when accessing any device based features in your Windows apps: Capabilities, Capabilities, Capabilities.

Till next time,
Paras Wadehra
Microsoft MVP and Ambassador
Twitter: @ParasWadehra
FB.com/WindowsPhoneDeveloper
My WP Apps

Wednesday, March 26, 2014

1 Million Downloads, Part-2, App Statistics

This is Part-2 in a series of blog posts I am writing to detail my experiences to get to 1 Million downloads on Windows Phone.

In this post, for the first time ever, I will make public detailed info around my app statistics which will show you how my top apps have performed since launch. I will also correlate some spikes I've seen with promotions I've run or new updates I've launched. Please note that the charts you see below are not from the same time period or include up to date downloads count info.

I'll start with statistics for my most popular app, Dictionary:

Dictionary






























As you can see, getting featured in the Windows Phone Store really helps drive downloads for your app. The sustained organic growth period you see above is actually due to Dictionary winning first place in the Best Educational App category of the first-ever Windows Phone App Awards, beating competition from Microsoft and other competitors.

Now, let's take a look at SketchPad:


Again, the effect of getting featured in the Windows Phone Store clearly shows its benefits. I've been fortunate enough to have SketchPad featured in different countries across the world several times now.

Let's take a look at Unit Converter:


This chart shows you the bumps received in the download count just by updating the app to include new features and functionality. Users really like seeing their feedback being incorporated in the app.

Here's Events For Me:


This chart not only shows you the benefit of getting featured in the Windows Phone Store, but also getting a good review on WP Central. In this case, the WP Central review drove the most downloads in 1 day to the Events For Me app.

I've saved the best for the last though, be prepared to be flabbergasted, as I show you The DVLUP Effect. Here's a look at the downloads for my Chess game



And here's the interesting part. See that red circle with a minor bump on the road? That is what you see in the chart below.



This shows you how using campaigns from DVLUP, I was able to achieve The DVLUP Effect which dwarfed downloads from any other promotions. Soon after launch, in early 2012, the Chess game also won 1st place in Microsoft's You've Got Game competition.

Windows Phone Store placements and DVLUP Campaigns have been a god given gift for an indie developer like myself.

In Part 1 of this blog series, I shared the news about my apps hitting 1 Million downloads on Windows Phone and introduced you to my apps.
In Part 3 of this blog series, I will talk about mistakes made and lessons learned.
In Part 4 of this blog series, I will talk about monetization and promotion mechanisms I've used over the years and which ones have worked better than the others.

Cheers, 
Paras Wadehra
Do you DVLUP?
Twitter: @ParasWadehra

Thursday, March 20, 2014

1 Million Downloads

I am happy to report that my apps have surpassed the 1 Million download mark on Windows Phone.



This is the first post in a series of blog posts I will be writing about my lessons learned, mistakes made, best practices, monetization and promotion practices, among other things, so keep an eye out!

I've been able to get to this special landmark a few days before 3 year anniversary of my first app launching on Windows Phone.

I would love to share my development experience with you all, in hopes of helping all aspiring app developers out there.

My first app (or rather a game), Tic Tac Toe, launched in the store on 25-Mar-2011. I wrote this as a personal learning experience on Windows Phone. I included ads in the game and I soon started seeing some ad revenue trickling in. I used to get excited when I made 5c/day in ad revenue in early days - simply because it meant someone out there downloaded my game and was playing it. Soon I saw that number climbing up, 10c/day, 25c/day and soon I was seeing $1/day in ad revenue coming in.

By then I had already launched a couple more apps in the Windows Phone store, Transit Maps USA and Dictionary, the first Dictionary app on Windows Phone. It got featured in the Windows Phone Store and I immediately saw the effect of that as to the increase in my downloads and ad revenue. And since then I haven't looked back and launched new apps constantly on the platform, though in the last year I have been focused on updating my existing apps with new features rather than creating new apps, given the time constraints as this is a hobby outside of my job. I've been able to help create Windows Phone apps for some big name apps on the store as well along the way.

Given that I was developing apps at a rapid pace for the platform, I got accepted to receive early access to the Windows Phone Mango (WP 7.5) update in 2011, before it launched and subsequently to Windows Phone Apollo (WP 8) in 2012, as well.

My current apps on the Windows Phone platform include, in chronological release order:

As you will see from the list above, I launched a majority of my apps in 2011 and then focused on maintaining and updating those apps for the most part with a few other apps launching in 2012 and 2013. I have several unfinished projects that I need to find time to finish and polish to publish them in the store. I also have a wish list of many more apps that I want to develop.

When Windows 8 was announced, I ported my Unit Converter and Tic Tac Toe apps to that platform as well and saw some good download numbers for both of these apps.

In Part 2 of this blog series, I provide detailed breakdown of my app statistics and the download performance associated with major releases, updates and promotions.
In Part 3 of this blog series, I will talk about mistakes made and lessons learned.
In Part 4 of this blog series, I will talk about monetization and promotion mechanisms I've used over the years and which ones have worked better than the others.

Cheers,
Paras Wadehra
Do you DVLUP?
Twitter: @ParasWadehra

Monday, March 10, 2014

Announcing Windows Phone Day in Portland, OR

I am proud to announce the Windows Phone Day in Portland, Oregon on Saturday, May 3, 2014.

Learn to make amazing Windows Phone apps at the Windows Phone Day event and you may win big for launching your apps in the store. Join Nokia Developer Ambassador Paras Wadehra & Windows Phone Development MVP Kelly White, as they provide hands-on Windows Phone development training and teach you how to get your app in the store. Even if you barely know how to code, you will walk away with the ability to write a mobile app.

Windows Phone Day is a unique community event that combines presentations by Windows Phone experts along with hands-on help for attendees to get started on their apps. Work with our experts, get started on your app or game, publish it within 3 weeks after the event and get a chance to win a free Windows Phone 8 device!

BRING YOUR LAPTOP!
Make sure to have Windows 8 running with Visual Studio and the Windows Phone 8 SDK installed on it, prior to the event. Windows 8 Pro is best because this will let you run the full Windows Phone 8 development environment and emulators. Windows 8 (non Pro) can develop Windows Phone 8 apps but cannot run the emulator, so you will need to test your app on a physical device.


Eventbrite - Portland Windows Phone Day


See you there,
Paras Wadehra
Do you DVLUP?
Twitter: @ParasWadehra
FB Group: http://bit.ly/WinPhoneDev
My WP Apps

Sunday, February 16, 2014

Windows Phone App Promotion

Well, it has been a while since I've run a promotion for all of you Windows Phone developers out there, so I am giving away a Nokia Lumia 520 to one lucky developer who writes and publishes a new app in the Windows Phone store by Mar-31.

This low memory device is the most popular Windows Phone in the world and every developer needs to test his/her app against it to make sure the app works for the majority of the users.

Contest: Write a new app or game for Windows Phone
Prize: A Nokia Lumia 520 phone
Deadline: 31-Mar-2014
How to enter: Email ext-Paras.Wadehra AT nokia DOT com with a link to your app before midnight on Mar-31 with subject "I want to win the Lumia 520"
Restrictions: You need to reside in Northern California (anywhere above San Luis Obispo county), Nevada, Oregon or Idaho
Bonus: You can enter multiple times, once per new app!

Cheers,
Paras Wadehra
Nokia Developer Ambassador
INETA Community Champion
Twitter: @ParasWadehra

Terms and Conditions
* The app needs to have been published for the very first time between Feb-16 and Mar-31, 2014
* The app needs to be live and searchable in the Windows Phone store before midnight on Mar-31.
* The winner will be selected soon after the entries close and will be informed via email. The winner will have 48 hours to respond with the details requested otherwise the prize may be awarded to an alternate winner.
* I reserve the right to modify these terms and conditions at anytime.
* If Nokia Lumia 520 is not available at the time of prize drawing, another prize of equal value will be substituted.
* The app needs to be a Windows Phone 8 app.

Wednesday, January 29, 2014

Sorting a List in C#

I often receive emails from developers asking for help with their development conundrums. One of the common questions I get asked, especially from someone learning C# and writing their first app, is how to sort a list of items.

It's quite simple actually; there are 2 ways you can sort a list, and both have their own purpose as defined below.

Using the first method you can sort a list in place, i.e. without having to create a copy of the list. E.g. if you had a list of an object which contained a date and you would like to sort the list in chronological order, you can do something like the following:

MyList.Sort((x, y) => x.OrderDate.CompareTo(y.OrderDate));

The second method does not sort the list in place, but rather returns a sorted copy of the original list:

List<Employees> lstEmployees = MyList.OrderBy(emp => emp.JoinDate).ThenBy(emp => emp.empID).ToList();

This example also shows you how to sort the list based on 2 parameters, in this case Employee Join Date and Employee ID, so if there were multiple employees who joined the company on the same date, they will be further sorted by their Employee ID.

Hope this helps!

Regards,
Paras Wadehra
Nokia Developer Ambassador
INETA Community Champion
Twitter: @ParasWadehra

Saturday, January 4, 2014

The build stopped unexpectedly because of an internal failure.

If you ever receive the following error while doing development in Visual Studio, don't fret, it just means your system is running low on memory. Close a few apps, or restart Visual Studio and/or your system, if need be, and then try rebuilding your app and it should work like a charm!

The build stopped unexpectedly because of an internal failure.

Microsoft.Build.Exceptions.BuildAbortedException: Build was canceled. Failed to successfully launch or connect to a child MSBuild.exe process. Verify that the MSBuild.exe "C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe" launches successfully, and that it is loading the same microsoft.build.dll that the launching process loaded. If the location seems incorrect, try specifying the correct location in the BuildParameters object, or with the MSBUILD_EXE_PATH environment variable.

Happy New Year,
Paras Wadehra
Nokia Developer Ambassador
INETA Community Champion
Microsoft Windows Phone Champ