Archive

Archive for the ‘Rant’ Category

Make WORK your favorite!

I SWEAR, I LOVE that quote from Elf.  It cracks me up every time I say it.

make-work-your-favorite

 So this blog is in response to the “you should blog more”, which I get a LOT.  Where does that COME from?  I don’t blog much.  I would say RARELY.  I try to blog about things that are productive, but they always turn into crazy rants.  THAT’S what THIS is.  I figure I’d get that out of the way so it would NOT be incorporated into my NEXT blog post which should actually be HELPFUL.  At least I HOPE it’ll be helpful.

 I SHOULD be working!  There is SO MUCH to do.  Why the HELL am I blogging?  I read about 4 or 5 different posts about “infinite or endless” scrolling.  This is a term used where your client (web or app) requests a bit of data to fill the screen which returns MUCH faster than attempting to request ALL of it.  Instead of having paging controls that just take up valuable real estate on the screen, the client monitors the scrolling of the window and if the user scrolls down then more data is loaded to fill that empty space.  The user keeps scrolling and the client keeps requesting more data.  There were a few posts about this that were total crap and totally confusing.  I stumbled across one that was pretty close, but they took their complex example and went with it (and some of their HTML was malformed and didn’t render properly).  If you’re going to demonstrate a piece of core functionality, then your objects DON’T need to be that complex.  Keep it SIMPLE!!  THEN if you want to go into something crazy then by all means DO THAT.

So that’s what I’m going to try to do with my next example.  Keep it bare bones and then if I feel like I have the time, then expand on that.

And THAT’S the problem.  WHO has the time to BLOG?  If there isn’t WORK  or other obligations to do (like random legal bullshit) then WHY the hell would anybody BLOG when they COULD be playing Xbox?  Yeah, I don’t get it either.  I certainly DON’T get paid for this.  I would definitely like to THANK the people who took the time to blog about endless scrolling and I could piece together the different examples (most that did NOT work right out of the box) and make it my own.  So I will take the complex code that I’ve already expanded upon and make it SIMPLE for the next post.

</rant>

If you’re following this then PLEASE SAY SOMETHING.  Put a comment below and THANK YOU for listening to my rant.

Advertisements
Categories: Rant

Idiot Driver 3.0

“Why don’t you blog more?” … “You should blog more.” I’ve been hearing that more and more. Who REALLY has the TIME to DO this?? So it’s been WELL over two years since my last blog post. Since two-dot-oh Twitter has changed their interface and with THAT… my app was broken. I don’t know EXACTLY when that happened, but it happened. Needless to say, I was PISSED. But why should I try to fix it? Twitter was just going to change their interface AGAIN and then my application would be broken… again.

The voice control was pretty much a hack. There was PROMISE of an API (Application Programmer Interface), but nothing really showed up from Microsoft. The Windows Phone 8 came out, but I didn’t have one. So what was the point of fixing idiot driver? All roads pointed to a dead end and some SERIOUS LACK of motivation.

I’m not sure where I got this motivation to rev back up and get in gear. Could it be my new found love of the Top Gear show and how they LOVE to make fun of EVERYTHING? That really could have been IT! It’s been hard to find the time. A few hours here. A few hours there. My to-do list was getting WAY out of hand, but then suddenly I was getting it under control.

My FIRST step was go for broke. Windows 8.1 I thought. I thought WRONG. I’ve been using Visual Studio 2013 for quite some time and the NEW way to run the phone emulation was through Hyper-V (Microsoft’s virtual machine code). By default I believe the Windows Phone SDK (Software Developers Toolkit) comes install by default with VS 2013. If it doesn’t, it’s easy enough to download and get up and running. Microsoft even GIVES their “express” version away to entice more developers. So even BEFORE I generated a template project I needed to get Hyper-V going.

So the RIGHT way to do this is to go to the BIOS FIRST. Make sure that your machine supports virtualization. The Hyper-V installation will tell you what options you need. As it turns out, my aging HP HAS these options but they aren’t on be default. You can typically get to the BIOS by rebooting and then frantically pressing F2, F1, F8, F10, F11, F12… Well, it’s ONE of those. I usually hit the right one eventually. Sometimes the boot screen will actually TELL you which key to press for the BIOS. Yeah. Press THAT one. Dig around and find the virtualization options and make sure they’re ON.

Once you reboot you will have to turn on the Hyper-V options ON in the Windows Options section. This is the “Features” section of the “Programs and Features” control panel. Turn on as many of the Hyper-V options on as you can. You might have to reboot. Yes. AGAIN! But quite possibly I didn’t have to this time.

