January 2008 Entries

I'm going to phase out Gallery, my old photo system.  It sucks, Flickr is so much better and easier to get stuff up on.  I've been meaning to do this for a bit, just work has been making me go to such horrible places like ASU and be subjected to countless beautiful women.  But having to spend what is basically an entire day on an airplane (leave at 8am there to the airport, get home at 6pm), you don't have too much access to the Internet.

So if you're keeping notes, this is the last PHP app that is running on Better Than Everyone.  Why am I doing this?  I've gotten hosting with the wonder company called Applied Innovations and will be migrating all my sites over there.  I'll have my own Virtual Private Server (FINALLY) and will be rocking out how to do this.  I just need to put everything over there and test it out.  Current way of doing stuff annoys me too much when I have people say "Clint, you're site is down" or "Clint, why can't I FTP in?".  I do have to figure out how to set up SFTP and a mail server now however.  Wonder if they already have one I can tap into.

The first site I'll officially port will be Peace Love Code since there are far fewer moving parts.

And best of all I'll finally have access to .Net 3.5 stuff so I can play with LINQ without my server yelling at me.  Currently I'm stuck at .Net 2.0 for my web host.

So in addition to my own stuff, I have my brother's stuff too that I have to figure out how to migrate.  That is all PHP and MySQL.  Could be a fun weekend project (or not).  I may do a "how to convert your PHP to .Net" series too for just this.

And yes, I know I could just have a PHP and MySQL instance for this up on the VPS, but I think that is a last resort.  There has to be a MySQL to SQL Server migration tool out there and converting the site shouldn't be "that" hard.  It may however just be a total slash and burn with the exception of the database and build from the ground up.  New UI, without a doubt new code base since the current version is more of a ASP style instead of an OO style.

Now, why else would I have a VPS?  I can test out other stuff like Ruby on Rails, Apache, .... without messing up my current site or server instance. 

Virtualization, It is god's gift to the nerds.

image My little airplane coding project is officially complete.  I think I got almost any edge case covered too that someone may run into. 

I can't post the source currently since I'm 30,000 feet in the air, however I'm going to aim by this weekend to get this new and improved version up and going.

