<?xml version="1.0"?>

<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/"	xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>

<title>Glenn Thomas Hvidsten</title>
<link>http://glenn.whitestone.no</link>
<description>The personal homepage of Glenn Thomas Hvidsten</description>
<language>en-US</language>
<copyright>Copyright (C) 2013, Glenn Thomas Hvidsten</copyright>

<item>
<title>Printing XPS files to a physical printer</title>
<link>http://glenn.whitestone.no/blog/article/printing-xps-files-to-a-physical-printer/</link>
<comments>http://glenn.whitestone.no/blog/article/printing-xps-files-to-a-physical-printer/#comments</comments>
<pubDate>2013-03-21 12:43</pubDate>
<category><![CDATA[.Net]]></category>
<category><![CDATA[Programming]]></category>
<description>I had the need to programatically print an XPS file, but a couple of hours of Google searches only returned examples of how to print TO an XPS file. It was extremely difficult to find how to send a XPS file to an actual physical printer.
Eventually something turned up and the solution seemed to be the XpsDocument class.

Look at this simplified [...]</description>
<content:encoded><![CDATA[<p>I had the need to programatically print an XPS file, but a couple of hours of Google searches only returned examples of how to print <b>TO</b> an XPS file. It was extremely difficult to find how to send a XPS file to an actual physical printer.<br/>Eventually something turned up and the solution seemed to be the <a href="http://msdn.microsoft.com/en-us/library/system.windows.xps.packaging.xpsdocument.aspx" title="<b>XpsDocument</b>"><b>XpsDocument</b></a> class.<br/><br/>Look at this simplified example to see how easy it turned out to be:<br/><br/><pre><br/>PrintDialog dlg = new PrintDialog();<br/>XpsDocument xpsDoc = new XpsDocument(PATH_TO_YOUR_XPS_FILE_HERE, System.IO.FileAccess.Read);<br/>dlg.PrintDocument(xpsDoc.GetFixedDocumentSequence().DocumentPaginator, &quot;Document title&quot;);<br/></pre><br/><br/>As you can see, reading a XPS file and then sending the contents to a printer is not very hard at all.</p>]]></content:encoded>
</item>
<item>
<title>Looking back at getting lost near Grand Canyon</title>
<link>http://glenn.whitestone.no/blog/article/looking-back-at-getting-lost-near-grand-canyon/</link>
<comments>http://glenn.whitestone.no/blog/article/looking-back-at-getting-lost-near-grand-canyon/#comments</comments>
<pubDate>2012-09-14 14:47</pubDate>
<category><![CDATA[Life]]></category>
<category><![CDATA[Travel]]></category>
<description>Having recently published my big Californian vacation video to YouTube I think it's time to reminisce a bit about my adventures.

As you already know from seeing the video and by photos in my photo album I went to Grand Canyon. Before traveling to the US, a colleague of mine mentioned the place where he visited Grand Canyon West and suggested I [...]</description>
<content:encoded><![CDATA[<p>Having recently published my big Californian vacation video to <a href="http://www.youtube.com/watch?v=tE7bd9n-AGc" title="YouTube">YouTube</a> I think it's time to reminisce a bit about my adventures.<br/><br/>As you already know from seeing the video and by photos in my photo album I went to Grand Canyon. Before traveling to the US, a colleague of mine mentioned the place where he visited Grand Canyon West and suggested I go there to.<br/>I looked up the place on Google Maps, found the GPS coordinates and plotted those into my GPS to get driving directions.<br/>My colleague warned me that the drive would seem a bit wrong because you would have to go onto some gravel roads, so when my GPS directed me onto a gravel road I didn't think much of it.<br/>I did get a bit more suspicious when the gravel road got more narrow and led into some mountains. My worry reached its peak when I suddenly got to a sign that said &quot;Only 4WD vehicles beyond this point&quot;. My GPS advised me to continue, but the sign, and the fact that I didn't have a 4WD car, advised me to turn around. What to do?!</p><p>Fortunately some locals came driving by on ATVs. They pulled up to me and asked me where I was going and I told them I was going to Grand Canyon West.<br/>They looked at each other, then at me, and promptly said: <i>&quot;Man! You're lost like fuck!&quot;</i><br/>Those words are certainly comforting. Especially when they looked in my car and followed up with: <i>&quot;What? No beer? No guns? Where's the fun in that?!&quot;</i>.<br/><br/>Fortunately, they were good guys, and even offered to give me a personalized tour of the mountains and the surroundings. Had I not been on a tight schedule I would've taken them up on the offer.<br/><br/>They then pointed out where I had gone wrong and told me where to go from there, so I turned off the GPS and followed their directions and eventually got to Grand Canyon West where I had a really great time.</p>]]></content:encoded>
</item>
<item>
<title>Attention comment spammers</title>
<link>http://glenn.whitestone.no/blog/article/attention-comment-spammers/</link>
<comments>http://glenn.whitestone.no/blog/article/attention-comment-spammers/#comments</comments>
<pubDate>2012-09-12 17:44</pubDate>
<category><![CDATA[Technology]]></category>
<description>I have now added a nofollow attribute to all links in the comments section, so spammers will no longer get increased page ranks from Google or other search engines.

