I prefer to work with ASP.NET MVC but currently work with a hybrid code base that includes plenty of Web Forms pages laying around. One of the nice new features ASP.NRT 4.5 brought to the Web Forms world is called Model Binding. This makes binding data to a form very clean and plays nicely with Entity Framework, Code First. It took some reading and experimenting to get up to speed with it so I created a Gist (below) that demonstrates a simple example of using Model Binding to populate a GridView. Note that sorting / paging are built-in automatically and I am passing a TextBox field in for filtering the results.
Way back in 2005 when my wife and I got married we went to pre-marital counseling and learned we had a bit of a problem in our relationship. Not surprisingly, it had to do with money. I was a so called “saver” and she was a so called “spender”. We had different ideas about how spend money and we were counseled to start a budget. The idea of budgeting made my eyes roll, to be honest, because it seemed like such a drag. I figured we should just save as much and spend as little so we didn’t have to worry about keeping track of everything.
We started keeping the budget with Excel. I had a bunch of worksheets with cross references, crazy complex functions and all. It was super cool, complex and she hated it. It didn’t last long because it was too cumbersome and didn’t pass the WAF.
Then we started Using Quicken. It was great because it integrated with our banks and make transaction entry a breeze. With its insane amount of features it seemed that it could handle any budget scenario we threw at it. Things went well for quite awhile but over time we started misusing it. We wanted to start saving up for things and planning ahead rather than looking at historical reports so we created a concept call “buckets” and had a two page documented process. It became a mess.
We realized we were trying to do Envelope Method of budgeting so we looked for a solution that would download our transactions like Quicken but allow us to use the envelope so we found and used a web based program called Mvelopes. It was nice. It was real nice. It did all we wanted it to. However, it was expensive and sluggish (Flash based).
Fast-forward 2 years and I had a working Rails based application and was able to migrate off of Mvelopes and begin to use it. I called it “Bud-E” (get it? Buddy but an E for Envelope? Yeah, it’s lame and I ended up changing the name later.) It was rough around the edges for sure but it worked. It download transactions from our banks, allowed us to enter transactions, manage envelopes and transfer money between them. Over the next year, I worked on making it better and somewhere along the way I decided I could make this thing into a commercial, subscription based application. I saw a market opportunity and thought I might be able to make some money. I also knew this type of app would have a bigger audience with a SAAS model rather than being an open source project.
Fast forward another year and I finished the polishing and released my first commercial project called “Bento Budget”. Bento is a type of Japanese meal that is partitioned into multiple sections on a plate. This term seemed to go along with the envelope, “bucket” idea where you have different partitions for your money. It also helped that the bentobudget.com domain was available :).
Under the hood, it’s a Rails 3 app that relies heavily on Bootstrap, jQuery, jQuery UI. On the server side, I have a C# REST application, utilizing the Nancy framework that does the financial institution integrations. For data, I use MySQL with the InnoDB engine. There is an iOS and Android app, both built using PhoneGap.
This project was a lot of fun and a ton of work. I learned many useful things along the way. I’ve already had a good bit of interest and usage and am excited to see what the future holds for Bento Budget. Go check it out at www.bentobudget.com!
At work, I have use a MacBook Air and run Windows 7 in a VirtualBox VM. I use (and love) the Mac Terminal heavily and have almost an entire monitor dedicated to it. Since we use Git, I wanted to be able to use the Mac Terminal to interact with files on my Windows 7 VM since I do a good deal of development on the Windows box itself. I installed cygwin with the sshd and Git packages, configured it and was able to successfully ssh in to the Windows box from my Mac OSX terminal. (By the way, the reason I went with cygwin is because I was able to install sshd as a Windows Service; msysGit does not provide sshd). After some tinkering with settings and ssh keys, everything was working fairly well. However, over time I began to notice (more and more) Git on cygwin running slow when doing pull, merge, status, etc. on a particularly large repo. It got really frustrating! I tried the same commands in msysGit and things were much snappier, possibly because msysGit was running Git 1.9.4 and the latest version (available) of Git in cygwin was 1.7.x. Anyway, I decided I would try to run msysGit from within cygwin to see if could get the best of both worlds. It wasn’t the easiest thing to get working but I finally did get them playing nicely with each other and am very happy. Here are the steps I took:
- Install cygwin with the latest Git package. (My install path is C:\cygwin64)
- Install the latest version of msysGit. (My install path is C:\Program Files (x86)\Git)
- Rename C:\cygwin64\bin\git.exe to C:\cygwin64\bin\git_cygwin64.exe (to back it up)
- Copy C:\Program Files (x86)\Git\bin\git.exe to C:\cygwin64\bin\
- Copy the folder C:\Program Files (x86)\Git\libexec to C:\cygwin64\
- From within cygwin environment, run git config –global color.ui always
The only issue I’m still having is when doing a git log command, the paging is not working. If I run git log | less the paging works fine so I am just using this syntax for now.
Somehow I forgot the password to one of my Raspberry Pi boxes and needed to reset it. The only way I know how to do this is to mount the root partition from the context of another machine and then edit the /etc/shadow file. Since I own a MacBook Air and it can’t read ext3 natively (not that I know of at least) I thought I would just just spin up a virtual machine in VirtualBox, mount the SD card from the Raspberry Pi, make the change and be done. It wasn’t as easy as I thought because, for some reason, getting VirtualBox to pass the SD card reader to a virtual machine as a virtual device is not quite easy. Below are the steps I had to take to get it working.
First, insert the SD card into the reader, open a terminal window and type mount.
Take note of the SD card device that shows up. In my case, it was /dev/disk1s1 (NO NAME matches the title that showed up in Finder when I inserted the card so this is a hint as to which one is the one I am looking for) listed at the bottom of the mount command. You don’t want to get this wrong so make sure it’s right! For a sanity check you could always run mount before inserting the card and then after, to see the difference.
Next, open up Disk Utility, click on the the mounted partition from the card (NO NAME in my case), and then click the Unmount button at the top. Do not click the eject button, just the Unmount button.
Now, you need to create a VirtualBox vmdk file that points to the SD card so that you can mount it as a device in a virtual machine. You need to run sudo VBoxManage internalcommands createrawvmdk -filename ./sd-card.vmdk -rawdisk /dev/disk1. Note, when I ran the mount command above, my device name was /dev/disk1s1 but in this command I did not include the trailing s1 portion. The reason for this is that the s1 portion of the device name denotes a partition but I want to create a pointer to the entire device (mine has 2 partitions). So, just take the first portion of your device name and use it for the -rawdisk parameter.
Now that you have a vmdk file pointing to your raw SD card device, you need to set permisisons on the vmdk file and /dev/disk1 device. Run sudo chmod 777 /dev/disk1 and sudo chmod 777 ./sd-card.vmdk. This will ensure you are able to access and mount the vmdk file in VirtualBox.
The last step, is to add a SATA device in the virtual machine Storage configuration. Click “Add Hard Drive” on the SATA controller.
You will be given the option to “Choose existing disk”. Choose this option and then select the vmdk file you created earlier.
Now, all you need to do is start your virtual machine with VirtualBox and your SD card should be accessible from your virtual machine. If you get an error about the device being busy when trying to start the machine, open the Disk Utility and ensure all partitions of the SD card are still Unmounted. For some reason I had to do this because OS X remounted my card somewhere along the way.
If you’re lucky like me, SD partitions will automatically be mounted. In my case, I was running Linux Mint and both partitions of my SD card were mounted automatically!
Last week I gave a tech talk on Entity Framework. One of the questions that was asked at the end of the talk was how to handle “complex types”. That is, how to get Entity Framework to map data into a container “child object” correctly. A couple of reasons you might want to do this are: to organize your model classes in a cleaner way and also to isolate data for serialization. For example, if you have a database table called Person that includes address related fields, you might want to create an Address class and have EF map just the address fields in this type. This gives you flexibility so that, for example, you could serialize the address info to JSON without having to ‘ignore’ a bunch of other fields you don’t want serialized.
I had to dig around a bit to figure out how to get it to work but it is definitely possible. You just need to:
- Define the complex type class
- Decorate the type with [ComplexType]
- Add a member of this type to the container type (i.e. add Address property to Person class)
- Make sure the type is always instantiated (either at declaration or in constructor). This seems a bit odd but if you don’t do this EF will throw an exception at runtime.
The article Associations in EF Code First CTP5: Part 1 – Complex Types was definitely helpful with understanding this.
Here is a gist demonstrating what it looks like.
Sorry, no posts matched your criteria.