October 2007 Entries

So my manager, Martin, emailed me asking why the delayed startup application wasn't a bit more selective on what it opened.  I know why I excluded the .ini file but other than that, do I really care what a user puts in that folder?  Nope.  The startup folder doesn't.  If someone wants a word document to boot up or a batch script, who am I to say that is a bad idea?

But this question got me reflecting on a higher level of exactly why do I design applications like I do?  I think this is a result of a few things that have shifted from the past to where I am now.  Back in the day, I'd do whatever was cool, neat, or interesting and really didn't think about reusability.  I really don't think back then there was an instance when I needed to reuse code actually.

Move forward a bit, I entered the wonderful world of the internet.  This was my first venture into real user interaction.  HTML could only do so much and I could only do so much with graphics.  When I first started everything looked like it was either a terminal prompt or massive font-sizes and still butt-ugly.  Coding wise however, stuff started to become more refined.  I have two projects I have to deal with on code that is over 5 to 7 years old that I wrote.  Now the old folks that read this blog may go, pfff, that is nothing.  For me that puts me back in diapers.  Plus half the time I can't remember what I ate for dinner much less coded a few days ago.  The stuff I could do 3 years ago and now is night and day.  But the nice things is I can read that code and follow the logic a lot easier.  I know why I did certain things.  I named stuff properly.  You can also start seeing things go from 800 options to 30 options.  Easier to use for everyone, including me to code / update.

Crack the dial up even further, now I adopt a "Can my mom use it" philosophy.  I first used this with my Senior Capstone at DePaul University.  I've used it for a lot of other projects too.  People look at me weird when I said "this is total crap, my mom can't figure this out, who the hell knows what this icon means, where is the help text?"  Yes, the swearing was edited out but this is a real conversation I had.  But when designing an interface, does the user need 800 options or is that just a power user thing?  Go simple, make life easy.  My mom gets overloaded from too many opinions.  She expects a power button in the middle of a computer.    With that said, you must know your target audience for the application.  Too simple and stripped down and you'll have a revolt on your hands. 

API's in my opinion are the same way.  Giving me all the power in the world is really nice but at times can be harmful.  I'm just as guilty for doing 400 different params on my arguments or having them SO powerful and flexible that without a book, you can't figure out what is going on.  My solution to this is normally to actually write a wrapper object that is super simplistic and does the bare minimum of what is needed for this super complex object.