You will NOW be able to run the phone emulators. If you haven’t set things up correctly, and believe me, I HADN’T quite a few times then these things won’t run. If you’re about to give up, then don’t worry. You can run your development code on your phone or better yet, your OLD phone that you couldn’t trade in. You can register these devices when you get your Windows Phone development account. You can only have so many phones registered at a time, but I think the max is three. If you’re named your new device the SAME name, you will have to UNregister the old phone and the REregister the NEW phone.

If you’re running your emulators fine and then you see weirdness that your application doesn’t authenticate with Twitter… Check the time on the emulator. Make sure the phone emulator time matches the REAL time otherwise you won’t be able to logon. You can close down the emulator and restart it or you can go into its settings to fix the time. This probably happened overnight when your computer went to sleep and the emulator went to sleep along with the computer. When the computer wakes back up, the phone emulator DOESN’T resynchronize with the computer. Sad panda. L

Once you’ve got something on which to run your code, you can create a template. I started with Windows 8.1. I called it PhoneApp2. I figured I could change the name later. Oh wait. I didn’t change the previous version, PhoneApp1. The conversion was going slow and I was creating ALL NEW views and using ALL NEW controls. I sure did MISS the old controls though. I used the ListPicker heavily, but I didn’t see it as one of the standard controls. I had converted the MainPage, About, Settings, and Disclaimer. Things were compiling and I was getting things set up the way they were. I needed to bring TweetSharp into the fold, because the API looked very straightforward. My old code just made the REST calls using Hammock. What a pain in the ass THAT was. I knew I needed to change from THAT mess. I tried to install TweetSharp from NuGet. NO support for Windows 8.1 because the Json serializer wouldn’t install because it wasn’t built for 8.1. BUMMER! All that time wasted. Going with 8.1 and then finding out that it wasn’t going to happen.

That was actually a blessing in disguise, because I created a Windows 8.0 project. Of course I called it something original. Yes. The default. PhoneApp3 was born. When I was digging through the files again of PhoneApp1 I found a README.txt file. Why didn’t I see that before? At the top of the file mentioned the use of the Windows Phone Toolkit. Ah-HA! This was readily available through NuGet as well. Of course I NuGot it. Is that a word? Past tense of NuGet is most certainly NuGot. Or is it NuGetted?

I NuGot TweetSharp which grabbed the Newtonsoft Json Serializer and Hammock (the REST easy library). I just started with the MainPage view. A few controls including the browser (for the oAuth 1.0b authentication). A few application buttons. All I wanted to test was to see if I could talk to Twitter. I could grab a few oAuth keys from the Twitter AppDev pages to bypass the logon. I plugged this stuff into the TweetSharp code and in a few minutes I had about 20 of my latest tweets showing up in my app. SUCCESS!! I coded up the oAuth browser response stuff using most of my old code for reference. Then it was mostly a matter of cutting and pasting the controls from my old PhoneApp1 project (Idiot Driver 2.0) and pasting them into newly created files. I was determined to stick with the MVVM (Model-View-ViewModel) pattern that I’ve been using for Silverlight and WPF. I was successful at this in MOST places, except for the application buttons. You can’t {Bind} to a RelayCommand there. Maybe you can do it in 8.1, but certainly NOT in 8.0. So you have to go old-school and hook up the click event. I created a utility class that would help me with the transition from the code behind (an evil place to put your logic) to the ViewModel. I created a routine to translate the DataContext to the ViewModel generically. I also created a class to call the RelayCommand which I needed for the old-school events.

I found two articles done by somebody who helped with the voice recognition libraries and those helped a TON. I scooped some code out and go the license plate and rant prompts working. I was STUNNED that I could dictate letters and numbers and the code would actually spell out license plates (ABC 123). Since the spacing was rather arbitrary I added some translation code which would turn the word “space” into an actual space. I did the same with “hyphen” and “dash”, which in the end they all got turned into underscore “_” characters anyway so they would be recognized as a Twitter #hashtag. I had to add more options because the API isn’t great at recognizing sentences so I added code to turn the word “period” into a period. I’m not sure if I’ll go total “Dragon”, but it would be nice if you could edit your tweet using your voice versus saying the entire thing over and over until the API recognizes EXACTLY what you’ve said. That’s for FUTURE versions I guess.

So a few more hours sprucing the thing up a bit and getting a few more bugs ironed out. You can edit your default tweet list and turn on/off more options. Once piece of code that I was FINALLY able to implement is the #hashtag #everything option. #This #will #turn #ALL #your #words… Well YOU get the picture. It’s annoying. That’s why you can turn the feature on and off. I swear. I’ve SEEN tweets like this though. THEY need this app!! They can type normally and the app will make their tweet annoying FOR them.

