tag:blogger.com,1999:blog-38057586946731859292024-03-13T14:59:40.448-07:00Random ThoughtsA journal of geekery and icecream.Lizhttp://www.blogger.com/profile/15074924782006831812noreply@blogger.comBlogger11125tag:blogger.com,1999:blog-3805758694673185929.post-51038437066466889222010-08-17T10:09:00.003-07:002010-08-17T10:29:48.044-07:00Adventures with QEmuSetting up QEmu with a Windows XP host and a Ubuntu Server guest is the topic for another blog post.<br /><br />This is the story of what happened when I tried to move it to another directory.<br /><br />1. Decide that having QEmuManager sitting in your root My Documents folder is ugly and move it to a folder called Applications so it can snuggle up with PuttyPortable and ChromePortable.<br />2. Move the folder.<br />3. Start up QemuManager. Receive error stating it is unable to write to the original location.<br />4. Try to close QemuManager. Receive write error again. Eventually kill process using Task Manager.<br />5. Sigh; move folder back.<br />6. Start up QemuManager. Receive error stating it is unable to write to the new location (where it is no longer located).<br />7. Make "..." face. Repeat steps 4 and 5.<br />8. Spend a long time poking through the folder and menu options trying to find any path location.<br />9. Make a backup of your images folder. <br />10. Delete the application folder. <br />11. Unzip the original zip file to your preferred location.<br />12. Add a 'new' VM, only instead of creating a new disk image use your existing one.<br />13. It works. Cheer.<br />...<br />14. Discover networking no longer works on the Linux server.<br />15. Reboot a few times and fiddle with network settings. Discover that <br />16. Google "error while getting interface flags: no such device".<br />17. Find <a href="http://ubuntuforums.org/showthread.php?t=255018">a post on Ubuntu forum describing similar issue</a>. Descend into config file hell.<br />18. Follow instructions. <br />19. Everything works! *knocks on wood*<br /><br />In summary:<br /><br />To fix the "unable to write to [location]" error when you've moved Qemu Manager to a new location:<br />1. Make a copy of your VM image. In my case, it was the .qcow2 file in /Images. Make a note of what VM options you've chosen.<br />2. Delete the Qemu folder entirely.<br />3. Unzip qman70.zip to your new location.<br />4. Copy the image to the new /Images folder<br />5. Add a new VM in QemuManager, choosing the image file you saved.<br /><br />To fix the networking problem (caused by the MAC address changing), <a href="http://ubuntuforums.org/showthread.php?t=255018">as discovered by modifiedmind</a>. <br />1. Locate /etc/udev/rules.d/70-persistent-net.rules. Make a backup, write down the module name (in brackets on the #PCI Device line)<br />2. Delete the #PCI Device line<br />3. sudo /etc/init.d/udev restart<br />4. sudo modprobe -r module<br />sudo modprobe module<br /><br />Everything seems to work now.Lizhttp://www.blogger.com/profile/15074924782006831812noreply@blogger.com0tag:blogger.com,1999:blog-3805758694673185929.post-40332740156027906862010-04-26T16:00:00.002-07:002010-04-26T16:13:00.684-07:00Field Prefix in custom Model BinderI'm doing some model validation and adding errors to the ModelState at <code>OnModelUpdated</code> in a custom model binder overriding <code>DefaultModelBinder</code>.<br /><br />However, since the model can be updated either as one of many children in another Model, or on its own, I needed to get the field "prefix" out so that it would highlight the invalid field correctly in the view.<br /><br />After a lot of unsuccessful searching, it hit upon me to look up the source code for <code>TryUpdateModel</code> to see what it does with the <code>prefix</code> parameter. <br /><br />Turns out that the <code>ModelName</code> property on <code>ModelBindingContext</code> is the field prefix.<br /><br />So, I was able to add my model error successfully for both usage cases like this: <br /><code>string fieldPrefix = (!String.IsNullOrEmpty(bindingContext.ModelName)) ? bindingContext.ModelName + "." : String.Empty; controllerContext.Controller.ViewData.ModelState.AddModelError(fieldPrefix + "PropertyName", "Error Description");</code><br /><br />Works for me.<br /><br />PS: I wanted to use the new DataAnnotation validators for this validation, but since it involves comparing two (or more) fields on the model I was unable to get it working with the correct ModelState error keys. If anyone knows a better way, please let me (and <a href="http://stackoverflow.com/questions/2613293/asp-net-mvc-class-level-custom-data-annotation-and-modelstate-keys">this person on StackOverflow with a similar problem</a>) know!Lizhttp://www.blogger.com/profile/15074924782006831812noreply@blogger.com0tag:blogger.com,1999:blog-3805758694673185929.post-52082008433376600392010-04-23T14:11:00.004-07:002010-04-23T14:31:45.247-07:00Making Visual Studio copy .config filesI'd created a few XML configuration files and given them the extension .config, since it was a descriptive name with the added bonus of IIS refusing to serve them.<br /><br />However, using the Publish function in Visual Studio 2010 (right click -> "Publish...") to copy to the local file system, my custom .config files were never in my output directory. However, the .config files I'd created using the web.config file template were there.<br /><br />I'd tried setting their "copy to output" setting to "always copy" and "copy if newer", all to no avail.<br /><br />Eventually, it occurred to me to compare the properties of the ones that <em>did</em> work to the ones that didn't.<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_a9H4S5Qbt00/S9IQli1iWbI/AAAAAAAAA2w/scuP-RSkW-4/s1600/build_action.png"><img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 196px; height: 320px;" src="http://1.bp.blogspot.com/_a9H4S5Qbt00/S9IQli1iWbI/AAAAAAAAA2w/scuP-RSkW-4/s320/build_action.png" border="0" alt="Screenshot of properties dialogue, 'Build Action' highlighted" id="BLOGGER_PHOTO_ID_5463447535146391986" /></a>So, the solution:<br /><br />Bring up the Properties window for the file (right click -> Properties or alt+enter) and set the Build Action to "Content".<br /><br />Now my files are copied successfully.<br /><br style="clear: left">Lizhttp://www.blogger.com/profile/15074924782006831812noreply@blogger.com0tag:blogger.com,1999:blog-3805758694673185929.post-51499794955446975392010-04-14T12:17:00.004-07:002010-04-23T14:34:30.819-07:00A pet peeve: Switch vs. If/Else IfOne of my pet peeves is seeing an if/else tree where there could be a switch statement. I get even more annoyed when I see it in official sample code from Microsoft.<br /><br />From the MSDN description of <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.maildefinition.aspx"> System.Web.UI.WebControls.MailDefinition</a><br /><code style="white-space: pre">if (sourcePriority.SelectedValue == "Normal")<br />{<br /> md.Priority = MailPriority.Normal;<br />}<br />else if (sourcePriority.SelectedValue == "High")<br />{<br /> md.Priority = MailPriority.High;<br />}<br />else if (sourcePriority.SelectedValue == "Low")<br />{<br /> md.Priority = MailPriority.Low;<br />}</code><br /><br />I admit that my reasoning is largely aesthetic - switch statements just <em>look</em> neater, and I find them easier to read. Switch is generally held to be the more efficient of the two, but I will accept that for a 3-option split the performance gain is likely to be negligible.<br /><br />Also, in this particular case, you could even use <a href="http://msdn.microsoft.com/en-us/library/system.enum.parse.aspx">Enum.Parse()</a>.Lizhttp://www.blogger.com/profile/15074924782006831812noreply@blogger.com0tag:blogger.com,1999:blog-3805758694673185929.post-1699842915285009192010-04-13T10:44:00.002-07:002010-04-13T10:57:06.272-07:00It's been a while!Some Visual Studio regular expressions I've found useful recently:<br /><br />To replace your lazy Response.Write statements with something a little more correct:<br />Find: <code>Response\.Write\({.#}\);</code><br />Replace: <code>Results.Text += \1;</code><br />(Or <code>stringBuilder.Append(\1);</code> or whatever is appropriate.)<br /><br />To find textboxes (Html.TextBox from the ASP.NET MVC helpers, and standard input elements) that don't have a maxlength set. Works on single lines only.<br /><code>(Html\.TextBox|input type="text")~(.#maxlength)</code><br />(Replace maxlength with any other text for other properties.)<br /><br />I found <a href="http://knol.google.com/k/brian-lalonde/microsoft-visual-studio-special-regular/34l0bem1ht3yo/3#">this Knol</a> by <a href="http://brianary.blogspot.com/">Brian Lalonde</a> very useful in creating these regular expressions (and I love the snarky ending paragraph).Lizhttp://www.blogger.com/profile/15074924782006831812noreply@blogger.com0tag:blogger.com,1999:blog-3805758694673185929.post-90220521949025449622007-06-17T20:23:00.000-07:002007-06-17T20:23:55.648-07:00How to Create a Theme in Windows SharePoint Services v2I was going to make a post about making SharePoint 2003 themes, but while I was searching for resources I came across <a href="http://www.heathersolomon.com/blog/articles/create2003theme.aspx">this guide by Heather Solomon</a>, which is far more comprehensive than anything I would have written. <br /><br />Thanks, Heather!Lizhttp://www.blogger.com/profile/15074924782006831812noreply@blogger.com0tag:blogger.com,1999:blog-3805758694673185929.post-1237366561611357532007-06-17T20:16:00.000-07:002007-07-25T07:04:27.870-07:00Butterscotch ice creamI had butter and brown sugar lying around the house, so I decided to search for a <a href="http://www.astray.com/recipes/?show=Butterscotch%20ice%20cream">Butterscotch Icecream recipe</a>. The only problem was that the recipe was all in Imperial (and measured sugar in grams, which is a pain for me as I don't have an electric scale).<br /><br />Consequently, I present you with the same recipe, but with different measurements.<br /><br /><span style="font-weight:bold;">Butterscotch ice cream</span><br /><br />60g Butter<br />6 tbsp Brown sugar; dark, soft<br />1 cup full cream milk; warm<br />2 Eggs<br />5 tbsp Caster sugar<br />1/4 tsp Vanilla essence<br />Whipping cream (10oz./283.5 g, which I estimate at about 300mL) <br /><br />1. Melt the brown sugar and butter together in a pan over a gentle heat. Increase the heat until the mixture bubbles for 1 minute only.<br />2. Allow to cool slightly.<br />3. Add the warm milk.<br />4. Stir continuously over a gentle heat until thoroughly blended.<br />5. Allow to cool.<br />6. Beat together the eggs and the caster sugar in a bowl.<br />7. Pour the mixture from the saucepan on to the beaten eggs/sugar, add the vanilla essence and stir.<br />8. Strain back into the pan.<br />9. Stir over a low heat until the mixture thickens slightly; take care not to let it boil.<br />10. Cool the mixture.<br />11. Whip the cream lightly and fold into the cooled mixture.<br />12. <strike>Pour into a freezer container and freeze until mushy. Beat with a whisk and return to the freezer until the ice cream is firm.</strike> Put in icecream maker. <br />(Website notes recipe is from Scottish Tea-Time Recipes by Johanna Mathie, ISBN 1 898435 18 9.)<br /><br />This is good with shortbread bits added, or macadamias, or with chocolate fudge sauce.<br /><br />I'm not sure about the cream quantity, so it might come out a little intense, depending on your tastes.Lizhttp://www.blogger.com/profile/15074924782006831812noreply@blogger.com0tag:blogger.com,1999:blog-3805758694673185929.post-79166993224415277632007-06-01T22:32:00.000-07:002007-06-01T22:37:08.381-07:00Icecream Base<ul><li>1 cup full cream milk</li><li>1 cup cream</li><li>1/3 cup sugar</li><li>2 whole eggs</li></ul><ol><li>Whisk together eggs and sugar until well-combined and fluffy.</li><li>Heat the milk until not-quite boiling, then stir into the egg and sugar.</li><li>Stir the mixture over low heat until it thickens slightly (or coats the back of a spoon), custard style. I do this in a Pyrex bowl over a saucepan of boiling water.</li><li>Refrigerate until cold, then stir in the cream.</li><li>Place the mixture in your icecream maker and follow the manufacturer's instructions.</li></ol>Depending on what you're adding to the mixture, add less milk and cream.<br /><br />I like this recipe because it doesn't involve large amounts of egg. In my icecream maker, the end product is quite soft.<br /><br />I often make this with whole 300mL cartons of milk and cream. The custard takes a little longer to thicken, but otherwise I haven't encountered any problems with it.<br /><br />This recipe was inspired by the proportions at Think Quest, however I like to cook my eggs a little more than that recipe.Lizhttp://www.blogger.com/profile/15074924782006831812noreply@blogger.com2tag:blogger.com,1999:blog-3805758694673185929.post-67120416839563433952007-06-01T22:09:00.000-07:002007-06-01T22:22:48.955-07:00WoW MacrosThese are mostly for my own benefit, in case I'm playing on my laptop and need my macros.<br /><br />Get Ready<br /><code>#showtooltip<br />/cast [modifier:ctrl] Conjure Water; [modifier:alt] conjure food; [modifier:shift] conjure mana emerald<br />/castsequence [nomodifier] reset=60 conjure water, conjure water, conjure mana emerald, conjure food, conjure food, evocation</code><br />This is a one-button food/water/gem macro. If you hold down ctrl while clicking it casts, if you hold down alt it casts food, with shift it casts mana emeralt (you'll want to change that if your spell is different).<br />If you don't hold down a modifier, it's a cast-sequence of water, water (makes 20), mana emerald, food, food (makes 20), and evocation. It will reset after a minute.<br /><br />Mount<br /><code>#showtooltip <br />/use [modifier:shift] Hearthstone; [modifier:alt] Swift Palomino; [flyable] Swift Red Gryphon; Swift Palomino</code><br />This will cast my (epic) flying mount if I'm in a place I can use it (ie. Outland), otherwise it will cast my ground mount. If you hold down shift it will cast Hearthstone, and alt overrides to the horse.<br /><br />Polymacro<br /><code>#showtooltip<br />/focus [target=focus, noexists]<br />/focus [target=focus, dead]<br />/focus [modifier:shift]<br />/s Polymorphing >%f<! Watch for it!<br />/castrandom [target=focus] Polymorph: Pig, Polymorph</code><br />This will focus my current target if my focus is dead or doesn't exist or if I hold down shift while clicking. It then makes an announcement of what I'm doing, and polymorphs my focus.<br /><br />Ice Block<br /><code>#showtooltip<br />/me is now a block of ice! Watch for disgruntled mobs!<br />/cast Ice Block</code><br />I like to let people know when I do this because it will wipe my aggro. My paladin companion likes it when we're duoing instances because she knows she can shield herself and not worry about me.<br /><br />THE EYE<br /><code>/target eye<br />/cast Fire Blast</code><br />If you've ever done undead Stratholme, this is for you. Usually takes out the Eye in one shot.Lizhttp://www.blogger.com/profile/15074924782006831812noreply@blogger.com0tag:blogger.com,1999:blog-3805758694673185929.post-80665983242650494552007-06-01T22:02:00.000-07:002007-06-01T22:30:32.579-07:00GTK ThemesI was recently alarmed to discover that my preferred IM client, Gaim, had been renamed to Pidgin and updated and nobody had told me. So I installed the new version and was suitably disoriented by the removal of protocol-specific icons. I see from their website that this is part of their approach to transparency of multi-protocol IM.<br /><br />At any rate, I found myself somewhat dissatisfied with the default GTK skins. So to save anybody else the Googling and hunting I went through here's how you do it on Windows:<br /><ul><li>You can download new themes for GTK from here: <a href="http://art.gnome.org/themes/gtk2/">http://art.gnome.org/themes/gtk2/</a></li><li>Unzip the theme you have chosen and copy it to C:\Program Files\Common Files\GTK\2.0\share\themes</li><li>Select the theme using the GTK+ Theme Selector that was probably added to your Start Menu.<br /></li></ul>Lizhttp://www.blogger.com/profile/15074924782006831812noreply@blogger.com2tag:blogger.com,1999:blog-3805758694673185929.post-55439735544331070832007-05-30T16:49:00.000-07:002007-05-30T16:51:34.231-07:00If anybody is looking for the "auto-convert older entries" option in their LiveJournal profile...I eventually found it at <a href="http://www.livejournal.com/settings/?c=OldEncoding">http://www.livejournal.com/settings/?c=OldEncoding</a><br /><br />You need to set this in order to use LJ Archive to backup your old entries. In fact, it wouldn't even backup my new entries until I set this.Lizhttp://www.blogger.com/profile/15074924782006831812noreply@blogger.com4