I think both User Interface designing and API designing have to follow a trait.  Know your audience, listen to them, and do what needs to be done.  This doesn't mean that you have to do everything they want unless it actually suits a purpose.  Person A's request may counter exactly what Person B wanted.  Who cares?  Well, Person A and B, but to be honest, not me.  I'll take both requests and listen to them but then I'm going to do my own thing and develop the product I want to do.  I got this bit of advice from a project manager (doesn't work at Microsoft) and I've taken it to heart more and more.

To recap

  • Can my mom use it?
  • Listen but you don't have to do everything someone asks
  • If you need to have a complex object / interface, make an simple wrapper for it too

Why did I create a delayed startup program?  After I saw all the stuff my manager had booting up on his computer, I thought this may be useful.  His computer really wasn't terribly usable for a good 10 minutes after a reboot so I decided to spend a few minutes and create him a nice program while I'm at a .Net User Group meeting (they had free food and it was 1 floor up in my building).  My theory is most of the programs in your startup folder aren't actually needed asap.  I don't need OneNote open right away, I don't need a bunch of other stuff right away.  The nice thing is now I can have Visual Studio, Outlook, IE, and a few other programs I run everyday not impact me restarting my computer's bootup time since they'll do a gradual loading sequence.

Why isn't there an application to do the configuration file?  Because I'd hope someone could decipher 3 lines of XML.

Here is the source code (and the .zip file) and the installer

Source Code:

[STAThread]
static void Main()
{
    string startupPath = Environment.GetFolderPath(Environment.SpecialFolder.Startup);
    string delayedStartupFolder = GetSetting("DelayedStartupFolderName", "Delayed Startup");

    int TimeDelayBeforeStartingSeconds = GetSetting("TimeDelayBeforeStartingSeconds", 10);
    int TimeDelayPerProcesssSeconds = GetSetting("TimeDelayPerProcesssSeconds", 5);

    DirectoryInfo di = new DirectoryInfo(startupPath);

    Thread.Sleep(TimeDelayBeforeStartingSeconds * 1000);
    string delayedFolder = Path.Combine(di.Parent.FullName, delayedStartupFolder);
    if (Directory.Exists(delayedFolder))
    {
        di = new DirectoryInfo(delayedFolder);

        FileInfo[] files = di.GetFiles();
        foreach (FileInfo file in files)
        {
            if (file.Extension.ToLower() != ".ini")
            {
                Process.Start(file.FullName);
                Thread.Sleep(TimeDelayPerProcesssSeconds * 1000);
            }
        }
    }
}

private static int GetSetting(string key, int defaultValue)
{
    int.TryParse(ConfigurationManager.AppSettings[key], out defaultValue);

    return defaultValue;
}

private static string GetSetting(string key, string defaultValue)
{
    return ConfigurationManager.AppSettings[key] ?? defaultValue;
}

App.Config:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <appSettings>
        <add key="DelayedStartupFolderName" value="Delayed Startup"/>
        <add key="TimeDelayBeforeStartingSeconds" value="10"/>
        <add key="TimeDelayPerProcesssSeconds" value="5"/>
    </appSettings>
</configuration>

Source for it can be found over at http://www.peacelovecode.com/ for the search application.  c# and all that good stuff.

On a side note, I realized when publishing a new version of PLC, it deletes the directory.  That is kind of crappy if you ask me.

So last night I created something I was plotting to do for a while.  A search page for myself that does both the google and live search engines.  I'm hosting it over at Peace Love Code at http://www.peacelovecode.com/search/UpdatedSource Code posted at peacelovecode.com.

Now why did I do this?  To prove live's engine is better?  No.  I did it cause I did google searches before working at Microsoft a lot.  It is built into muscle memory.  I'm at google before I even know what hit me.  This was a cool way for me to see which engine gives ME better results.  I search for weird stuff, technical stuff dealing with computer languages and reverse engineering query string variables that are cryptic but deal with what I'm doing.

Smooth as silk Successes:

  • Dealing with the Live API's was easy.  Live's API allows me to do paging and return between 1 and 50 results unlike ...
  • Going from postbacks to ASP.Net Ajax callbacks are super easy.  One might as ... too easy.
  • I remembered how to do code without touching it for a few months.  I demand a cookie for doing this.

Problems:

  • UTF8 is evil.
  • The Google Ajax results is a hack using their Ajax search results.  Who knows how long they will allow this to work like this.  They can change it and break what I'm doing at any time.
  • Reverse engineering objects from JSON is hard.
  • Finding the api key for Live Search was a bit harder than I thought.  Microsoft calls it an AppID.  It can be found at http://search.msn.com/developer.
  • Google's wasn't exactly a walk in the park either if you don't enter through the front door (I didn't).  Their signup can be found http://code.google.com/apis/ajaxsearch/signup.html.
  • Google's Ajax Search results only give me 8 results back.  I don't think there is a way to page the results also.
  • Using ASP.Net Ajax, I couldn't fire off 2 Ajax requests side by side it seemed like.  I know there is some way to do it, I just don't know how ... yet.  This is for the "Search" button.  I want both panes to update independently.
  • I couldn't do a straight port of the app to ASP.Net Ajax, I know if I actually searched for this, I'd be able to convert the ASP.Net version to ASP.Net AJAX with ease.
  • Installed ReSharper and am fighting with some of the key bindings, they are different than what I had at my old job.

I'm with stupid moments:

  • It took me too long to figure out to do a server-side focus on a control is controlName.Focus();  I was looking for a function when there was a method call to do it right in my face.
  • I blanked out once on doing CSS

So I'm attempting to get a cool demo of Ajax up and working but am fighting one API every way since I'm actually not actually using their API in a traditional context.

After some tweaks, I got the JSON to c# object working but now I have a text encoding problem.  Some of the data from the object is in UTF-8 for HTML reasons.  < becomes \u003C and what not.  But since that \ needs to be escaped, it becomes \\.  \\u003C is not actually the same as \u003 when you do this wonderful line of code.  Now the real question is how dangerous do I want to be with this.  I could do a regular expression validate test the data.

\\\\u[A-Fa-f0-9]{4,4} would properly validate it according to Wikipedia if I read the standard correct.  I may just be overcomplicating this since I really think the greater than and less than symbols will be the only ones used.

Here is the function that is causing me the headaches. 

private static string Utf8ToUnicode(string utf8)
{
    return Encoding.Unicode.GetString(
        Encoding.Convert(
        Encoding.UTF8,
        Encoding.Unicode,
        Encoding.UTF8.GetBytes(utf8)));
}

Update:

I don't know if this is even possible since by stripping out one of the slashes, it still won't programmatically shift to UTF8.  Only way I can get it to read as UTF8 is if I literally hardcode in the string.  So right now I have 3 replacements, <, > and & were the UTF8 encoded characters I saw.  I'm betting there will be more but can't do much until I see them.