Cool Stuff in v2:

  • It is all XML based, if you update your XML file, there is a file cache dependency that destroy the cache and use the new XML file.  In addition, the cache will time out after 1 hour.  Almost everything in it can be altered, a few things I did in the code behind, however I know they can be extracted out. 
  • The source will also do some neat stuff like verify the file is on the server.  I got this idea from Joe Healy's web site.
  • Everything renders the same in FireFox and in Internet Explorer too.  Before this wasn't case.  For traffic that goes to my site at a minimum, I do have about a 25% FireFox user base so I need to be sure they are supported.
  • Zero hacks for IE or Firefox to do this too.
  • I no longer use the Yahoo CSS file.  Andy Konkol has a sweet way of doing div based layouts that work pretty nice by calculating a fixed width then translating it to percentages.
  • Everything should be with XHTML strict and CSS 2.0 valid (haven't tested due to the being in an airplane issue)

Things I still need to do on it and nice to haves:

  • Create PLC's XML file
  • Do Coding4Fun write up
  • Figure out how to do DateTimes in XML.
  • Figure out to do paging.  If you have 100 projects, right now it will show all 100.  I was thinking about LINQ but right now my web server doesn't have 3.5 extensions.
  • Add in the LightBox JavaScript library for showing pictures.
  • Maybe add in some scriptaculous animation effects.

And lets view some source code from the global.asax.cs file to check out how I actually did the caching.

public class Global : HttpApplication
{
    private static readonly string fileName = "portfolio.xml";
    protected void Application_Start(object sender, EventArgs e)
    {
        SetInCachePortfolio(Context.Cache, Context.Server);
    }

    public static Portfolio GetPortfolio(Cache cache, HttpServerUtility server)
    {
        return (cache[fileName] == null) ? SetInCachePortfolio(cache, server) : (Portfolio)cache[fileName];
    }

    private static Portfolio SetInCachePortfolio(Cache cache, HttpServerUtility server)
    {
        Portfolio portfolio = Portfolio.Load(server.MapPath(fileName));
        cache.Insert(fileName, portfolio, new CacheDependency(server.MapPath(fileName)), DateTime.Now.AddHours(1), Cache.NoSlidingExpiration);

        return portfolio;
    }
}

image

Google broke my hack to get their search results on my Live VS Google search application.  I haven't really looked too much into this except I'm irked it is broke.  I know it was a hack to get it to work so it may just be a small problem like the JSON formatting got tweaked. 

Seriously, give us back a SOAP API.

0604spellingbee[1]I'm a very special child when it comes to the English language.

 Andy pointed out something everyone already knows, I suck at spelling.  Varient should be spelled Variant.  Good thing Visual Studio has find and replace for the Code Portfolio program.  Good thing all you need to do is rename the file and Visual Studio fixes all your references and renames the class automatically.

imageToday I found a few minutes to work on it.  I have the XML serializing now and layout pretty much done.

While I've done this trick countless times, I always seem to forget it with CSS and floating images.  So on my blog, I have images I float to the right in blog posts.  By having an overflow: auto on the wrapper div that the image is busting out of, it automatically resizes it to the proper height.

Here is one of the CS files along with the updated XML.  I'm not sure if I like the Portfolio File Varient structure though.

using System;
using System.IO;
using System.Xml.Serialization;

namespace CodePortfolio
{
    [Serializable]
    public class PortfolioFileVarient
    {
        [XmlAttribute("language")]
        public string Language { get; set; }

        [XmlAttribute("fileName")]
        public string FileName { get; set; }

        [XmlAttribute("imageUrl")]
        public string ImageUrl { get; set; }

        internal void prepFilesPaths(string RootPath, string RelativeFilePath, string ParentPath, string SubPath)
        {
            string tempPath = string.Empty;

            if (!string.IsNullOrEmpty(SubPath))
                tempPath = SubPath;

            if (!string.IsNullOrEmpty(ParentPath))
                tempPath = Path.Combine(ParentPath, tempPath);

            if (!string.IsNullOrEmpty(RelativeFilePath))
                tempPath = Path.Combine(RelativeFilePath, tempPath);

            if (!string.IsNullOrEmpty(RootPath))
            {
                _serverFilePath = Path.Combine(RootPath, Path.Combine(tempPath, FileName));
                _fileExists = File.Exists(_serverFilePath);
            }

            if (!string.IsNullOrEmpty(ImageUrl))
                ImageUrl = Path.Combine(tempPath, ImageUrl);

            _url = Path.Combine(tempPath, FileName);
        }

        public bool FileExists { get { return _fileExists; } }
        private bool _fileExists;

        public string URL { get { return _url; } }
        private string _url;

        public string ServerFilePath { get { return _serverFilePath; } }
        private string _serverFilePath;
    }
}

And the XML file I'm using for the data source.

<?xml version="1.0" encoding="utf-8" ?>
<portfolio rootFilePath="code" useServerMapPath="true">
    <items>
        <item relativeSubFilePath="test1">
            <title>test 1</title>
            <description>ipod</description>
            <imageUrl>test.jpg</imageUrl>
            <files>
                <file major="1" minor="2" build="3" revision="4" relativeFinalSubFilePath="version1">
                    <varients>
                        <varient language="vb" fileName="vbFile1.zip" />
                        <varient language="c#" fileName="cSharpFile1.zip" />
                    </varients>
                </file>
            </files>
        </item>
        <item>
            <title>Test 2</title>
            <description>ipod</description>
            <imageUrl>test.jpg</imageUrl>
            <files>
                <file major="2" minor="3" build="4" revision="5" imageUrl="test.jpg">
                    <varients>
                        <varient language="vb" fileName="vbFile2.zip" />
                        <varient language="c#" fileName="cSharpFile2.zip" />
                    </varients>
                </file>
                <file major="1" minor="2" build="3" revision="4">
                    <varients>
                        <varient language="vb" fileName="vbFile3.zip" />
                        <varient language="c#" fileName="cSharpFile3.zip" />
                    </varients>
                </file>
            </files>
        </item>
    </items>
</portfolio>

I was at a coffee shop and did some doodles while I was attempting to figure out a different code problem.  I did some measuring later on.  Figured I'd post them.

IMG_4119

All I did was highlight the selected rows I wanted and I got a sum AND average.  Normally I'd do a summation (total amount) in a different column.  This just reduced the amount of work I've had to do for my monthly reports!

image

After much Zen meditating (or as normal people say, drinking beer), I've decided aluminum framing is the way to go.  Cheap(ish), zero welding, 1 bar should be enough to do the entire structure and then some, connectors are there, connectors are there to reinforce too.  Mounting brackets for everything.

Basically, it is perfect.  Now I get to buy a drill press and band saw for my apartment too.  Power tools, every man's weakness.

So I'm attempting to figure out how to build the frame for the Skateboard segway and I think I made some serious headway.

My dad (Bob Rutkas, even though he is an evil mac user), has informed me about Bosch aluminum framing and it is AWESOME.  All I need is a band saw and I'm set.

80x80

On the flip side, I could go carbon fiber too.  Robot Market Place has some cool stuff that may be usable.  I'm not sure if I'm able to drill into it and construct it with lets say wing nuts.  That is the part that worries me.  But it looks SO damn cool!

store_wcc_angle[1]

Plus the aluminum framing is competitively priced.

When you create a new Silverlight project, it creates a Page.html.js file that appends on a function to the window.onload to gain focus.

NO, bad silverlight, you go in the corner, you get focus when I give you focus.  Jeff Atwood agrees too.

gearbox

They need to be modified slightly by shaving off a bit.  It is 3/8" 6061-T6 aluminum alloy.  Time to get my dad on the phone to tell me what I need to buy!

I also have the speed controller too.

image I posted the source over at Peace Love Code.  Here is a direct link.

Even though it is the previous post, here is a link to the Silverlight video puzzle in action.

So I just finished up my Silverlight 1.1 2.0 project. The slider control, I borrowed from the Silverlight SDK. I'll package everything up once I get it to run without physically redistributing the SDK.

I posted the source over at Peace Love Code or direct link.

Use the Silverlight 2.0 Beta version, direct link for source.

Run-times: Mac or Windows

As 1 piece 

image

As 20 pieces

image

It is now 5am, I think it is time for me to go to sleep.  However, I think Silverlight should take the taxi home since I tend to sprawl out on my bed.  I've had my way with it and while I had to learn some weird new positions, it was fun.  Not as easy as I'd like, but fun.

And yes, that is an HD video I used just because I could.  And it is the Fantastic Four movie.

Things left to do:

  1. Add in text boxes to dynamically cut up the movie instead of doing it at variables compile time.
  2. Get video to repeat after it is done playing
  3. Create a video that is low in size since I don't want to add in buffering
  4. Post my amazingness with source
  5. Write a Coding4Fun article on it.

silverlight_detail[1] I've been dabbling with Silverlight for a bit after I attended a workshop on it a month ago.

Since it has been well proven with past projects I'm a masochist, I decided my first application with Silverlight would be something easy like a recreating the Microsoft Surface Video Puzzle.

So far, I've learned a rather large sum about Silverlight.  I'm using Silverlight 1.1 September Refresh.

  1. Dynamically adding items to play videos is harder than one may think.  After many hardships, I finally got it to work BUT
  2. I found out that the Silverlight event life cycle acts differently than the ASP.Net
  3. Which made me have to hand code all the objects in code behind to have it load properly.
  4. I now feel the pain of programmers from 20 years ago when they had to do this for user interfaces. 
  5. I can't apply the same Brush to multiple objects.  What I mean is I can't say this without having an exception thrown.
  6. SolidColorBrush blackBrush = new SolidColorBrush(Color.FromRgb(0, 0, 0));
    rotateOverlay.Stroke = 
       translateOverlay.Stroke = blackBrush;
  7. I was told everything should be after InitializeComponent(); BUT this does not appear to be the case when dynamically loading objects, putting items in the constructor is the way to go.

So things that must be said here are that the 1.1 (now 2.0) is still alpha.  This has been said many times before and I can only assume these problems will be fixed.

I will say this is pretty neat however.  Can't wait to show it off.

cubs-failure[1] Being a life long cubs fan, I've learned a few things about failure.  And tonight, I failed to have the relay boards pour more than 2 shots in a row.  Prototyping the bartender is seriously getting annoying.

I'm not sure if I fried the relay boards I've been using for the past few months.  It is possible.  The timing seems off now too which makes me a bit more likely to believe this..  I need to see how much work it will take to mod one of the boards into a master board.  I may need to do a trip to the uber geeky electronic store tomorrow instead of just Radioshack.

I did find out that 8 PSI when shooting liquid out can cause a mess too.  5 PSI is far nicer  Also the 12V valves suck.  They leak air which makes them pointless and me angry.  Plus they were a pain to mount.

However, I think a sledgehammer may be both more fun and relaxing.

IMG_4049 Synergy is eff'in the best program ever if you have multiple computers in one area like me! 

So to the right is a picture of my desk in St. Louis.  In it you can see a ton of computing power (3 laptops, 1 desktop and a Windows Home Server) but only one keyboard and mouse.  I love my Microsoft Natural Keyboard Pro and Logitech MX wireless mouse and would plug them into my work laptop when I needed to work remotely.  I would randomly run into the problem of someone would IM me or I'd have to gain access to my desktop which would cause great pain to unplug ....  This couldn't continue for much longer.

I remembered way back, my old coworker, Ian Hall, was running Synergy at work and was showing it off.

To get it up and working was fairly painless, however one thing that took me a bit to figure out what I had to tell the software about both sides of the barrier.  I also had to expressly say "clintDesktop" and "crutkas-t60p" to get them to talk to one another.  The rest is straight forward. 

image

One computer is a server, rest are the clients.  No delay in mouse movements or typing too.  Plus it brings over the clipboard from one computer to another.  The image above was copied from my desktop but I'm writing this on my laptop.  Sweet.