I am back working on Project Euler again. It has been a great long while, maybe 4 or 5 years, not sure, since I started on it originally, using ruby. Now I am using a mixture, starting for Python for a bit, and possibly switching back to ruby. I say that after solving this last problem (#4) and then going thru some of the other folks solutions, the most elegant usually are the ruby ones, in my humble opinion.
There are of course smaller, or rather more concise, ones but they are too cryptic. Solutions is in statistical languages such as J or K are frightfully illegible. I have to share, just for kicks. First, the problem was to find the largest numeric palindrome that is the product of two 3-digit numbers. Similar to 9009 being the largest that is the product of two 2-digit numbers, 99 and 91. So just for giggles, here are a couple of super concise (and un-readable INHO) solutions:
1. This is in J (http://www.jsoftware.com)
I recently rebuilt my work machine, with a new SSD. But that meant I had to setup Console2 again…
I recently rebuilt my work machine. I have had my Dell Precision M4600 for almost two years now and it has served me well. I started with 8gb of RAM and have upgraded to 16gb. Despite the increase in ram though I had started to notice a slow down in performance, partly due to my frequent use of Visual Studio 2012 and the new Office 365 suite. These newer apps use a lot of memory, a whole lot. VS 2012 can easily use a gb of ram per instance if left open too long. So I decided to ask for a hard drive upgrade and lucky me I received approval. I promptly ordered a 256 gb Sandisk Ultra Plus SSD and eagerly awaited its arrival.
The drive arrived and aside from a slight snafu that cost me a 20 dollar part from ebay (I broke off the HD cover plate when removing the factory HD) the installation was fairly simple. I cloned an M4600 Windows 7 x64 image our IT Manager gave me and was up and running in a couple of hours. I did have to wait until the next morning to re-join the domain, but then I was off and running. And I mean running! The new drive is wicked fast.
I installed VS 2012 in about an hour (instead of the three it took when I first started) as well as Office 365 and a host of smaller utilities. A small note about that, I cannot recommend enough the Chocolatey package manager for windows. It was the first utility I installed and then I used it to install almost everything else, including things like:
- BeyondCompare 3
- SharpKeys (I use this to map keys for my Apple Keyboard)
To get a list of all of the packages you have installed use the command:
cver all -localonlyI was continually amazed at how easy it was. I would be working and realize, for instance, that I needed to add some annotations to a wireframe for some documentation for my latest feature task, but I hadn’t installed paint.net yet. So, I hit Win-Key, then type in Console and hit enter. Then at the command line, I tried:
cinst paint.netAnd it just worked. It would search the packages find it and install it. Bam! Then I could hit Win-Key again and type in paint and select Paint.Net and hit enter and be working. Super cool and super easy. I really can’t say how much time it saved me and also how much space it saved me because I didn’t have to go out and search for installers and download them and forget to delete them when I was done. Thanks to Chocolatey my downloads directory is practically empty.
Console2 SetupA new machine meant I had to do some reconfiguring of my utilities, especially the ones I use the most, like Console2, or just Console now. I have previously published an article that contained my Console2 Setup and it has been quite a popular article, my most popular one on the site in fact. And when I had to figure out how to do it all again I thought a new article would be a good idea. Especially because I have added even more tabs to this setup.
- Windows Cmd Prompt
- Visual Studio Cmd Prompt
- Git Bash
I was able to salvage some of my settings from my old hard drive by locating and copying the settings file from Console2 which for me was located in \AppData\Roaming\Console\console.xml but on my new build I am using a portable install of Console so that my settings file is in the Console2 directory.
Here are the specifics. I am assuming that you know enough about Console to open the settings and add a new tab and get to this screen:
And here is the goodies! A detailed list of the settings for each tab that work for me. I add that caveat because due to the differences in versions of Windows and install locations I cannot swear that my settings will work for you, but you should be able to use my settings to figure out how to make yours work…
Visual Studio Cmd Prompt
- Title: VS Cmd
- Icon: C:\Users\jgilliland\bin\Console2\vscommand.ico (from Scott H.)
- Shell: %comspec% /k ""C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat"" x86
- Startup dir:
Git Bash Shell
- Title: Git Bash
- Icon: C:\Program Files (x86)\Git\etc\git.ico
- Shell: C:\Program Files (x86)\Git\bin\sh.exe --login –i
- Startup dir: %HOMEDRIVE%%HOMEPATH%
- Title: Cygwin
- Icon: C:\users\jgilliland\bin\Cygwin\Cygwin.ico
- Shell: C:\users\jgilliland\bin\Cygwin\Cygwin.bat
- Startup dir:
- Title: Powershell
- Icon: C:\Users\jgilliland\bin\Console2\vspowershell.ico (from Scott H.)
- Shell: %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe
- Startup dir:
So there you have it! My new drive with all of my utilities, mostly portable installs this time, so that next time they can just be moved with me. In fact, here is a screenshot of my username/bin directory where all of my portable installs are:
In conclusion I am super stoked about my new ssd and I cannot recommend using Chocolatey enough for your windows package management needs. And of course you now have all of the details of my Console2 setup. Enjoy!
PRISM + WPF = MVVM
All of my recent projects at work have been WPF applications designed using the Microsoft PRISM framework for composite/modular applications. PRISM provides the ability to modularize our applications into separate UI modules that are decoupled from the main application and they are developed in a separate project and compiled into their own dll. The UI module project has a bootstrapper class (of sorts) that implements the IModule interface, and in doing so, registers its views with a region in the main window. So basically, if the dll is there then the content will show up in the main UI and if it is not, it won’t. This is an over simplification but I am just trying to provide some context for the main issue that I want to post about. Let us look at a simple example, a configuration/settings module. We would have a main region (see the web for more information on Prism Regions) that is likely a tab control with a tab for each major piece of the user interface, i.e. a Reports tab, a Help tab, etc. The settings module would be a separate project and show up in the main window as its own tab. PRISM will only show the settings module/tab if its dll is found in the bin of the application. The settings bootstrapping class tells PRISM that it has views and which region within the main window’s layout to which the view should be linked. Here is some code:
I have seen this information in various places and in various pieces and finally have taken the time and effort to put it together and implement a working solution on my work machine. First a bit of context for the situation and my motivations.
This is just a quick note to extoll the smoothness of the new Code Mapping feature in Visual Studio 2012. I am working on some of the model classes for the Whistle project I mentioned in a previous post and I actually found myself wanting to see a graphical representation of the classes I had been adding. I added several at once no real plan in mind for the final design, just sort of shooting from the hip if you will. Therefore, the short video I had seen after installing the VS 2012 Update 1 package that had afforded me a brief overview of the Code Map feature definitely made it easy to try it out. I was able to produce this interactive code map graphic in no more than seconds, maybe 30 or even 40. That includes rearranging what was produced by default after selecting “Show on Code Map” and dragging over a few files from Solution Explorer. The map is interactive with information about the relationships if relevant, and offers expandable class details info, and more I am sure, I just did some curiosity clicking.