So with the new job and my unique ability to get bored with a project right when it is near complete, I've been neglecting my automated bartender system.  I had it "done" at Maker's Faire, however, the primary relay boards sucked and made me say naughty words that aren't appropriate for little children or the elderly to hear.  So I have an outlined view for version 2.

  • Replace the tubing with something less "grippy".  The current stuff is hard to adjust since it clings very nicely to other tubes.  I was thinking Polyethylene but have to verify that won't deteriorate.
  • Don't flush all the lines.  Only flush the lines on stuff that needs to be flushed.  Stuff like Orange Juice, yes, flush it.  Whiskey doesn't need to be.
  • Switch from AC to DC.
  • New relay boards (already talked about those).
  • Different wiring harness to reduce wiring complexity.
  • Fix some rendering bugs in the program that annoy only me.
  • Hopefully I can get Ian to recreate some sweet flat versions of the icons.  But this is an optional thing since I know he has better things to do.

 

The old systems.  Note the rat's nest of wiring and tubes.  Goal is for the new version to fix this.

IMG_3577

 

1 episode of House later ... 100% disassembled.  I love how it took more than 2 days to wire them up and I undo it all in 45 minutes.  Now to see how much of this I can reuse.

IMG_3581

 

Boiling up all the old connectors to get them all nice and clean.  Who knows what got into the tubes when I was moving but they were wide open.

IMG_3583

 

All the nice DC valves.  Yup, 2 different types for 2 different things for two different purposes.  The white ones are the DC version of the previous valves I had before.  I bought out the store of the polycarbonate valves so that is why I only have 7.

IMG_3584

IMG_3573

In my never ending task of doing crazy projects, one important part just came in, the gyro for the skateboard.  This sucker is super small too.  This weekend I'll start to do some coding with it but I do need to figure out the header part # so I can get a matching one for the RS322 adapter and have a nice cord.

NEWS-8304-0f8369b2200fd71aa345c168f88476e4[1] After a few hours of testing, retesting, migrating, reviewing old PHP code, updating old config files, and realizing what I did 5 years ago wasn't too horrible, I think everything is fixed.  The old hosting company managed to restore both missing databases, I migrated them, and then verified it still works.

One of the sites has a database I'm not totally sure what it is there and couldn't find a db user login. 

OperationDoorstep2-DemolishedHouse4[1] So a few of my brother's sites and my own have been on our old hosting service and something very bad just happened.  It was one of those "I told you moments" to my brother but still sucks.  One of those, you just got kicked in a very unpleasant area (multiple times).

First, thank god I ported BTE already away from their servers.  But here is the break down

They moved the server.  They changed the name servers servers and IPs.  They moved databases around.  Did I forget to mention they didn't tell us.  They took down the old name servers so nothing was resolving.  Got that fixed and realized half the sites weren't working properly.  Worse was  email on rutkas.com still isn't working properly (I can't IMAP to get my email or view the WWW page now I can finally view the WWW and do IMAP Pop3).

So the code on the site that is failing is 5 years old and I haven't even looked at a line of PHP in almost 3 years.  So to fix the sites, I have to remember PHP and decipher code I did.  Time to bust out the beer and get in to the same state of mind I was in during college.  The code isn't failing, the database is just missing for this site.  This just gets better and better.  There is another site with a database that was missing too!

On the up side, I got one of the sites that had a database ported to my server just now.  This makes me happy.  However, I think I have another 9 more to go, 3 with database migrations.  This makes me sad and wishing I could charge my brother a nice consulting fee or the old web hosting company.

Since these databases are during my "MySQL" period of my life, I have to admit, their tools for migration are fairly decent.  While migrating databases is one of the most frustrating things I've done in some time, I still somehow manage to come up with a list of things that are worse.

I got better stuff to do than this crap, you know, like sleep and finish my own anti-social projects.  I could take a bottle of aspirin to fix the headache I now have after hitting my head against the wall over and over again.

I really should just get my own web server and a database server and be done with this hosting dealie.  But is so much cheaper to just host.

6DOF-v2-2[1] So my goal for this project is to have everything 100% off the shelf so anyone can built this.  There will be zero (yup, zero) custom parts.  Everything can be bought with zero alterations (I hope).

So my first parts ordered are actually the inner ear of the board.  I ordered all three parts from Sparkfun.

