Archive for February, 2012

How fast should software be written?

February 29th, 2012

In most software development positions, you get projects sent your way with an expected completion time, and for the most part there always has to be a completion date to any project or nothing would ever get done.  Now, granted you have some projects where some R&D will have to be done beforehand if you either don’t know the technology that will need to be used or you don’t understand the domain you have been tasked to work with.

 It helps tremendously to work with domain experts when you don’t understand the domain you are working with, people that understand how the business works or the terminology or the business flow.  When it comes to R&D up front, it helps to work with or for people that understand that it takes time to get a grasp of the tools needed to get the job done.

One sort of thing I have wrestled with over the years is how fast should a particular piece of software be written?  What I mean by that is how fast should you let others know it is completed.  Under certain situations, you could end up with high expectations that you can produce software very quickly, which you may be able to, but maybe not in every scenario because of the R&D aspect or you may run into a really difficult snag that makes things drag out for a while.  Its probably a bad idea to let others know you are done immediately without at least letting some others bang around on your new shiny tool or product, so you at least don’t look like a fool, not to mention that in general it just needs to be tested.

If you look at the chart I have here, the software development cycle doesn’t always apply, especially when you are creating what I want to call “small” projects, like a data integration for instance.  I recently created a webservice that was simply a way for a client to send data to us and it would generate some more data and send it back.  I guess you could say that there was some analysis involved in trying to see if it was possible, and there was some approval there so we have 2 of the steps, but I didn’t really have a need to mock anything up since it was just some simple ties to data, no UI’s involved.  I did do the rest of it with the stage and test and release the software, so I guess I pretty much did all the cycle minus the mockup part of it.

I guess what I am wondering from others in the field is if you can get a particular project done in a lot faster time frame than was expected, do you sit on it and do more research or do you tell management about it immediately so you can reap those rewards?

Start your blog today!!!

February 22nd, 2012

Have you been thinking about starting your own blog but just don’t know where to start?  Its really easy actually, just take a topic that you are passionate about, for me it is software development, and just start writing!!  I try to write 1-2 articles a week myself, just to keep articles on my site and keep the content fresh as well.  Here are the steps you need to get going with a blog in an hour or less (really).

1) Purchase a domain.
You don’t HAVE to purchase a domain, but if you don’t you will probably regret it down the road and if you want to use the blog to make revenue or for professional reasons its the way to go.  You can purchase domains from godaddy.com for $8 a year, so really cheap.

2) Get some webhosting.
You are going to need a place to “host” or house your blog, I recommend DreamHost.com, they have very affordable  plans and you can be up and running with your own WordPress blog in minutes.

That is pretty much it, the rest is up to you as to what you want your blog to look like and the content you will have on there.  I think a blog serves many purposes, the biggest benefits for myself is that I can learn more by having to do research into the articles that I write and I think it adds more respect in others eyes in the community that I work in.

I can’t say you will make a pile of money off your blog, I haven’t made a dime off this venture and I don’t plan on it either, but if I became an well-sought expert in my field as a result of this blog, it can always lead to other opportunities like contract work, better paying jobs, or maybe even a novel someday, you just never know.  So if you have thought about starting a blog, don’t wait any longer, I await the chance to learn more from you!!

Save WPF/Xaml controls to Bitmaps

February 17th, 2012

I don’t know if you have ever had the need to save an image of a Xaml/Wpf control but I did recently in a project. The method I have below will do just this:

public List<Bitmap> ExportToPng(List<object> objects) {
            var images = new List<Bitmap>();
            // iterate wpf objects, saving current canvas transform
            foreach (object o in objects) {
                Transform transform = c.LayoutTransform;

                // reset current transform (in case it is scaled or rotated)
                c.LayoutTransform = null;

                // Create a render bitmap and push the surface to it
                var renderBitmap =
                new RenderTargetBitmap(
                (int)c.ActualWidth,
                (int)c.ActualHeight,
                96d,
                96d,
                PixelFormats.Pbgra32);

                renderBitmap.Render(c);
                System.Drawing.Image ImageWork;
                // Create a memory stream for using image
                using (var stm = new MemoryStream()) {
                    // Use png encoder for our data
                    var encoder = new PngBitmapEncoder();

                    // push the rendered bitmap to it
                    encoder.Frames.Add(BitmapFrame.Create(renderBitmap));

                    // save the data to the stream
                    encoder.Save(stm);
                    ImageWork = System.Drawing.Image.FromStream(stm);
                    images.Add(ImageWork as Bitmap);
                }
                // Restore previously saved layout
                c.LayoutTransform = transform;
            }
            return images;
        }