The publishing experience was actually easier than before. The Windows Phone Dev Publishing center remembered all my settings from before. The only hard part was adding the screenshots. That wasn’t working because I needed to delete my old ones FIRST, and THEN add my WXGA ones which would scale down automatically. Once I got that figured out, my app was back out in the store within about an hour of submission. Of course as SOON as you publish, you find bugs. So the next night I’m fixing those and then re-publishing. And the next night. Which brings me to version 3.2. It’s pretty stable. And what can you expect for FREE!

So I’ve put down my coding keyboard and picked up the “creative” keyboard to bring this shiny new blog entry. I doubt you’ve made it to the end, but hopefully you don’t feel like I’ve wasted your time, since I certainly feel like I have. But if you laughed just ONCE, then I’ve done my job.

Idiot Driver 2.0

My FIRST thought is WHY did this TAKE so (expletive deleted) DAMN long?  All right, all right.  I’ll cut you some slack Microsoft.  You DID give me the App Dev account for FREE.  I’ll give you that.  PLUS, you’re making sure my code isn’t stealing somebody’s password or doing something malicious to their phone.

That’s the timely news.  But if we warp back to two weekends ago, I would have been throwing QUITE a few expletives towards Twitter.  It was rainy and overcast and was the perfect time to update Idiot Driver to 2.0 and apply the “metro” look to the main page.

I have a few custom controls that I wrote for the settings page that prompt for input.  The first one is just a single field with Ok and Cancel all placed on a modal background.  I can adjust THAT font size so it’s a bit bigger (I know, it should be even BIGGER – next version).  Most of the default text blocks are pretty small.  Call it programming for the blind.  Which I am.  Oh sure, I can SEE, but I need a powerful prescription to see WELL.  I added a small “drop arrow” to the metro button so it looks more like a drop down list.  WHY Microsoft didn’t make this style a default is beyond me.

This modal field was NOT wrapping the text and was seriously annoying so I fixed that.  AND I intercepted the “Back” button in the modal field so it wouldn’t dismiss the entire page and go back to the previous page or exit you out of the application.  If the modal is displayed, the first press of the back button will dismiss the keyboard and the next press of the back button will dismiss the field.  A minor technicality, but definitely a LOT less annoying.

Raj sent me some code that he found on the net which basically adds the tilt effect to EVERY control that can do it.  So I added these tags to the top of each page and it just WORKED.  I was pretty happy about that, but the highlight color is pure white which is pretty ugly.  Maybe not ugly enough to try to change it before the next release, but I’ll get to it.

xmlns:STK=”clrnamespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit”
STK:TiltEffect.IsTiltEnabled=”True”>

 I added <<MYTAG>> substitution which is similar to the <<TAG>> substitution but it replaces the <<MYTAG>> with YOUR license plate it you’ve defined it.

The name change was pretty easy too.  Just make sure that all or your application name references are changed (including the manifest).  By doing that, the name will change in the Windows Marketplace.  I think that’s what took so long with certification and then the subsequent publishing to the WM.

The thing that REALLY got me all steamed was the fact that Twitter changed their REST (Representational State Transfer) response.  Everything above, including the manifest change, took me about 3 hours.  I was all set to test things on thephone (versus testing on the emulator).  That means I had to re-authenticate with Twitter.  This is where things failed.  I was able to get to the Twitter Authentication page, but once I pressed OK the navigation events would trigger and the response came back compressed.  The code I had was definitely NOT expecting this and spit out some graphical characters in the error box.  This meant that TEXT was definitely NOT coming back from Twitter and I had a long road ahead of me to try to figure out what was going wrong.  I Bing’d a bit and found that Twitter had made an announcement a while back that they WOULD be doing this.  GREAT!  I just get my application out to the marketplace just in time for Twitter to change their
minds AGAIN.  Just like with the first Twitter hurdle, the posts are REALLY old and out of date.  Although I saw something that looked promising.  “All I had to do was set two properties in the request and everything worked!”  This was coming from some post.  So I tried it, and I got nothing.  I was still getting compressed data in the response.  I figured I was going to have to decompress it myself.