1 x IMU 6 Degrees of Freedom - v2 with ADXRS150 (SKU#: SEN-08192) = $324.95
1 x Battery Holder - 4xAA Square Terminated (SKU#: PRT-08159) = $3.95
1 x RS232 Shifter SMD (SKU#: PRT-00449) = $13.95

The Inertia Measurement System (IMU) is what will allow me to know exactly where the hell I am.  I'm not sure if this will actually eliminate the need for force sensors to detect someone turning if this is sensitive enough.  I need the shifter to communicate with a computer and the batteries to power the IMU.  Now that I have these, I can start building out my test applications for detecting movement and even creating the inverse pendulum app maybe out of some LEGO.  Trevor Blackwell has tons of information on the topic of home built segways too.

And my ultimate goal is to have a cell phone power (looking at a spare iPaq hw6925 that I have) this bad boy but no promises, I may have to find a lower powered embeddable computer for this.

Next items that need to be bought are the motors, gearbox and motor controllers.  I have a few options on this front but I think I found my wheels and gearbox.

fourth[1]So my favorite band is releasing their seventh album tomorrow.  What is even funnier is the fallout in their distribution method.  They are letting us (you) the consumer choose the price.  NIN is another band that is doing this and reportedly more are.

And yes, the masochist in me bought the disc box even though I could have gotten the CD for 1 dollar.  Partly I think because one of my favorite songs is on the 2nd CD you can't get.  Bangers and Mash was AWESOME in concert.

I feel sorry for my coworkers since I'll be rocking out all day tomorrow and on my way to Missouri State University and the way back and all weekend.  I'm not sure if it will be possible to wear a CD out by over playing it but I'll try.  Or I'll try to break my MP3 player.

Image from by radiohead too.

I'm fixing the ?p= issue for converting to Das Blog by actually creating a custom version of Das Blog for my own use.  I've hooked into the Application_BeginRequest in the global.asax.cs but there is a small problem, everything is a custom hook.  I've tried to find every hook in my own blog that someone linked into but it won't be 100% ... ever.

That was the problem fixed.  The problem found is how Wordpress did posts using the online system.  It used new line characters and did a conversion to I'm assuming a <br/> tag.  By reading the source code, I found Das Blog has ContentFilter in the site.config.  Now I just need to figure out how to make it display properly with some regex.

dasBlog SimpleSo I've been wanting to do this for a while after the pain I went through to get Wordpress from one server to another.  Functionality was lost (permlinks) and even some of the character encoding got fugly.

I've been a huge fan of Scott Hanselman's blog and noticed it runs Das Blog and did my research.  I would have figured it would have been SQL Server based, but instead all the data is stored in XML files.  That was the only thing I was seriously worried about however, I had a little mental thought about how much traffic Scott's site actually gets and I no longer cared about the XML files being used for the database.  The nice thing also about this is I can just download everything and put it on another server instead fighting to get the server to play nicely.

So how does one convert blog engine's content to another?  There is this sweet open source tool called BlogML on CodePlex to help aid in converting.  To get your data out of Wordpress, you need the Wordpress BlogML export which was decent, but not perfect for exporting data.  I had one small issue with the data but it was easy to fix.  After that, I used Paul van Brenk's BlogML importer to do this.  BlogML is sweet and a life saver when doing this.

To do paging, that took a bit more effort to figure out, I did a search and found how to do paging in Das Blog on Scott's blog again.  Surprise, surprise since he is a developer on the project.

Nothing is perfect but I want to do this by my self without "cheating".  What implies cheating?  Directly asking Scott to me is cheating since he helps out Coding4Fun and now works for Microsoft and as mentioned above, he is a dev on Das Blog.

There are two things that I have to fix no matter what before I do the conversion is fix the date.  It is too long.  The next problem is how to support people that linked into me before.  Wordpress has ?p=SomeNumber while DasBlog does a GUID or permlink.  I could do a few things but not sure.  This Int to GUID thing is a tad puzzling.  I think I'll have to add something in and just do a switch statement with a map on the default.aspx page.  Until this is fixed, I can't do the conversion.

After this, I need to ditch my gallery for something better.

WhatIAmdoingSo when I do stuff, I'm an extremist.  I'm that guy that takes a simple thing and makes it so overly complex it makes "normies".  So instead of using stuff like twitter, facebook, or hell, an excel spreadsheet to keep track of wtf I'm doing at work, I make a program that will do all that and then some.

When I told Martin, my manager / old c# teacher, about wanting to keep track of what I'm doing to verify I'm using my time to the up-most.  He thought I'd a spreadsheet to do this.  He found out about my little "side project" a week ago and I do believe rediscovered my "problem".

So here is my mock up I did using Paint.Net and my tablet PC.  I love my tablet to draw with.  On the plus side, this will be open sourced and I'll pop it on Coding4Fun when it is done ... along with my 8 other projects.

bigAPI[1]

Updated:  Source Code has been updated and workings.

So I have a project I want to write and it requires me to use the Google and Live search APIs.  Last time I dealt with the Google APIs, they had a SOAP version that hooked very nicely into Visual Studio.  However, I found out they no longer do such a thing and it makes me wonder why they would do that.  You can do their AJAX calls, but that won't work in the context I want.

But fear not, after a quick search, I tracked down Yuvi and this genius has a bit of c# code to get the results from the call.  Yuvi transcoded Davnum Srinivas's Java code which properly dealt with the obfuscated Javascript from the Javascript call.

Now I need a JSON to .Net object serializer which already exists on CodePlex.

Plus I have to say, when I saw this image (it was smaller), I thought it was a guy rocking out on a guitar.  How wrong I was.