The method does take an array of objects, of course you could modify it to only do one at a time but I had several I needed in my example. The key thing here is that in your xaml code, make sure you have your control in just a single stackpanel, or a stackpanel per control. I found that when I had several controls in a single stackpanel, it was only grabbing the first one, the rest of the controls were not getting generated. This would be a really nice feature that Microsoft could provide to all their controls because I know I am not the only person that has wanted this functionality but had to write this hack in get it accomplished.

How to bind an enumeration (enum) to a WPF/Xaml ComboBox

February 16th, 2012

You may already know this, but if you don’t I hope it is of some help to somebody out there looking to do this in their code. If you have an enum or enumeration and you simply want to have it as a choice in your UI and also want to bind it to a property on your View Model, I have attached the code to do this below, check it out.

public enum Enum {
        none, 
        Choice1, 
        Choice2
    }

<UserControl.Resources>
        <ObjectDataProvider MethodName="GetValues" ObjectType="{x:Type sys:Enum}" x:Key="odp">
            <ObjectDataProvider.MethodParameters>
                <x:Type TypeName="vm:Enum" />
            </ObjectDataProvider.MethodParameters>
        </ObjectDataProvider>
    </UserControl.Resources>

<ComboBox ItemsSource="{Binding Source={StaticResource odp}}" IsSynchronizedWithCurrentItem="true" SelectedItem="{Binding PropertyToBindTo, Mode=TwoWay}" Width="100"/>

I am using a UserControl in my example but a standard Xaml window would work as well. Notice also that the key is named as so (x:Key=”odp”) you use that down in your combobox as a static resource since we are placing this in the resources of the user control. If you make a property with the enum as its type you can bind right to the SelectedItem just make sure that you set it to Mode=TwoWay or it may not work. The (ObjectType=”{x:Type sys:Enum}”) simply tells wpf that you are presenting it with an enum type that uses the ‘sys’ namespace. In This line ‘‘ the ‘vm’ is simply the namespace that your Enum sits. I hope this can help somebody out there wanting to implement this type of thing.

My free software method to getting videos on the web.

February 13th, 2012

I run a local blog for our sports team here in Mayfield called mayfieldcardinals.net and the biggest draw for the fans to the site is the videos that I have on there.  I thought I would share the list of the programs that I use to get the videos from DVD to the site itself.

AviDemux – I typically just use this tool to grab a JPEG off the video for use as a splash screen for my videos, but it does have a lot of other useful tools in it.

JoinVobFiles.exe – I use this file to take the VOB files off the the dvd and join them into one to allow handbrake to run through it.

Handbrake – grabs video from a variety of sources, including a DVD, and a DVD image, and grabs audio from sources as well, including MPEG audio tracks. You’ll then be able to output a digital file in a variety of formats, including AAC, MKV, MP4, and MPEG-4.  I use this tool to get the video ready and compressed for uploading to the site.

QTIndexSwapper – When you send your videos up to the web to be played through the flash player of your choice, it won’t stream by default.  This is usually due to the encoding being in the wrong place in the video, this tool will place the encoding and other related information at the front end of the video so it will work correctly on your site.  I always run my final videos coming out of handbrake through this just to be sure.

This is a pretty extensive list of things and I would like to find something in the future that could do all of this but at the moment this is the best I can come up with without become an expert in video editing.  I hope it can help you.

Modify your Kindle Fire Launcher Screen

February 10th, 2012

I don’t know about you, but I was never really a big fan of the default carousel on the Kindle Fire, but thankfully it is an android device and android devices are well known for their customization.  If you don’t have it, I recommend Go Launcher EX, but you won’t be able to install the apps until  you root your kindle and get that done first, I have outlined in my previous post HERE.  Here are a couple of screenshots to show you what is possible with Go Launcher:

With the latest version I have noticed that it does put a drain on your battery, a pretty large drain compared to when its not running.  I recommend getting Badass Battery Monitor and you will see where the drain is coming from.  I found that if I turned off my wifi when I wasn’t using it, it will last a long time.  I hope the developers can address this issue in an update, but Go Launcher is pretty sweet.

How to root your Kindle Fire for 6.2.2 Users

February 6th, 2012

I know there are other Kindle Fire Rooting tutorials out there, but I wanted to put one out for others that may follow some and run into a snag here or there.

Disclaimer: I will not be held responsible if your device gets bricked or damaged during the process.