I ended up using a GzipInputStream in one of the libraries that I was already using.  There was quite a bit of setup because you have to take the “character” data and convert it to bytes.  Then put the bytes into a MemoryStream.  THEN hand the MemoryStream off to the GzipInputStream.  I tested it and I got “bad magic”.  No.  SERIOUSLY.  “Bad Magic” means that the first two bytes of the data were NOT correct.  Not the correct “magic” (or completely arbitrary) numbers that mean THIS data stream is “Gzip Compressed”.  For data that has been gzipped those magical first two bytes are 13 and 139.  The stream that was coming back from Twitter was 13 and 253.  I tried quite a few permutations of properties and spitting things out to the debug window and I could ONLY debug the stuff ON my phone.  PHUN!!

if (response.Headers[“Content-Encoding”] == “gzip”)
{
    // MAGIC: First byte (13), second byte (139)
    // BOGUS coming back from Twitter: First byte (13), second byte (253)

    byte[] bytes = StringToByteArray(content);

    //bytes[1] = 139;

    using (MemoryStream stream = new MemoryStream(bytes))
    {
        using (GZipInputStream gzipStream = new GZipInputStream(stream))
{
using (StreamReader reader = new StreamReader(gzipStream))
{
StringBuilder builder = new StringBuilder();

                while (reader.Peek() > -1)
                {
                    int theByte = reader.Read();

                    builder.Append(((char)theByte).ToString());
}

                content = builder.ToString();
}
}
}

    Debug.WriteLine(string.Format(“content = ‘{0}'”, content));
}

I tried different Gzip libraries that Hammock might recognize to NO avail.  SIX hours later I figured I needed to head back to Bing.

I ran across a thread on a Twitter API forum that took me back to CodePlex.  REALLY?  I had gotten just about every library from CodePlex so why not some SOURCE?  I grabbed the source for Hammock and SharpZipLib.  That didn’t work.  I was getting reference errors and the namespaces were out of whack.  More Binging…  I found https://github.com/GunioRobot/hammock and downloaded the source from there.   I scooped those pre built DLLs from the projects and plopped them into my project.  BOOM!  Object reference not set.  AGAIN!  REALLY?  I stepped through the code and bit and saw something out of alignment.  So I brought the Hammock AND SharpZipLib project into MY project and hoped for the best.  I ABSOLUTELY could NOT believe it.  All of the source compiled and loaded onto my phone.  It actually WORKED!!  I threw my arms up in the air.  TOUCHDOWN!!  WOOO!!  I could NOT believe it.  I was hopeful, but wasn’t expecting even THIS to work.  So if I initially had ALL of the source in my project then…   “All I had to do was set two properties in the request and everything worked!”

I apologize to my friends that aren’t nerds who actually stuck it out to the end of this.  My brain hurt for quite a few hours, at least YOURS can hurt for a few minutes reading this.  😉

Crazy Driver – Don’t be an IDIOT!

Don't be an IDIOT!

Crazy Driver Disclaimer

I thought I’d post the disclaimer a bit bigger than what’s in the Windows Phone Marketplace.  Plus, many people have asked me if I had a disclaimer. Yes.  Yes I do. I certainly don’t want to get sued because people are idiots.  If you haven’t had a close call trying to “quickly” reply to a text then you WILL.  It’s just like riding a road bike (or mountain bike).  There are those who HAVE wrecked and those who WILL.  And you MIGHT just want to be wearing that helmet because you never know when you WILL.  So my close call was with a curb.  I was going pretty slow and missed it due to my video game reflexes.  BUT!  You never know when there will be a kid right there on his skateboard or running to get a ball.  So it’s good NOT to do it.I’m excited for the voice to text to be available on the phone.  Hopefully it’s SOON!  Hello?  Microsoft?

That’s why I typically launch the SMS text application FIRST and try to say everything to a new text message.  It doesn’t have to be TO anybody, just so you’re able to “talk” to your phone.  Then cut and paste the snippet(s) into Crazy Driver and let that person HAVE IT!

Of course you don’t even have to be driving.  You could be the passenger while your mom or dad is driving.  I see that quite a bit under the #CrazyDriver hashtag.  Or you could be walking to your car in the parking lot and one of your co-workers tries to run you over.  That’s a good time to let them have it too.  Sorry Raj.

So go ahead and download the app, confirm that you’re NOT an idiot, and tweet to your heart’s content.

Crazy Driver 1.0

You know how it is.  You’ve got your to-go cup of coffee and you’re blaring KBPI on the radio.  Things are going smooth until you’re out of the neighborhood and down by the post office.  Then you see him behind you.  A big old pickup racing up behind you.  Apparently poor planning on HIS part BECOMES your problem.  He SLAMS on his brakes.  DUH!  We’re at a stoplight you dumbass.  The traffic slowly starts moving again right past the Walgreens.  Yeah, they’re EVERYwhere, aren’t they?  And just as you expect, the guy behind you cuts over and passes you in the right hand lane that just opened up.  But of course HE didn’t see the other guy pull out up ahead.  I’m expecting this.  You HAVE to expect this.  And he swerves into MY lane.  I glance at his license plate “DUMBASS”.  OK.  That’s NOT what it said, but it SHOULD have.  Or at least ID10T.  You raise your hands and yell some obscenities.  They’re GOLDEN.  But nobody heard you.  The guy in front of you is already flicking his cigarette out his window and has swerved back to the right.

That’s when it hit me.  I want to push a button on my phone and through the Blue Tooth integration in my stereo the radio mutes and a digitized voice comes across the speakers.  “This is Crazy Driver, what would you like to rant?”  I say “License plate D-U-M-B-A-S-S.  Ranting why the hell did you cut me off you idiot?!”  The app thinks for a second and then fills in the appropriate fields and parses out the tweet “Why the hell did you cut me off you idiot #CO_DUMBASS #CrazyDriver.”  I glance at my screen and the tweet is scaled up so I can read it on the tweet tile.  I’m good with that since I don’t feel like stopping at the next light to add the question mark and five exclamation points (remember the disclaimer?).  I hit the tile and it’s sent.  I feel better.  Not as good as activating a 0.50 caliber machine gun on my roll cage and blowing the guy off the road, but better.

So after signing up with Microsoft’s 30 Days To Launch event I got a free developer account and was able to publish Crazy Driver.  It didn’t take a whole lot to build, because I was able to find code on the net that did the tweeting.  But there was still some learning curve.  If I got my application to certification by a certain date then I could have won a new Windows Phone, but that didn’t happen.  I have a regular development job and I was working on Mass Effect 3 too.

Not bad for my first Crazy Driver blog post.  I’ll post what I’ve learned and where you can find the oAuth code since the first snippet of code that I found didn’t work and I had to Bing again.

I LIKE this font.

THIS font I like. See how it reads like book? Now doesn't that feel like
you're reading a legitimate article?

So here's what I did. I ended up editing one of the old articles that converted
from the MSN Spaces. I switched to the HTML view and took the various styles in
the tag and pasted it into notepad. I compressed each span tag into one
and saved it into my blog.html template file. I closed out that file from
notepad and dropped it into the Visual Studio 2010 that I was running at the
time. C'mon. WHO uses notepad to edit HTML anymore? Really? Sure, in a
pinch. But there are MUCH nicer editors out there. I'm not saying that VS
2010 is the BEST, but it's what I'm used to.

Technically I'm using Word as my editor right NOW. But I'll paste
this into Studio and look at the HTML Word generates, which is a whole lotta
crap and stuff that Word Press doesn't care about and will just confuse it. I
tried that already for the previous article and it just wouldn't do it for me.
So I'll use Word for that red squiggly spell checking that I'm used to, that's
about it. THEN paste it into Notepad to strip out all of the bloated HTML
that Word puts in.  Copy THAT from Notepad and paste it into Studio
to check out the HTML and make sure that WP doesn't throw up all over it and
convert my post to something that looks like crap versus what I'm seeing now in
Word.

So if the planets align correctly then you'll be seeing this post in Times
New Roman and slightly grey. See? THERE! So now I can get on with
converting a few of my game reviews out of Outlook and post them here.

I hate THIS font.

Yes.  The font you’re reading.  I HATE it.  I’m fine with the font used for editing this post.  The font I’m using right NOW is a nice serif font that looks like Times New Roman.  I like that.  It’s pleasing to read.  It looks like a book or a “real” article.  And it makes me feel like a “real” writer.  The other san serif fonts look like something you’d type up in Notepad.  Something temporary.  Like a GUID (goo-id) that you have to remember for a download so you paste it into Notepad and then save it to your desktop (or not).  And then your machine crashes during the initialization process and you had WISHED you had saved it.

See the font that’s used in the Mixed Case post?  THAT’S the font I want to use.  THOSE posts came over from the MSN Spaces and were converted straight over with the font preserved.  Maybe I have to upgrade my Word Press account in order to JUST change the font on these posts.

Why even HAVE that “Visual” tab up there if what I’m seeing NOW while I’m typing isn’t going to be exactly what’s posted?  If I were Word Press I’d change that label to “Approximate Visual”.  I even created the post below in Word.  Then saved it as HTML so I could paste it in exactly as I typed it in.  No such luck.

Unfortunately for now…  When I post this article, the font will change and it’ll look like crap.  Sorry about that.

I figured it out shortly after I posted this. Check out the LATEST article.