For non-spammers, add the following to an anchor tag and google won't follow that</description>
<content:encoded><![CDATA[<p>I have now added a nofollow attribute to all links in the comments section, so spammers will no longer get increased page ranks from Google or other search engines.<br/><br/>For non-spammers, add the following to an anchor tag and google won't follow that link:<br/><br/>rel=&quot;nofollow&quot;</p>]]></content:encoded>
</item>
<item>
<title>For my sister</title>
<link>http://glenn.whitestone.no/blog/article/for-my-sister/</link>
<comments>http://glenn.whitestone.no/blog/article/for-my-sister/#comments</comments>
<pubDate>2012-09-03 16:20</pubDate>
<category><![CDATA[Life]]></category>
<description>My sister got married on Saturday, September 1.
There was a great party with many great speeches. I'm not claiming greatness on my own, but I will post it here (translated to English for my foreign friends) for everybody else to enjoy (for the first time, or again if you were there).
I said it many times that day, but I'll say it here [...]</description>
<content:encoded><![CDATA[<p>My sister got married on Saturday, September 1.<br/>There was a great party with many great speeches. I'm not claiming greatness on my own, but I will post it here (translated to English for my foreign friends) for everybody else to enjoy (for the first time, or again if you were there).<br/>I said it many times that day, but I'll say it here again.<br/><br/>Congratulations to my sister and her husband!</p><p><b>Both my sister (Elisabeth) and her husband (Fredrik) are teachers, so the toastmaster made the entire experience to be like a class at school.  I was the evening's teacher of the computer class.</b><br/><br/>----------<br/><br/>If everybody in the class can start their computers, open a web browser, go to Google and search for my name, you will all see that I'm not only Elisabeth's brother, but, if there were any doubts, her older brother.<br/><br/>The two of us have done a lot of stuff when we were younger, and we have both been both bad and good to each other. I don't necessarily remember much of this, but thankfully there are lots of pictures in our parents' house.<br/><br/>One of the best pictures from our childhood is me rolling you around in a toy stroller made of wood. I still find it a bit strange that you're now rolling around a little rascal of your own.<br/><br/>Something I <i>do</i> remember is a certain pajama party.<br/><br/>Elisabeth was home alone for the very first time and had a sleepover pajama party with her friends. I was studying in Kongsberg at that time, so everything was set for a proper girl party. <i>[Note: Kongsberg is about 120km from our parents house, or almost 3 hours by train.]</i><br/>What Elisabeth and the other girls didn't know was that I had travelled back home and snuck into the house without them noticing. Dressed in a black robe and a <a href="http://en.wikipedia.org/wiki/Ghostface_%28Scream%29" title="Ghostface">Ghostface</a> mask I ran screaming into the living room.<br/>The screams from the girls quickly drowned mine. Elisabeth actually started to cry, and as the good brother I am I don't regret that stunt for even a moment.<br/><br/>I always counted on you finding yourself a handsome, kind, pleasant and no-frills kind of guy. Why you ended up with Fredrik is very good question! Because after all the stories I heard at his bachelor party I'm so sure about all those points any more.<br/>But seriously, Fredrik really is a kind, pleasant and no-frills kind of guy and it's really nice to have you as my brother-in-law.<br/><br/>This is a day you have worked a lot to reach, and I'm sure everybody here agrees with me that all that work has truly paid off.<br/><br/>I wish that your future brings good luck and good fortune.<br/>Congratulations!<br/><br/>Cheers!</p>]]></content:encoded>
</item>
<item>
<title>Change image tag generated by CKEditor</title>
<link>http://glenn.whitestone.no/blog/article/change-image-tag-generated-by-ckeditor/</link>
<comments>http://glenn.whitestone.no/blog/article/change-image-tag-generated-by-ckeditor/#comments</comments>
<pubDate>2012-06-11 21:08</pubDate>
<category><![CDATA[Programming]]></category>
<description>For a new project of mine I'm using a rich text editor called CKEditor.
This is a highly configurable editor that, unfortunately, suffers from cluttered and not easily understandable documentation.
I needed to change the generated HTML from the editor so that images that were resized not only had their size set as style attributes, but as query [...]</description>
<content:encoded><![CDATA[<p>For a new project of mine I'm using a rich text editor called <a href="http://ckeditor.com/" title="CKEditor">CKEditor</a>.<br/>This is a highly configurable editor that, unfortunately, suffers from cluttered and not easily understandable documentation.<br/>I needed to change the generated HTML from the editor so that images that were resized not only had their size set as style attributes, but as query string variables.<br/><br/>So I needed this:<br/><pre>&lt;img src=&quot;http://yoursite.com/photo.jpg&quot; style=&quot;width:150px; height:200px;&quot; /&gt;</pre><br/>to be output as this:<br/><pre>&lt;img src=&quot;http://yoursite.com/photo.jpg?width=150&amp;height=200&quot; style=&quot;width:150px; height:200px;&quot; /&gt;</pre><br/>That proved to be easier said than done, but after quite a lot of googling, asking on several forums, and getting some helpful (and some not helpful at all) replies, I finally ended up with the following:<br/><br/><br/>Put the following code into CKEditor's <i>config.js</i><br/><br/><pre>CKEDITOR.on('instanceReady', function (ev) {<br/>    var editor = ev.editor,<br/>        dataProcessor = editor.dataProcessor,<br/>        htmlFilter = dataProcessor &amp;&amp; dataProcessor.htmlFilter;<br/><br/>    htmlFilter.addRules( {<br/>        elements : {<br/>            $ : function( element ) {<br/>                // Output dimensions of images as width and height attributes on src<br/>                if ( element.name == 'img' ) {<br/>                    var style = element.attributes.style;<br/>                    if (style) {<br/>                        // Get the width from the style.<br/>                        var match = /(?:^|\s)width\s*:\s*(\d+)px/i.exec( style ),<br/>                            width = match &amp;&amp; match[1];<br/><br/>                        // Get the height from the style.<br/>                        match = /(?:^|\s)height\s*:\s*(\d+)px/i.exec( style );<br/>                        var height = match &amp;&amp; match[1];<br/><br/>                        var imgsrc = element.attributes.src + &quot;?width=&quot; + width + &quot;&amp;height=&quot; + height;<br/><br/>                        element.attributes.src = imgsrc;<br/>                        element.attributes['data-cke-saved-src'] = imgsrc;<br/>                    }<br/>                }<br/>            }<br/>        }<br/>    });<br/>});</pre><br/><br/>This code is run whenever the CKEditor generates the actual HTML, which happens when you either view the source by clicking the &quot;Source&quot; button, or by performing an HTTP POST of that page.<br/><br/>A small warning, though. The code above will keep appending the width and height query strings for each click on the &quot;Source&quot; button, or for each postback, so you might want to add some extra logic to filter out the width and height query strings before appending them to the src attribute. (I might edit this post in the future with the correct syntax for that ;))</p>]]></content:encoded>
</item>
<item>
<title>Art history lesson</title>
<link>http://glenn.whitestone.no/blog/article/art-history-lesson/</link>
<comments>http://glenn.whitestone.no/blog/article/art-history-lesson/#comments</comments>
<pubDate>2012-02-26 19:23</pubDate>
<category><![CDATA[Life]]></category>
<description>Today my nephew got baptized. Let's not dwell on that and look at what I got him instead.
A few days ago I actually went into an art gallery and bought a piece of art. There's certainly a first time for everything! I hope the little guy will appreciate a genuine piece of art as he grows older.

What I got him was this lithograph from artist Per [...]</description>
<content:encoded><![CDATA[<p><img align="right" alt="Art history lesson" src="http://glenn.whitestone.no/common/displaydata.php?id=07edc390-5f1f-11e1-85ca-000c293009c4&amp;size=100&amp;isheight=1&amp;constrainboth=1" />Today my nephew got baptized. Let's not dwell on that and look at what I got him instead.<br/>A few days ago I actually went into an art gallery and bought a piece of art. There's certainly a first time for everything! I hope the little guy will appreciate a genuine piece of art as he grows older.<br/><br/>What I got him was this <a href="http://en.wikipedia.org/wiki/Lithography" title="lithograph">lithograph</a> from artist <a href="http://en.wikipedia.org/wiki/Per_Krohg" title="Per Krohg">Per Krohg</a>, son of the renowned <a href="http://en.wikipedia.org/wiki/Christian_Krohg" title="Christian Krohg">Christian Krohg</a>. Per originally made a series of pictures for his son Guy when he was a child. Each picture represented a letter in the alphabet. The family of artists were typical of their time and lived in France, so each picture also represented something in French.<br/>Unfortunately the gallery didn't have the letter L, so I got the letter C (for &quot;Collage&quot; or &quot;la chambre&quot;) instead because I liked the motif and it had a fitting look for a baby room. The picture is also numbered, so there are apparently 75 copies and this is number 35.<br/>I'm interested in more information about this series, so if anybody out there can help do write me an email or a comment on this post.</p>]]></content:encoded>
</item>
<item>
<title>Response.Redirect inside an UpdatePanel</title>
<link>http://glenn.whitestone.no/blog/article/responseredirect-inside-an-updatepanel/</link>
<comments>http://glenn.whitestone.no/blog/article/responseredirect-inside-an-updatepanel/#comments</comments>
<pubDate>2011-10-18 16:37</pubDate>
<category><![CDATA[.Net]]></category>
<category><![CDATA[Programming]]></category>
<description>Recently I've had more and more pages displaying unexpected behaviour.
I had an UpdatePanel with a button inside it. The button's Click event performed a Response.Redirect(), but nothing happened.
The Javascript error console showed the following error message:

"Sys.WebForms.PageRequestManagerParserErrorException: The message received from [...]</description>
<content:encoded><![CDATA[<p>Recently I've had more and more pages displaying unexpected behaviour.<br/>I had an UpdatePanel with a button inside it. The button's Click event performed a Response.Redirect(), but nothing happened.<br/>The Javascript error console showed the following error message:<br/><br/><blockquote><p>Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled.</p></blockquote><br/><br/>After some googling it seems that ASP.Net doesn't quite support Response.Redirect() inside UpdatePanels any more.<br/><br/>The solution was to make sure the button actually performed a full postback of the webpage, and not only a partial postback (as it would do because it was inside an UpdatePanel).<br/><br/>There are two ways of doing this. First the easy way.<br/><br/><pre>&lt;asp:UpdatePanel runat=&quot;server&quot;&gt;<br/>    &lt;ContentTemplate&gt;<br/>        &lt;asp:Button ID=&quot;MyButton&quot; runat=&quot;server&quot; /&gt;<br/>    &lt;/ContentTemplate&gt;<br/>    &lt;Triggers&gt;<br/>        &lt;asp:PostBackTrigger ControlID=&quot;MyButton&quot; /&gt;<br/>    &lt;/Triggers&gt;<br/>&lt;/asp:UpdatePanel&gt;</pre><br/><br/>Here you're basically telling the UpdatePanel that &quot;MyButton&quot; should perform a full postback instead of a partial one.<br/><br/>My problem was a bit more complicated, though, because &quot;MyButton&quot; was inside a GridView. This complicated things a bit, but not too much. Mainly you have to have access to the ScriptManager.<br/><br/>Add the OnRowDataBund event to your GridView. In this event do the following:<br/><br/><pre>protected void MyGridview_RowDataBound(object sender, GridViewRowEventArgs e)<br/>{<br/>    if (e.Row.RowType == DataControlRowType.DataRow)<br/>    {<br/>        Button MyButton = (Button)e.Row.FindControl(&quot;MyButton&quot;);<br/>        ScriptManager1.RegisterPostBackControl(MyButton);<br/>    }<br/>}</pre><br/><br/>So instead of telling the UpdatePanel that your button should do a full postback, you're telling the ScriptManager the same thing.<br/>Doing this in code-behind would obviously work for the first example as well.<br/><br/>UPDATE:<br/><br/>This seems to be a recurring bug in .Net 2.0, 3.0 and 3.5, and is actually fixed in .Net 4.x.<br/>I have successfully got a Response.Redirect() to work inside an update panel without using any of the above fixes, and only by upgrading my solution, projects and website to .Net 4.0.</p>]]></content:encoded>
</item>
<item>
<title>Samba/Winbind connection issues</title>
<link>http://glenn.whitestone.no/blog/article/samba-winbind-connection-issues/</link>
<comments>http://glenn.whitestone.no/blog/article/samba-winbind-connection-issues/#comments</comments>
<pubDate>2011-10-15 13:08</pubDate>
<category><![CDATA[Linux]]></category>
<category><![CDATA[Technology]]></category>
<description>I recently had to reconfigure my linux (Ubuntu 10.04 LTS) servers.
I had previously used these two howto's to configure my servers.
Suddenly one of them refused to properly connect with various error messages:

# wbinfo -p
Ping to winbindd failed

# wbinfo -u
Error looking up domain users

# wbinfo -t
checking the trust secret via RPC [...]</description>
<content:encoded><![CDATA[<p>I recently had to reconfigure my linux (Ubuntu 10.04 LTS) servers.<br/>I had previously used <a href="https://help.ubuntu.com/community/ActiveDirectoryWinbindHowto" title="these">these</a> <a href="http://ubuntuforums.org/showthread.php?t=91510" title="two">two</a> howto's to configure my servers.<br/>Suddenly one of them refused to properly connect with various error messages:<br/><br/><i># wbinfo -p</i><br/>Ping to winbindd failed<br/><br/><i># wbinfo -u</i><br/>Error looking up domain users<br/><br/><i># wbinfo -t</i><br/>checking the trust secret via RPC calls failed<br/>Could not check secret<br/><br/>After a week of googling I finally found the following <a href="http://lists.samba.org/archive/samba/2003-May/066832.html" title="solution">solution</a>, which did the trick for me.<br/><br/><div style="margin-left:15px">Stop <i>smbd</i>, <i>nmbd</i> and <i>winbindd</i> <i>(make sure they are really dead using ps. winbindd still lingered after I stopped the service)</i></div><div style="margin-left:15px">Delete the linux computer from the Primary Domain Controller (using the Management Console)</div><div style="margin-left:15px">Delete the secrets database <i>(/var/lib/samba/secrets.tdb)</i></div><div style="margin-left:15px">Join the domain again</div><div style="margin-left:15px">Start the daemons (<i>smbd</i>, <i>nmbd</i> and <i>winbindd</i>)</div><div style="margin-left:15px">Test the winbind commands to see that everything is working</div></p>]]></content:encoded>
</item>
<item>
<title>Trying a new thing with my blog</title>
<link>http://glenn.whitestone.no/blog/article/trying-a-new-thing-with-my-blog/</link>
<comments>http://glenn.whitestone.no/blog/article/trying-a-new-thing-with-my-blog/#comments</comments>
<pubDate>2011-10-15 11:23</pubDate>
<category><![CDATA[Life]]></category>
<category><![CDATA[Technology]]></category>
<description>Because I'm using Twitter, Facebook and Google+ I haven't really made any good posts to my blog for a while.
I'm trying to remedy this by taking my blog in a new direction.
As a &quot;Technology Enthusiast&quot; I regularly get stuck in various situations where I have to do a lot of googling. Some times I can google for a week and not find a [...]</description>
<content:encoded><![CDATA[<p>Because I'm using <a href="http://twitter.com/GTHvidsten" title="Twitter">Twitter</a>, <a href="http://facebook.com/gthvidsten" title="Facebook">Facebook</a> and <a href="http://plus.google.com/113018222949520957533/posts" title="Google+">Google+</a> I haven't really made any good posts to my blog for a while.<br/>I'm trying to remedy this by taking my blog in a new direction.<br/>As a &quot;Technology Enthusiast&quot; I regularly get stuck in various situations where I have to do a lot of googling. Some times I can google for a week and not find a solution.<br/>When I finally do find a solution I've decided I should write about it on my blog so that others can (maybe) find the solution as well.<br/>So don't be surprised when you see lots of technical stuff popping up on this blog instead of the usual ramblings about what happens (or not) in my life.</p>]]></content:encoded>
</item>
<item>
<title>Give a little bit of yourself today and save a life tomorrow!</title>
<link>http://glenn.whitestone.no/blog/article/give-a-little-bit-of-yourself-today-and-save-a-life-tomorrow/</link>
<comments>http://glenn.whitestone.no/blog/article/give-a-little-bit-of-yourself-today-and-save-a-life-tomorrow/#comments</comments>
<pubDate>2011-06-14 08:15</pubDate>
<category><![CDATA[Life]]></category>
<category><![CDATA[Reflections]]></category>
<description>Today is the World Blood Donor Day. Donating blood is such an easy thing to do, and is also a very easy way to help save lives. You only give about 15-30 minutes of your time, and a pint of blood. Seeing how many lives are saved each year because of blood donors, the choice shouldn't really be that hard to make, but still there is a profound lack [...]</description>
<content:encoded><![CDATA[<p><img align="right" alt="Give a little bit of yourself today and save a life tomorrow!" src="http://glenn.whitestone.no/common/displaydata.php?id=096b6210-960a-11e0-bd6c-000c2916f59f&amp;size=100&amp;isheight=1&amp;constrainboth=1" />Today is the <a href="http://en.wikipedia.org/wiki/World_Blood_Donor_Day" title="World Blood Donor Day">World Blood Donor Day</a>. Donating blood is such an easy thing to do, and is also a very easy way to help save lives. You only give about 15-30 minutes of your time, and a pint of blood. Seeing how many lives are saved each year because of blood donors, the choice shouldn't really be that hard to make, but still there is a profound lack of available blood in hospitals around the world.<br/><br/>I am, of course, a donor. Even though I hate syringes and needles, I go through with the donation roughly once every three months. Being such an easy way to help others, I gladly do it. I get a gift from the local hospital every time I do it, but I would continue doing it even if I got nothing at all.<br/><br/>Use today as an incentive to go to your local blood bank and sign up to be a donor! If you're at work, tell your boss you're taking a few moments off work to go register. The boss should welcome this action. If he doesn't, remind him that some day maybe he or his family could be needing blood.<br/>I'm doing my part, are you?<br/><br/>For more information, see the following sites:<br/><br/><a href="http://www.redcrossblood.org/" title="American Red Cross">American Red Cross</a>, USA<br/><a href="https://www.blood.co.uk/" title="Give Blood">Give Blood</a>, UK<br/><a href="https://www.giblod.no/forside.asp?level=7348#campaign=bflfront2" title="GiBlod.no">GiBlod.no</a>, Norway</p>]]></content:encoded>
</item>
</channel>
</rss>