I have only provided the Windows instructions, sorry Mac users, :(.

If you have previously rooted your Kindle Fire, you can skip the first two steps.

1. Install the Android SDK
The first step has nothing directly to do with your Kindle Fire. You will want to install the Android SDK. The download links can be found here.  You will probably need to install the Java SDK before that, but it will let you know if you need to or not.

2. Preliminary requirements
Once you have the SDK installed,  go to “All Programs” and then “Android SDK Tools” and open the Android SDK Manager.  Then you want to navigate down to the Extras section and check the “Google USB Driver package” and install that package, that will create the .android folder in your users folder, when that is finished, navigate to the [your user name]/.android folder.

Edit the adb_usb.ini file, adding the following line of code at the end:

0×1949 <—TYPE THIS IN, DO NOT COPY FROM THIS SITE

If you copy this from this site it won’t recognize this as the Kindle vendor and won’t recognize it later.

Close and save that file.

Now find the folder where the SDK was installed, and open the google-usb_driver folder. In that folder, find the file android_winusb.inf and add the following code to both the [Google.NTx86] and [Google.NTamd64] sections:

;Kindle Fire

%SingleAdbInterface% = USB_Install, USB\VID_1949&PID_0006

%CompositeAdbInterface% = USB_Install, USB\VID_1949&PID_0006&MI_01

Now you can close and save this file as well.

Make sure you have enabled 3rd party apps on the Kindle Fire: on your Fire, tap the settings icon in the status bar. Then choose ‘More’ option, then ‘Device,’ and finally check the box that enables unknown sources.

Next connect your Kindle Fire to your PC’s USB port. Navigate to Device Manager (Windows) and under “Other Devices” find your Kindle Fire. Choose the android_winusb.inf file.

3. Root
First you will want to download the following two files onto a PC:

Burrito Root

SuperUser

SU

On your PC, move those three files to your adb directory. In your Android SDK folder, that will be platform-tools (if you have an old version of adb it will be tools).

Connect your Kindle Fire to your PC via USB. Open a command prompt in the adb folder. Type the following commands (one by one):

adb push BurritoRoot2.bin /data/local/
adb shell chmod 777 /data/local/BurritoRoot2.bin
adb shell /data/local/BurritoRoot2.bin
adb root
adb shell id
(if result is 0 continue, if not start over)
adb remount
adb push su /system/xbin/su
adb shell chown 0.0 /system/xbin/su
adb shell chmod 06755 /system/xbin/su
adb remount
adb install Superuser.apk (skip this step if its already installed)

After finishing, your Fire will reboot and it will be rooted.

If you got device not found errors when entering the above commands, refer back to steps one and two and make sure adb and the Kindle Fire drivers are set.

GrapeCity ActiveReports (Formerly DataDynamics ActiveReports) DataBinding

February 1st, 2012

I have been a long time user of Active Reports for Visual Basic 6 and then in the .net world, I think I have used every version of ActiveReports since they released the first version.  I wanted to write about a little known fact that you may or may not know about this tool that could save you from writing tons of logic to get the data displayed you want.  Lets say you have a couple of simple classes like below:

public class Person{
     public string Name {get;set;}
     public Job Job {get; set;}
}

public class Job {
     public string Status {get; set;}
}

You may already know that just by simply making any field on your report with the DataField of “Name” will automatically bind that property to that field as long as your datasource is set to a collection of Person objects. But did you know that the DataField can work like so:

So as you can see, if your Person object has a Job object in it and there is a string property on there called status, it will display it as long as the property is public. Another caveat to this is if you have a null object in that string, you may not get an error tossed up to your UI, which could make for some fun debugging. Even still, this is a very nice feature that I have long forgotten but recently came across and it was one of those forehead slapping times.

ReSharper – Best tool I have used to date.

February 1st, 2012

I don’t usually plug products, but I had to let you know about this very excellent plugin for Visual Studio.  I have heard about this tool for years and I really thought it was another collection of controls that I don’t care about, but it is not.  ReSharper is a refactoring buff’s greatest tool, it can do some really amazing things with your code.

  • On-the-fly code quality analysis in C#, VB.NET, XAML, ASP.NET, ASP.NET MVC, JavaScript, CSS, and XML. ReSharper will tell you right away if your solution contains errors or code that can be improved.
  • Instant fixes to eliminate errors and code smells. Not only does ReSharper tell you where there’s a problem in your code but it provides quick-fixes to solve them automatically.
  • Multiple code editing helpers including extended IntelliSense, hundreds of instant code transformations, auto-importing namespaces, rearranging code and displaying documentation.
  • Navigation features to instantly traverse your entire solution. You can jump to any file, type, or member in your code base in no time, or navigate from a specific symbol to its usages, base and derived symbols, or implementations.
  • Code formatting and cleanup to get rid of unused code and ensure compliance to coding standards.

I highly recommend this tool for anybody doing .net development, it can actually make you a better developer!!  It is expecially good with the formatting of LINQ code and removing a lot of unnecessary code.  It also has support for JavaScript, CSS, and Razor,  just too much stuff to not be something of great value for any developer.

Here is the link to the site, try the 30 day free trial, I promise you won’t be disappointed: http://www.jetbrains.com/resharper/