tag:blogger.com,1999:blog-13734435450953651032024-03-05T20:24:13.674-08:00Brain PorridgeProblems that make my porridge-filled brain ache. Thanks to Mr D for inspiration on the name: myspace.com/discoporridge.Chrishttp://www.blogger.com/profile/13880841562817161113noreply@blogger.comBlogger9125tag:blogger.com,1999:blog-1373443545095365103.post-5329076731110719902014-09-09T14:28:00.003-07:002014-09-09T14:28:58.818-07:00Nexus 5 not showing up on Windows 8.1<div dir="ltr" style="text-align: left;" trbidi="on">
Connecting my Nexus 5 using USB appeared to have stopped working. In Device Manager I could see some ACER ADB devices. I uninstalled the drivers from device manager. Connected phone again, another ACER ADB was showing.<br />
<br />
To solve, I selected the ACER ADB device in Device Manager, right click and choose<br />
<br />
Properties => Driver => Update Driver => Browse My Computer for Driver Software => Let me pick from list => MTP<br />
<br />
Then your Nexus 5 should show up.</div>
Chrishttp://www.blogger.com/profile/13880841562817161113noreply@blogger.com0tag:blogger.com,1999:blog-1373443545095365103.post-8787708196866130182014-08-29T01:20:00.002-07:002014-08-29T01:26:22.823-07:00IIS SSL Issues<div dir="ltr" style="text-align: left;" trbidi="on">
Suddenly I couldn't browse to https://localhost/test.html<br />
<br />
I could browse to http, but not https.<br />
<br />
In event viewer => windows logs => system I was seeing<br />
"A fatal error occurred when attempting to access the SSL client credential private key..."<br />
<br />
To solve, I did this:<br />
<br />
Fire up MMC.exe and add the local computer account certificates snap in.<br />
Navigate to Certificates/Personal/Certificates.<br />
Find the web server cerficate. Right click => all tasks => manage private keys.<br />
Grant full control to everyone.<br />
<br />
<br /></div>
Chrishttp://www.blogger.com/profile/13880841562817161113noreply@blogger.com0tag:blogger.com,1999:blog-1373443545095365103.post-35058489421716368772012-09-01T07:32:00.001-07:002012-09-01T07:36:54.768-07:00.NET Simple Recursive ConfigurationElementCollections<div dir="ltr" style="text-align: left;" trbidi="on">
I've seen plenty of quite complicated examples of how to load recursive configuration element collections from app.config. Here's a really simple example.<br />
<br />
I have the app.config below. You'll see that a person can have children. Each child is also a person and so each child can have children, and so on.<br />
<br /></div>
<pre class="brush: xml"><?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="myPeople" type="NestedCustomConfig.PeopleConfigSection, NestedCustomConfig" />
</configSections>
<myPeople>
<people>
<add name="Frank" />
<add name="Stanley">
<children>
<add name="Pauline">
<children>
<add name="Augustus"/>
<add name="Zebedee" />
</children>
</add>
</children>
</add>
</people>
</myPeople>
</configuration>
</pre>
<div dir="ltr" style="text-align: left;" trbidi="on">
To load this, I have the following classes:
<br />
<br />
<br />
<pre class="brush: csharp">using System.Configuration;
namespace NestedCustomConfig
{
public class PersonConfigurationElement : ConfigurationElement
{
[ConfigurationProperty("name", IsRequired = true, IsKey = true)]
public string Name
{
get { return (string) base["name"]; }
set { base["name"] = value; }
}
[ConfigurationProperty("children", IsDefaultCollection = false, IsRequired = false)]
public People Children
{
get { return (People) base["children"]; }
set { base["children"] = value; }
}
}
public class People : ConfigurationElementCollection
{
protected override ConfigurationElement CreateNewElement()
{
return new PersonConfigurationElement();
}
protected override object GetElementKey(ConfigurationElement element)
{
return ((PersonConfigurationElement)element).Name;
}
}
public class PeopleConfigSection : ConfigurationSection
{
[ConfigurationProperty("people", IsDefaultCollection = false)]
public People People
{
get
{
return (People)base["people"];
}
}
}
}
</pre>
<div dir="ltr" style="text-align: left;" trbidi="on">
I created a Console App for the example and have the following in Program.cs:</div>
<pre class="brush: csharp">using System.Configuration;
namespace NestedCustomConfig
{
class Program
{
static void Main()
{
var peopleSection = ConfigurationManager.GetSection("myPeople");
}
}
}
</pre>
<div dir="ltr" style="text-align: left;" trbidi="on">Good luck. </div>
</div>Chrishttp://www.blogger.com/profile/13880841562817161113noreply@blogger.com0tag:blogger.com,1999:blog-1373443545095365103.post-67128069917033699392012-06-02T10:19:00.002-07:002012-06-02T10:20:24.338-07:00Swiss Mortgage Example<div><span>In case you fancy buying a 1,000,000 CHF residential property in beautiful Switzerland:</span></div><div><span style="font-family: Georgia, serif; "><br /></span></div><div><span style="font-family: Georgia, serif; ">Purchase price: 1,000,000</span></div><div><span>20% Deposit: 200,000</span></div><div><span>First mortgage 66% of purchase price: 660,000 - renegotiate every 10 (max) years</span></div><div><span>Second mortgage 14% of purchase price: 140,000 - must be paid off in (max) 24 years</span></div><div><span><br /></span></div><div><span>5% * First Mortgage amount has to be less than 30% of your gross income</span></div><div><span><span class="Apple-tab-span" style="white-space: pre; "><br /></span></span></div><div><span style="white-space: pre; ">Simple! </span></div>Chrishttp://www.blogger.com/profile/13880841562817161113noreply@blogger.com0tag:blogger.com,1999:blog-1373443545095365103.post-54628145858914548782012-05-17T06:55:00.002-07:002012-05-17T06:55:25.021-07:00Old laptop running hot after Windows 7 upgrade<div dir="ltr" style="text-align: left;" trbidi="on">
So, I finally upgraded my aging Windows XP laptop to Windows 7. The <a href="http://www.microsoft.com/en-us/download/details.aspx?id=20">Windows 7 Upgrade Advisor</a> assured me my pc had enough resources to handle the (not so) new OS. The install went fine, but I noticed that the machine was getting very hot. Installing <a href="http://www.almico.com/speedfan.php">Speedfan</a> allowed me to monitor the temp, which was over 90C at times.<br />
<br />
A quick look at the Performance tab of the Task Manager (while watching an excellent talk on <a href="http://channel9.msdn.com/Blogs/codefest/DC2010T0100-Keynote-Rx-curing-your-asynchronous-programming-blues">Reactive Extensions</a>) showed me the CPU was maxing out. Next stop was the processes tab, showing processes from all users and ordering by CPU usage. Pretty close to the top was wmpnetwk.exe.<br />
<br />
This is Windows Media Player Network Sharing Service, which, according to the its description in Services, "Shares Windows Media Player libraries to other networked players and media devices using Universal Plug and Play".<br />
<br />
I decided I didn't need this, especially at the expense of running my CPU at over 90C (I already have a device for those kind of temperatures: a kettle). So, I went to Services, selected "Windows Media Player Network Sharing Service", right-clicked and chose properties from the context menu, set Start Up Type to disabled and stopped the service.<br />
<br />
Since then, the temp has reduced to between 40 and 50C. Still fairly high maybe (need to clean the cooling system probably), but manageable.</div>Chrishttp://www.blogger.com/profile/13880841562817161113noreply@blogger.com0tag:blogger.com,1999:blog-1373443545095365103.post-48358215592405081962009-08-11T06:34:00.000-07:002009-08-11T06:36:23.089-07:00TOAD - file extensions and highlighting.It’s been bugging me for a while that *.vew files were opening in TOAD without keywords being highlighted as they were in *.vw files. <br /><br />This can be fixed by adding the *.vew file-extension here:<br /><br />View=> Toad Options=>Editor=>Behaviour<br /><br />There is a “languages” frame in the middle at the bottom of the page. Select “PL/SQL” from the drop-down box and click on the button with three dots in it. <br /><br />In the “General” tab on the form that opens, you can add file extensions, so add VEW, SPS, SPB and anything else you want formatted.<br /><br />Hope this is of use.Chrishttp://www.blogger.com/profile/13880841562817161113noreply@blogger.com0tag:blogger.com,1999:blog-1373443545095365103.post-2608701725938904322009-06-12T06:58:00.001-07:002009-06-12T07:02:12.918-07:00NUnit TipWhen installing <a href="http://www.nunit.org/index.php">NUnit</a>, choose the "complete" installation option, otherwise the tests for NUnit itself aren't installed...and your brain will fill with porridge.Chrishttp://www.blogger.com/profile/13880841562817161113noreply@blogger.com0tag:blogger.com,1999:blog-1373443545095365103.post-50410998003449262722009-06-12T04:34:00.000-07:002009-06-12T04:56:11.661-07:00Cruise ControlI spent a couple of days this week configuring <span style="text-decoration: underline;"> </span><a href="http://nant.sourceforge.net/">NAnt </a>and <a href="http://confluence.public.thoughtworks.org/display/CCNET/Welcome+to+CruiseControl.NET">Cruise Control</a> to build one of my projects. It's all running on my dev box, until I can find a server to run it on. Not ideal, I know.<br /><br />I configured Cruise Control while running the ccnet.exe utility which handily outputs to a command window.<br /><br />When I switched to using the Cruise Control Service proper (ccservice.exe), running under a user id with all the necessary permissions to access my VSS (don't start on the VSS debate!) database, I got the following error:<br /><br />"No VSS database (srcsafe.ini) found. Use the SSDIR environment variable or run netsetup. "<br /><br />So, I added the environment variables. And I still got the problem. I tore the remains of my hair out and my brain filled with porridge.<br /><br />Eventually, I found the problem. I'd specified a drive-mapping rather than a UNC in the SSDIR tag in ccnet.config. The user running ccnetservice.exe has no knowledge about the drive-mappings on my machine.<br /><br />The tag should look something like this:<br /><br />< ssdir > \\Server\Directory\AnotherDirectory\Source Safe < /ssdir ><br /><br />and NOT something like this:<br /><br />< ssdir > V:\AnotherDirectory\Source Safe < /ssdir ><br /><br />Hope this helps someone.Chrishttp://www.blogger.com/profile/13880841562817161113noreply@blogger.com0tag:blogger.com,1999:blog-1373443545095365103.post-46227551377725268402009-05-26T08:46:00.000-07:002009-05-27T11:40:43.031-07:00Disecting the disection of HardRock Cafe Memorabilia - Part 1It all started when a friend showed me the <a href="http://memorabilia.hardrock.com/">Hardrock Memorabilia site.</a> "That's cool," I thought, "I could build myself a nice photo website like that." So then I set about investigating how it worked. <div><br /></div><div>A quick search on the web led me to <a href="http://projectsilverlight.blogspot.com/2008/03/dissecting-hard-rock-memorabilia-and.html">Wilfred Pinto's blog</a> and his fantastic recreation of some of the Hardrock functionality. Thanks, Wilfred!</div><div><br /></div><div>I downloaded the source and, fairly soon, I'd got it working with some of my own pictures. However, there were a couple of parts of the code that I just didn't understand. Armed with a brain made of porridge, I attempted to solve the problems.</div><div><br /></div><div>Here's the first part that I've been tearing my hair out over:</div><div><br /></div><div>1. How are the coordinates, width and height calculated for the new Rect object in GetSubImageRect?</div><div><br /></div><div>Here's the code (thanks, Wilfred P): </div><div><br /></div><div><div>Rect GetSubImageRect(int indexSubImage)</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>{</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> if (indexSubImage <>= msi.SubImages.Count)</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>return Rect.Empty;</div><div><span class="Apple-tab-span" style="white-space:pre"> </span></div><div><span class="Apple-tab-span" style="white-space:pre"> </span>MultiScaleSubImage subImage = msi.SubImages[indexSubImage];</div><div><span class="Apple-tab-span" style="white-space:pre"> </span></div><div><span class="Apple-tab-span" style="white-space:pre"> </span>double scaleBy = 1 / subImage.ViewportWidth;</div><div> </div><div><span class="Apple-tab-span" style="white-space:pre"> </span>return new Rect(-subImage.ViewportOrigin.X * scaleBy,-subImage.ViewportOrigin.Y * scaleBy,</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>1 * scaleBy, (1 / subImage.AspectRatio) * scaleBy);</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>}</div></div><div><br /></div><div><br /></div><div>I created a new DeepZoom project that contained only the functionality I was interested in and worked it out.<br /></div><div><br /></div><div>We want to create a rectangle the coordinates, width and height of which are "logical" or normalized to find out if the rectangle contains the logical point we're testing. For a definition of "logical", read <a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.multiscaleimage.elementtologicalpoint(VS.95).aspx">MSDN.</a></div><div><br /></div><div>I read <a href="http://blogs.msdn.com/lutzg/archive/2009/03/12/deep-zoom-collections-explained-part-1-coordinates-and-viewports.aspx">Gerhard Lutz's blog.</a> This guy knows his stuff, but it was too much for my peanut brain and I couldn't quite get it straight. If anyone thinks they can explain it to me in terms I'd understand, please get in touch. </div><div><br /></div><div>Luckily, <a href="http://blogs.msdn.com/jaimer/archive/2008/06/23/working-with-collections-in-deep-zoom.aspx">Jaime Rodriguez</a> had written something about subimages, which really helped. </div><div><br /></div><div>This is what I found out,it seems to work and it makes sense to me:<br /></div><div><br /></div><div>1. The SubImage.ViewPortWidth is relative to the the width of the MultiScaleImage control. </div><div><br /></div><div>For example, if SubImage.ViewPortWidth = 1 then it takes up the whole of the multiscale image width. If SubImage.ViewPortWidth = 2 then it takes up 1/2 the multiscale image width.</div><div><br /></div><div>2. The SubImage.ViewPortOrigin.X and .Y values are relative to the logical width of the SubImage with the added twist that coordinates within the MultiScaleImage are negative.</div><div><br /></div><div>Here's an example of a MultiScaleImage control containing 10 subimages. The images are numbered 0 to 9 from top left to bottom right. I added the numbers after I'd taken a snapshot of the page. Click on the image to see a bigger version.</div><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1Q2yZBAUCoPFVOt2hNZNmxzeWkK4DLWjQzUjSXZ6AgfTR86OwzYZtE1-V8YjL_6qB4EibgssgrM-QnWHhz0MQciLDhh4WU9OtE8FZrBkOrF1-9ACDytxtmCjcIuKvdEoY2HBBAmwOGy5x/s1600-h/SilverlightTestStartNumbered.jpg"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 241px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1Q2yZBAUCoPFVOt2hNZNmxzeWkK4DLWjQzUjSXZ6AgfTR86OwzYZtE1-V8YjL_6qB4EibgssgrM-QnWHhz0MQciLDhh4WU9OtE8FZrBkOrF1-9ACDytxtmCjcIuKvdEoY2HBBAmwOGy5x/s400/SilverlightTestStartNumbered.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5340442536845924050" /></a><br /><div><br /></div><div>Here's some info about each image. Click on the image to see a bigger version:</div><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhPyIDbCK3qBq5Axh1ccPom1Hgv1GFnnO0w09WsqVFDWfusrewySkl1JpPJDR_lz9qlVP4SxzLi02BkkkLukoqiVFvWwLGJDTqr-t33s6m3Gri7EvgFYhfyImX8itAwNl08fy07_p-uMsxQ/s1600-h/ViewPortEtc.JPG"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 310px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhPyIDbCK3qBq5Axh1ccPom1Hgv1GFnnO0w09WsqVFDWfusrewySkl1JpPJDR_lz9qlVP4SxzLi02BkkkLukoqiVFvWwLGJDTqr-t33s6m3Gri7EvgFYhfyImX8itAwNl08fy07_p-uMsxQ/s400/ViewPortEtc.JPG" border="0" alt="" id="BLOGGER_PHOTO_ID_5340438869154263618" /></a><br /><div>So, for image 0, ViewPortOrigin = (0,0). This means the top left hand corner of the SubImage (the ViewPortOrigin) is in the top left hand corner of the MultiScaleImage.</div><div><br /></div><div>Let's create the rectangle for image 6.</div><div><br /></div><div>Image 6 has ViewPortOrigin = (-2.5,-1.5). The minus sign tells us the ViewPortOrigin coordinate is to the right and down of (0,0). But how much? Let's work it out.</div><div><br /></div><div>As mentioned above, the ViewPortOrigin is relative to the logical width of the SubImage. The logical width of SubImage = 1/SubImage.ViewPortWidth. </div><div><br /></div><div>In the code example: ScaleBy = 1/SubImage.ViewPortWidth.</div><div><br /></div><div>In this case, ScaleBy = 1/5.5 = 0.181818181</div><div><br /></div><div>So, SubImage.ViewPortOrigin.X as a logical point along the X axis of the MultiScaleImage is:</div><div><br /></div><div>-1 * -2.5 * 0.181818181 = 0.4545454.</div><div><br /></div><div>(We multiply by -1 otherwise the coordinates will be outside the MultiScaleImage. The negative coordinates are only used in the ViewPortOrigin of the SubImage.)</div><div><br /></div><div>The Y coordinate of the rectangle will be:</div><div><br /></div><div>-1 * -1.5 * 0.181818181 = 0.27272727</div><div><br /></div><div>The width will be simply 1/SubImage.ViewPortWidth = ScaleBy = .181818181</div><div><br /></div><div>The logical height is a little more complicated.</div><div><br /></div><div>AspectRatio = Width/Height, so Height = Width/AspectRatio.</div><div><br /></div><div>Logical Width = ScaleBy,</div><div>So, Height = ScaleBy /AspectRatio = 0.1818181/0.666666 = 0.272727</div><div><br /></div><div>If you want the pixel coordinates (again, see <a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.multiscaleimage.logicaltoelementpoint(VS.95).aspx">MSDN</a> for the definition), you can multiply the results of the above by the actual width of the MultiscaleImage.</div><div><br /></div><div>For example, the pixel X coordinate of the rectange would be:</div><div><br /></div><div> 0.4545454 * 400 = 181.818181</div><div><br /></div><div><div><br /><div><br /></div><div><br /></div><div><br /></div></div></div>Chrishttp://www.blogger.com/profile/13880841562817161113noreply@blogger.com0