Tuesday, December 15, 2009
Monday, December 14, 2009
Thursday, December 10, 2009
DataBind
With nothing of particular note to bulk up this entry, I'm hoping to later collect all my knowledge on data binding into one post...
The Links...
Tuesday, December 08, 2009
Lifehacker Roundup
- http://gizmodo.com/5420641/can-my-ipod-make-this-airplane-explode
- http://lifehacker.com/5417966/networks-lights-turns-your-keyboard-leds-into-activity-indicators
- http://lifehacker.com/5420356/the-complete-guide-to-avoiding-online-scams-for-your-less-savvy-friends-and-relatives
- http://lifehacker.com/5420632/how-to-know-when-your-dns-servers-are-failing
- http://lifehacker.com/5416726/use-your-psp-as-a-wi+fi-scanner
- http://lifehacker.com/5420531/google-now-personalizes-logged+out-searches
And lastly, from the Network Lights site: http://www.itsamples.com/index.html - the best part? They provide source code for a lot of stuff.
Stuff it, instead of consecutive posts for this stuff, I'll just build up this week's...
- http://lifehacker.com/5422014/make-google-chrome-open-with-permanently-pinned-tabs
- http://lifehacker.com/5421670/negotiate-anything-by-keeping-three-things-in-mind
- http://lifehacker.com/5421717/whocrashed-explains-why-your-windows-pc-crashed
- http://lifehacker.com/5421752/18-extensions-worth-downloading-from-google-chromes-gallery
- http://lifehacker.com/5421651/chrome-extensions-gallery-officially-opens
And the fun continues on Thursday...
- http://gizmodo.com/5422712/iclassic-app-lets-you-revist-the-good-old-days-of-click-wheel-ipods
- http://gizmodo.com/5422667/the-first-official-poster-screenshot-and-synopsis-of-tron-legacy
- http://lifehacker.com/5422647/speed-tracer-diagnoses-where-your-web-sites-slowing-down
And the end of another week rolls around...
Wednesday, December 02, 2009
Debugging Tools And Fun, Erm...
Some useful links if you're trying to find web dev debug tools:
- TinyGet, for automated page requests: http://code.google.com/p/toolsdotnet/wiki/TinyGet
- WFetch (like TinyGet but with a GUI): http://support.microsoft.com/kb/284285
- The IIS6 resource toolkit: http://support.microsoft.com/kb/840671 (contains tinyGet & WFetch)
- A handy link on StackOverflow which should provide inspiration: http://stackoverflow.com/questions/1369829/how-to-debug-an-asp-net-applicaiton-on-live-server
Of course, deploying your DLLs in debug mode can help your logging, but release mode is going to provide at least 4x performance improvements. If you attach a profiler for checking memory usage or performance, you can leave your .pdb files up to get more information as these contain the .NET symbols used for inspecting the code. Please don't leave them there, as they are a serious security consideration - in short, if a hacker were to copy your pdb files from your server they've effectively stolen everything but the source code:
Here's some profilers that don't involve installing Visual Studio on a live server (always a bad idea):
- DotTrace (won't memory profile .NET1.1): http://www.jetbrains.com/profiler/index.html
- Red-Gate Developer Bundle (plus separate downloads): http://www.red-gate.com/products/dotnet_tools_overview.htm
- Red-Gate's SQL bundle: http://www.red-gate.com/products/sql_bundles/SQL_Comparison_Bundle.htm
- DynaTrace (I've not checked this out yet): http://www.dynatrace.com/en/
- Ipcas SpeedTrace (or this): http://www.ipcas.com/trace-and-profile/c-sharp-and-vb.net-tracer-and-profiler/
There are, of course, sites out there for providing information about your site:
- Repeatedly tests your site: http://www.siteconfidence.co.uk/
- Multi-browser testing: http://www.browsera.com/ via: http://lifehacker.com/5414998/browsera-simultaneously-tests-your-site-in-different-browsers
- Installed on your network, provides processor information: http://www.zabbix.com/
Of course, if you're intent on debugging in Firefox (www.firefox.com, of course) you should have:
- Firebug: https://addons.mozilla.org/en-US/firefox/addon/1843
- Firebug javascript debugging: http://getfirebug.com/js.html
Some tools for developing your code (essentially, my favourites, as there are tonnes, Microsoft's list notwithstanding (http://msdn.microsoft.com/en-us/magazine/cc300497.aspx)):
- Beyond Compare, the best comparison tool anywhere: http://www.scootersoftware.com/
- SVN or CVS
- ViewState decoder: http://alt.pluralsight.com/tools.aspx
And a list of developer must-have's:
And finally, a handy selection from youtube:
And once you've done all that, make sure it's performant:
Tuesday, December 01, 2009
Gizmodo, Lifehacker, Best Of The Last Few Days
It's been a while coming, my blogging has been down, so here's some updatey wonderfulness...
- http://lifehacker.com/5415321/ten-alternatives-to-mininova
- http://gizmodo.com/5415675/gizmodos-essential-iphone-apps-november-09-edition
- http://lifehacker.com/5412886/61-free-apps-were-most-thankful-for
- http://lifehacker.com/5413889/bittorrent-tracker-mininova-goes-legal+only
- http://lifehacker.com/5414998/browsera-simultaneously-tests-your-site-in-different-browsers
- http://lifehacker.com/5414288/top-10-cross+platform-apps-that-run-on-windows-os-x-linux-and-more
- http://lifehacker.com/5413223/how-to-fix-your-relatives-terrible-computer
- http://lifehacker.com/5412754/wallpaper-roundup-abstract-ice-and-snowy-scenes/gallery/
- http://lifehacker.com/5412148/remains-of-the-day-the-declaration-of-google-wave-edition
- http://lifehacker.com/5411899/diagnose-and-protect-your-iphone-from-worms
- http://lifehacker.com/5415526/canyouseemeorg-checks-for-open-ports-behind-firewalls
- http://lifehacker.com/5415266/coffee-temporarily-assigns-primary-secondary-apps-for-files
Thursday, November 19, 2009
Dealing With Exceptions
Knowledgeable blogs on the subject of debugging, crashes, exceptions and dumps - good reading:
- http://blogs.msdn.com/tess/archive/2005/11/30/498297.aspx
- http://blogs.msdn.com/cbrumme/archive/2003/10/01/51524.aspx
- http://geekswithblogs.net/dbose/archive/2008/11/08/windbg--crash-dump-.-associated-headches---part-1.aspx
Grabbing the dump file and getting at the data from the dump:
Very useful links for debugging, including dump file cheat sheet and analysis check list:
- http://windbg.dumpanalysis.org/ (Generally a good site: http://www.dumpanalysis.org/)
Every developer's starting point when looking for debugging tools:
Page of links for Microsoft debugging tools:
At time of writing this is labelled "Install 32-bit version 6.11.1.404 [16.9 MB]"
And finally, why you should use try...catch...finally, or even try...finally:
Sunday, November 01, 2009
XSLT, XPath Knowledge Base
XPath explained and easy-to-use grid of descriptions...
Applying XSLT to XML in .NET...
Very useful XSLT scripts (including url encode/decode templates)...
A list of XSL elements and descriptions...
Parameters and variables in XSLT...
Writing an XSD document...
.NET 3.5 page on navigating XML in XPath...
Using XPath and LINQ...
D. Pawson, the God of XML...
Copying all elements except one...
Passing parameters to XSLT...
Copying text while converting escaped characters (3rd post down)...
Add CData section easily...
Lower-case in .NET (because it doesn't support XPath 2.0)...
Functions, including string manipulation...
Labels:
how to,
knowledge base,
links,
problem solved,
xml,
xpath,
xslt
Saturday, October 31, 2009
String.Reverse And Microsoft Interviews
A question which often comes up in interviews (and, I'm told, at Microsoft) is "write a method/function to reverse a string."
This, of course, isn't very difficult and lots of people get it wrong or give up. The following links are useful in getting the best answer, but really the best answer is how you work it out at the time. My opinion, though, is that the best answer is along the lines, "I'd look up some good examples and apply what I've learnt to the actual problem I have." This is appropriate simply because most people at work (especially when programming) are not in the firing line solving some real time James Bond type challenge and that there is usually a better solution created/invented/found by someone more intelligent/luckier somewhere in the world.
None of the points above are excuses for laziness or stupidity, however. Mostly, in my experience, points are gained by having experience and applying it well. Therefore;
- Come on, it's google: http://www.google.co.uk/search?rlz=1C1CHMB_en-GBGB316GB316&sourceid=chrome&ie=UTF-8&q=string+reverse
- Because String.Reverse doesn't exist in C#: http://www.123aspx.com/ReadReviews.aspx?res=617
- A good internal for a reverse function: http://weblogs.sqlteam.com/mladenp/archive/2006/03/19/9350.aspx
- Microsoft Interviews: http://en.wikipedia.org/wiki/Microsoft_interview
It's also worth noting that:
string reversed = forwardStr.Reverse();
does not work. See link above.
[EDIT]
I'll include some extra links here, found recently while pondering the current state of affairs in the world. It's interesting to note that (it seems) a large number of interviews think that some (alleged) programmers are not, in fact, programmers...
Monday, October 19, 2009
Roundup: Week Ending 16/10/09
Hmmm...
- http://gizmodo.com/5379973/studio-raises-price-of-iphone-app-to-40-to-shut-whiners-up
- http://gizmodo.com/5379890/dyson-air-multiplier-review-making-a-300-fan-takes-cojones
- http://gizmodo.com/5379887/now-this-is-how-the-iphone-should-handle-multitasking
- http://lifehacker.com/5378494/five-best-windows-task-manager-alternatives
- http://lifehacker.com/5377878/datamasher-serves-up-government-data-on-a-map
- http://lifehacker.com/5378075/printliminator-quickly-easily-makes-any-page-printer-friendly
- http://gizmodo.com/5378719/yamaha-quietly-shows-off-1mm+thick-cloth-speaker
- http://lifehacker.com/5380470/onlineocr-converts-your-scanned-documents-to-editable-text
- http://gizmodo.com/5381846/androids-best-augmented-reality-app-hits-the-iphone
- http://lifehacker.com/5383186/nominate-walkable-spaces-for-the-street-view-trike
- http://lifehacker.com/5383351/flagtab-groups-your-firefox-tabs-with-colors
- http://lifehacker.com/5383526/manage-your-google-reputation
- http://lifehacker.com/5384381/app-of-the-day-rotates-highly+voted-iphone-apps
- http://gizmodo.com/5384304/theres-retail-markup-and-then-theres-canadian-windows-7
- http://gizmodo.com/5384249/nasa-moon-bombing-mission-may-have-worked-out-after-all
- http://gizmodo.com/5383799/an-asteroid-could-have-killed-us-tonight
And the not-gizmodo not-lifehacker...
Sunday, October 18, 2009
System32 Always Opening! Argh!
I've had this infuriating event happening every time I log into Windows. The Windows\System32 directory keeps opening up in Windows Explorer, every single time, just after I log in. This didn't used to happen, is really annoying and just highlights how crappy Windows can be.
Fortunately, there's a solution - even Microsoft know about this. And it's weird. My initial google search on this brought back this handy little site:
Which lead me to this Microsft knowledge base article:
Which lead me to opening the registry editor (Start -> Run -> regedit), following the path down the registry folders to:
- HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
And finally deleting the entry for "MultiScreen", which had a value of " ". Like I said; Weird.
Anyway, this seems to have solved the problem. Why there is code somewhere inside Windows which opens the System32 directory when you log in if there is an invalid registry entry is beyong me, but at least it's fixed now.
Labels:
explorer,
links,
operating system,
problem solved,
system32,
windows
Thursday, October 15, 2009
How To Capture Page Output, Caching
Found this on the net, while trying to capture the rendered output of a page...
Only takes a little modifying to adjust to writing to disc. In .NET2.0 and above you can use the File.WriteAllText to dump out your html file and easily implement disc caching:
Wednesday, October 07, 2009
Roundup: Gizmodo, Lifehacker For Week Ending 09/10/09
The first roundup of my favourite Gizmodo and Lifehacker posts (they may have linked off elsewhere...):
- http://lifehacker.com/5375727/remains-of-the-day-the-most-popular-hotmail-password-edition
- http://googleblog.blogspot.com/2009/10/what-is-browser.html
- http://lifehacker.com/5375549/arora-is-an-open+source-browser-with-out+of+the+box-ad-blocking
- http://lifehacker.com/5375469/stdu-viewer-is-an-impressive-tabbed-document-reader
- http://lifehacker.com/5375325/an-exhaustive-guide-to-saving-your-smartphones-battery
- http://lifehacker.com/5375184/use-google-voice-voicemail-without-changing-numbers
- http://gizmodo.com/5374876/windows-mobile-65-review-theres-no-excuse-for-this
- http://gizmodo.com/5375913/the-iphone-app-store-gold-rush-may-be-running-low-on-gold
- http://gizmodo.com/5375860/explore-the-new-york-city-which-couldve-been-with-the-phantom-city-iphone-app
- http://gizmodo.com/5375703/a-truck-drivers-baseball-cap-could-be-the-difference-between-life-and-death
- http://gizmodo.com/5375600/how-to-best-a-master-lock
- ...
Monday, October 05, 2009
Roundup: OCR, LifeHacker, Gizmodo And The iPhone, For The Week
This week's latest...
- http://gizmodo.com/366573/skywalker-last-supper-painting-made-with-69550-star-wars-frames
- http://gizmodo.com/5373262/transformers-3-gets-super-official-will-explode-july-2011
- http://gizmodo.com/5372760/parody-wetas-special-effects-technology-creates-green-screen-boobage
- http://gizmodo.com/5373308/the-week-in-iphone-apps-the-beautiful-game
- http://lifehacker.com/5373720/floating-monitors-and-hidden-peripherals
- http://lifehacker.com/5372743/talking-rss-reader-does-just-what-it-sounds-like
- http://lifehacker.com/5372388/never-leave-things-at-a-friends-house-again
- http://lifehacker.com/5373263/this-weeks-most-popular-posts
- http://lifehacker.com/5371489/google-wave-invites-is-a-web-site-dedicated-to-sharing-wave-invites
- http://lifehacker.com/5372894/wallpaper-roundup-retro-video-games-as-awesome-3d-pixel-art/gallery/
- http://lifehacker.com/5373075/google-removes-pirate-bays-front-page-from-search-results
- http://lifehacker.com/5373034/tweak-quick-look-to-see-what-files-are-inside-a-folder
- http://lifehacker.com/5372011/tineye-adds-reverse-image-lookup-to-firefox
- http://lifehacker.com/5372987/two+minute-video-makes-a-lot-of-sense-of-google-wave
- http://lifehacker.com/5372853/the-first-google-wave-search-you-must-know
- http://lifehacker.com/5372011/tineye-adds-reverse-image-lookup-to-firefox
- http://lifehacker.com/5371943/flickroom-enables-desktop-browsing-of-flickr
- http://lifehacker.com/5370537/dropbox-comes-to-the-iphone-and-ipod-touch
- http://lifehacker.com/5370027/use-google-docs-to-convert-images-to-text
- http://gizmodo.com/5370667/200-starlings-hitting-aircraft-engine-on-take-off
- http://gizmodo.com/5370586/nasa-can-now-create-objects-using-electron-beams
- http://gizmodo.com/5370652/remainders-+-things-we-didnt-post/gallery/
- http://gizmodo.com/5370278/alk-copilot-gps-navigation-app-gets-iphone-keyboard-text+to+speech-other-improvements
- http://gizmodo.com/5370493/apple-genius-bar-iphones-30-call-drop-is-normal-in-new-york
- http://gizmodo.com/5370446/why-iphone-tv-apps-are-doomed-to-mediocrity
Wednesday, September 30, 2009
Useful, Popular And Commonly Required MSDN Pages
Just thought a collection of these would be good. I'll try to keep it updated...
Tuesday, September 29, 2009
LifeHacker, Gizmodo And More...
Yeah, they're horrible, but some people still, erm, love them...
Um.
Aaanywaaay...
- http://gizmodo.com/5369498/foreign-airlines-rushing-to-offer-in+flight-cell-service-keep-it-out-of-america-please
- http://gizmodo.com/5369678/ping-is-like-a-free-sms-client-for-iphone-and-ipod-touch-users
- http://lifehacker.com/5369299/tap-and-hold-to-prevent-iphone-photo-rotation
- http://lifehacker.com/5369298/serviceseditor-makes-resetting-and-tweaking-windows-services-simple
- http://lifehacker.com/5369452/vlc-issues-security-update-support-for-64+bit-os-x
- http://lifehacker.com/5369267/auto-shutdown-lets-you-schedule-tasks-upon-download-completion
Monday, September 28, 2009
Latest Best From LifeHacker Gizmodo
LifeHacker...
- http://lifehacker.com/5367236/remains-of-the-day-microsoft-says-chrome-makes-ie-less-secure-edition
- http://lifehacker.com/5367793/create-your-own-usb+powered-gadgets
- http://lifehacker.com/5367392/techtracker-scans-your-computer-for-outdated-software
- http://lifehacker.com/5367801/hide-read-labels-declutters-your-gmail-sidebar
- http://lifehacker.com/5323369/xpize-polishes-windows-xps-interface
- http://lifehacker.com/5368294/top-10-ways-to-get-more-from-a-cameraphone
- http://lifehacker.com/5366172/use-apples-to-extend-the-shelf-life-of-cakes
- http://lifehacker.com/5368817/five-best-twitter-clients
GizModo...
- http://gizmodo.com/5368149/microsoft-getting-cleverer-and-cleverer-with-new-multitouch-screen-keyboard
- http://gizmodo.com/5368680/best-use-of-sms-technology-yet-includes-boobs-of-course
- http://gizmodo.com/5367749/7-gadgets-that-will-make-your-life-easier-at-airports/gallery/?skyline=true&s=x
- http://gizmodo.com/5368065/the-week-in-iphone-apps-happy-mms-day-everyone
Tuesday, September 22, 2009
Monday, September 21, 2009
Properly Handling CDATA In .NET XSLT
Prologue:
I have a T-SQL table of data, one field of which contains escaped X/HTML - that is, it has XHTML where the important characters, like < and >, are represented as < and > etc. Some of this XHTML is broken because the writer was probably using a rich-text editor which sent fragments of XHTML to the database. Of course, using SQLXML to pull this out I find that the body of some of the elements contains this escaped HTML. So now I need to unescape it back into normal HTML, so it can be rendered on a page without hassle, but without making it part of the XML document.
Sumary:
Ok, so, in summary, we have valid XML with escaped XML (or XHTML) which needs to be wrapped sensibly so it's not mixed up and we need to do this in .NET.
First problem:
Unescaping the code, in XSLT, is a little tricky, but if you assume every element which needs unescaping is the same, then we can do this:
<xsl:template match="Description">
<xsl:copy>
<xsl:value-of select="node()" disable-output-escaping="yes" />
</xsl:copy>
</xsl:template>
What this does is match every element named 'Description' in the original XML and unescape it's content - so code like < and > become < and >. Simple. If you want to do that for specific elements only, just move the 'value-of' XSL element to where you want it.
Second problem:
We now have XML containing some more XML, which should really be considered plain text, until it's needed. So, we want to keep this 'inner XML' as it is (ie: pretty XML and not escaped) but indicate that it's not part of the current XML document.
Second solution:
Wrap the body content of the elements we want to remain as body content in a CDATA tag, like this:
<xsl:template match="Description">
<xsl:copy>
<![CDATA[<xsl:value-of select="node()" disable-output-escaping="yes" />]]>
</xsl:copy>
</xsl:template>
What the CDATA block does is tell any parsers that the content is to be, essentially, ignored. Simple.
Unfortunately, the CDATA block tells the parser not to parse the content within it, so what we actually end up with is:
<Description>
<![CDATA[<xsl:value-of select="node()" disable-output-escaping="yes" />]]>
</Description>
Third problem:
If you just add the CDATA block to your XSLT a standard parser will take the XSL element within it as to be ignored, and not process it.
Third solution:
The answer to this is not to include the CDATA block ourselves, but to tell the XSLT document which elements need to contain the CDATA block, instead. Thus, the XSLT parser will wrap them itself. We do this by adding the 'cdata-section-elements' attribute to the output element of the XSLT document:
<xsl:output method="xml" indent="yes" cdata-section-elements="Description" omit-xml-declaration="yes" />
Now, every <Description> element, in the output XML, will contain a CDATA block which wraps the body content of the element, like this:
<Description>
<![CDATA[<strong>Some content that was parsed from the value-of XSL element.</strong>]]>
</Description>
However, if you have been trying this as we go along and seeing something different - ie, it's not working for you - that's because, in .NET, you have to handle XSLT in a certain way.
The short answer is, here's the C# to do it:
/// <summary>
/// Takes a string containing XML to be parsed and a string containing the the XSLT to do the parsing.
/// </summary>
public string NewTransform(string xml, string xsl)
{
// create the readers for the xml and xsl
XmlReader reader = XmlReader.Create(new StringReader(xsl));
XmlReader input = XmlReader.Create(new StringReader(xml));
// create the xsl transformer
XslCompiledTransform t = new XslCompiledTransform(true);
t.Load(reader);
// create the writer which will output the transformed xml
StringBuilder sb = new StringBuilder();
XmlWriter results = XmlWriter.Create(new StringWriter(sb), t.OutputSettings);
// write the transformed xml out to a stringbuilder
t.Transform(input, null, results);
// return the transformed xml
return sb.ToString();
}
/// <summary>
/// Takes an absolute path to a file which is then loaded into a string and returned.
/// </summary>
public string LoadFileAsString(string fullpathtofile)
{
using (var sr = new StreamReader(fullpathtofile))
return sr.ReadToEnd();
}
The key to ensuring that the cdata-section-elements attribute, and therefore the CDATA block, is handled correctly is the t.OutputSettings - passing the settings to the writer informs it of the intentions of the XSL transformer.
Epilogue:
I battled with all of the above until I stumbled upon this post, so thank you to everyone there:
I have a T-SQL table of data, one field of which contains escaped X/HTML - that is, it has XHTML where the important characters, like < and >, are represented as < and > etc. Some of this XHTML is broken because the writer was probably using a rich-text editor which sent fragments of XHTML to the database. Of course, using SQLXML to pull this out I find that the body of some of the elements contains this escaped HTML. So now I need to unescape it back into normal HTML, so it can be rendered on a page without hassle, but without making it part of the XML document.
Sumary:
Ok, so, in summary, we have valid XML with escaped XML (or XHTML) which needs to be wrapped sensibly so it's not mixed up and we need to do this in .NET.
First problem:
Unescaping the code, in XSLT, is a little tricky, but if you assume every element which needs unescaping is the same, then we can do this:
<xsl:template match="Description">
<xsl:copy>
<xsl:value-of select="node()" disable-output-escaping="yes" />
</xsl:copy>
</xsl:template>
What this does is match every element named 'Description' in the original XML and unescape it's content - so code like < and > become < and >. Simple. If you want to do that for specific elements only, just move the 'value-of' XSL element to where you want it.
Second problem:
We now have XML containing some more XML, which should really be considered plain text, until it's needed. So, we want to keep this 'inner XML' as it is (ie: pretty XML and not escaped) but indicate that it's not part of the current XML document.
Second solution:
Wrap the body content of the elements we want to remain as body content in a CDATA tag, like this:
<xsl:template match="Description">
<xsl:copy>
<![CDATA[<xsl:value-of select="node()" disable-output-escaping="yes" />]]>
</xsl:copy>
</xsl:template>
What the CDATA block does is tell any parsers that the content is to be, essentially, ignored. Simple.
Unfortunately, the CDATA block tells the parser not to parse the content within it, so what we actually end up with is:
<Description>
<![CDATA[<xsl:value-of select="node()" disable-output-escaping="yes" />]]>
</Description>
Third problem:
If you just add the CDATA block to your XSLT a standard parser will take the XSL element within it as to be ignored, and not process it.
Third solution:
The answer to this is not to include the CDATA block ourselves, but to tell the XSLT document which elements need to contain the CDATA block, instead. Thus, the XSLT parser will wrap them itself. We do this by adding the 'cdata-section-elements' attribute to the output element of the XSLT document:
<xsl:output method="xml" indent="yes" cdata-section-elements="Description" omit-xml-declaration="yes" />
Now, every <Description> element, in the output XML, will contain a CDATA block which wraps the body content of the element, like this:
<Description>
<![CDATA[<strong>Some content that was parsed from the value-of XSL element.</strong>]]>
</Description>
However, if you have been trying this as we go along and seeing something different - ie, it's not working for you - that's because, in .NET, you have to handle XSLT in a certain way.
The short answer is, here's the C# to do it:
/// <summary>
/// Takes a string containing XML to be parsed and a string containing the the XSLT to do the parsing.
/// </summary>
public string NewTransform(string xml, string xsl)
{
// create the readers for the xml and xsl
XmlReader reader = XmlReader.Create(new StringReader(xsl));
XmlReader input = XmlReader.Create(new StringReader(xml));
// create the xsl transformer
XslCompiledTransform t = new XslCompiledTransform(true);
t.Load(reader);
// create the writer which will output the transformed xml
StringBuilder sb = new StringBuilder();
XmlWriter results = XmlWriter.Create(new StringWriter(sb), t.OutputSettings);
// write the transformed xml out to a stringbuilder
t.Transform(input, null, results);
// return the transformed xml
return sb.ToString();
}
/// <summary>
/// Takes an absolute path to a file which is then loaded into a string and returned.
/// </summary>
public string LoadFileAsString(string fullpathtofile)
{
using (var sr = new StreamReader(fullpathtofile))
return sr.ReadToEnd();
}
The key to ensuring that the cdata-section-elements attribute, and therefore the CDATA block, is handled correctly is the t.OutputSettings - passing the settings to the writer informs it of the intentions of the XSL transformer.
Epilogue:
I battled with all of the above until I stumbled upon this post, so thank you to everyone there:
Friday, September 18, 2009
Thursday, September 17, 2009
Augmented Reality On The iPhone
Well, I've finally found something cool, useful and right here, right now...
I found this via the original link...
Now, signing up (free, easy and quick) to the iPhone app Yelp, gives you something very useful: Switch on Monocle (shaking the iPhone isn't necessary any more - I discovered too late!) and it'll show you which restaurants, bars, etc are in the direction your phone is facing. It's that easy to find places. Tapping the screen takes you to the contact information and from there the world is yours!
Yes, I'll say it again, I'm in love with the iPhone. Well done Apple - and all the enterprising developers out there making the best use of a very good gadget!
Space Photos On A Budget
Recently, some MIT students took their own photos of the Earth's curve...
- Space photos for less than $200 http://www.wired.com/gadgetlab/2009/09/the-150-space-camera-mit-students-beat-nasa-on-beer-money-budget/
- Project Icarus – the cheap space camera project http://space.1337arts.com/
- Balloon trajectory forecasts http://weather.uwyo.edu/polar/balloon_traj.html
- The Kármán Line http://en.wikipedia.org/wiki/Kármán_line
- NASA Astronaut Wingshttp://en.wikipedia.org/wiki/Astronaut_wings#NASA_Astronaut_Pins
- Apollo 1 http://en.wikipedia.org/wiki/Apollo_1
Wednesday, September 16, 2009
Make Sure Your IIS Uses The Correct .NET Version - Unrecognized attribute 'type'
Recently, I created a new .NET 3.5 web site in VS2008 and started getting this error:
- Parser Error Message: Unrecognized attribute 'type'.
This page helped me here:
Essentially, the problem is that IIS must be configured to use the correct version of .NET to run the site. Therefore, I opened the IIS panel "properties" for my site, clicked the ASP.NET tab and switched the version from .NET 1 to 2 and everything was fine.
Point IIS to .NET 2 even for .NET 3.5 web apps.
So, yes, the issue was I was using the wrong version of .NET to run my website. D'oh!
Lifehacker Fun
LifeHacker fun...
- http://lifehacker.com/5093536/gmail-updates-its-look-adds-themes
- http://lifehacker.com/5360150/install-snow-leopard-on-your-hackintosh-pc-no-hacking-required
- http://lifehacker.com/5359986/google-chrome-3-brings-more-speed-and-features-to-the-stable-release
- http://lifehacker.com/5359789/choose-which-app-opens-for-each-camera-in-snow-leopard
- http://lifehacker.com/5359335/google-fast-flip-gives-a-print-look-and-feel-to-google-news
- http://lifehacker.com/5359025/mms-for-iphone-begins-slow-rollout
Wednesday, September 09, 2009
iPhone Problems And Solutions
Well, I love the iPhone, but like any device it's not perfect. Ok, I've not found anything that isn't pretty much perfect (built by Apple, at least) but having found my first problem, hopefully here's some solutions, some generally useful links follow...
- Unsent email won't send. A sent email fails to appear in the "Sent" folder and the message "1 unsent email" displays at the bottom of the mail application.
For me, this resolved itself, I assume by finally managing to send. Here is a useful link related to the issue:
http://support.apple.com/kb/TS1426?viewlocale=en_US
Generally useful links to be aware of:
- http://manuals.info.apple.com/en/iPhone_User_Guide.pdf
- http://www.hackint0sh.org/
- http://forums.macrumors.com/forumdisplay.php?f=109 "Tips, Help and Troubleshooting forum"
Sunday, September 06, 2009
Loving Up The iPhone
Finally made the switch from a dying T-Mobile Windows Mobile MDA Vario II, to the 16GB iPhone 3GS and it's awesome! This thing completely surpasses all expectations in performance, usability, speed and sheer number of applications available - there are far more applications than for Windows Mobile and they are so easy to get. The addictive nature of downloading to the iPhone, I think, would compare to the discovery of P2P file sharing.
Anyway, I was disappointed when I discovered (yes, lots of this is new to me) that I can't just dump files onto the iPhone like I can with the iPod (using it as an external HD, for example) or that ringtones cannot be selected from any music on the device. I did, though, find a very good page with instructions on how to do this. Originally written, then tidied up, for the iPhone 3G, this page is accurate for 3GS as the method is fairly generic;
In short, it goes like this:
- Get an audio file and edit to around 20-30 seconds
- Save as MPEG-4 (.m4a - see WavePad for easy converting)
- Change file extension to .m4r
- Drop into the Ringtones section of iTunes
- Sync Ringtones to your iPhone
The ringtones will now be available in the Sounds section of you iPhone's settings. Easy. There is more detail on the above link and a pointer to the http://audiko.net/ site for even easier conversions, but manual conversion was my preference (and is really very easy.)
WavePad is available here:
On the other side of the coin, we have videos for the iPhone. As with iPod and iPod Touch, there are plenty of videos to purchase or stream (iPhone comes with a YouTube app) but what if you have a load of wmv's or avi's you want to just dump there? I would get the iPod/iPhone video converter Videora because it has all the "want that one" simple functions that you could need, while being fast and producing quality output. Then it's simply a case of syncing your iPhone to your videos (videora can auto-add conversions to iTunes' library or you can manually drop them onto the phone) to make them play on the iPhone.
Red Kawa, the makers of Videora, even have easy-to-use apps for making wallpapers for the iPhone, but with the wallpaper selector built in, I don't think those are necessary.
Tuesday, September 01, 2009
Friday, August 21, 2009
Equals Equals Vs. Equals
Recently I was asked, "What's the difference between 'a == b' and 'a.Equals(b)'. The short answer is that the second is a method call (easily overridden) and the first is not. While this is true, it's not the whole truth.
The real answer breaks down into two parts. First, for value types such as int, bool and float, the '==' is a direct comparison - it does compare the value of a and b. This is also true for 'string's, though these are a special case. For value types the '.Equals()' also compares the value of a and b because every value type can be treated as though it is boxed - .NET implicitly allows the class methods and properties to be called on their value type siblings.
For reference types - those created from classes, such as String, Int32, MyCarClass etc - the value comparison '==' cannot be called because an instance of a class is not the most primitive type of data the system can work with (in fact, Java calls value types 'primitives'.) In this case, the class must provide an 'Equals()' method - and every class does because all classes inherit from Object. However, because the default implementation (from Object) of 'Equals()' is to compare the references (ie: memory address value, not the data contained at that address), if 'Equals()' is not overridden you might find that two objects with the same value return false from Equals().
All the classes representing value types provide the appropriate Equals method (in that they all compare the value and not the reference of the object.) But for your own classes you must override Equals and provide your own implementation - because .NET does not implicitly know how to compare instances of your own classes. (It is possible to write reflection code which can do this, but it is long, difficult and prone to infallibility, so don't do it - unless you fancy a learning challenge ;)
So, in short (but not as short as earlier) the guide is:
For int: == compares the value, .Equals() compares the value (this is the .Equals() in Int32).
For Int32: == compares the value by calling the .Equals() in the Int32 class, .Equals() compares the value.
For MyInt32: == compares the references of the variables, .Equals() calls the method in your MyInt32 class.
If you want the '==' operator to perform a value comparison on instances of your own classes, you can use the 'operator' keyword and define your own '==' functionality;
For example, in a class called 'MyClass', if you have a working 'Equals()' method:
public static bool operator ==(MyClass a, MyClass b)
{
return a.Equals(b); // or whatever comparison you want to do
}
Another site with some code:
- http://tipsandtricksondotnet.blogspot.com/2009/08/difference-between-aequalsb-and-b.html
- Try googling it, there's lots out there and the MSDN certification 70-536 training material has lots of insight into C# which every .NET developer should know.
Thursday, August 20, 2009
Tuesday, August 11, 2009
I'm Back, And It's Ok
Thought I would just post something that might be of use to anyone trying to get back-end (or "code-behind") code working inside the ASPX or ASCX of their control - this can be useful to avoid having to do a full code release or if the page/control is dynamically loaded, say from a DB or plain text...
Isn't that great? Just a script block with runat=server and you're done.
This might also be useful:
Run along now, you're done.
Tuesday, July 21, 2009
Swapping Two Numeric Variables In Only Three Instructions
Having done this in the past, needing it again and finding this page:
I've found that two numerics can be swapped quite easily without the use of a third variable:
a = a + b
b = a - b
a = a - b
b = a - b
a = a - b
Neat.
Monday, July 20, 2009
Thursday, July 16, 2009
Wednesday, July 08, 2009
Google OS - What's To Come? Goose?
Google have announced that they plan to start building an Operating System. This should be fairly exciting for anyone who mildly doesn't like Windows and is free to start using another system. Also, exciting for anyone who isn't, but also believes that the new GOS (Can we start calling it 'Goose' yet? Too soon?) will be compatible enough to allow easy migration. As a .NET developer myself, I'm doubtful. The only reason that I stayed with Windows Mobile on the smartphone was simply because I could write my own apps for it. Now I've not done that in a dog's age, I'm switching to iPhone ASAP! Android, I'm afraid, hasn't had a look-in. Sorry, it just looks too flimsy.
I guess the other question is that, what with a bunch of things that require Windows to be able to be installed, will all downloadable apps from Google be GOS-compatible right out of the barn?
- http://www.youtube.com/google
- http://googleblog.blogspot.com/2009/07/introducing-google-chrome-os.html
- http://technology.timesonline.co.uk/tol/news/tech_and_web/article6665703.ece#cid=OTC-RSS&attr=1063742
- http://pack.google.com/intl/en-gb/pack_installer.html
- http://timesonline.typepad.com/technology/2009/07/google-chrome-os-its-a-really-really-big-deal-honest.html
- http://fakesteve.blogspot.com/2009/07/lets-all-take-deep-breath-and-get-some.html
That last link is something cool from Google - a collection of free and useful things (not all Google products) ready for download, something most will consider required installs for clean machines.
Tuesday, July 07, 2009
Social Things
Feel like I should read up on some of these social network and web 2.0 marketing issues of the day...
- http://www.chrisbrogan.com/19-presence-management-chores-you-could-do-every-day/
- http://www.time.com/time/business/article/0,8599,1902604,00.html
- http://www.searchenginepeople.com/blog/the-6-spheres-of-social-media-marketing.html
- http://web2.socialcomputingjournal.com/the_evolving_web_in_2009_web_squared_emerges_as_web_20_mai.htm
Monday, July 06, 2009
Canonical Tagging - SEO
Google, Microsoft and Yahoo can agree on one thing:
It's a good idea to be able to identify the original ('canonical' - http://dictionary.reference.com/browse/canonical)
Thursday, July 02, 2009
Lifehacker, Gizmodo And Interesting Links Of The Day
Some unusual stuff today...
- http://gizmodo.com/5305827/papercraft-castle-is-more-gorgeous-and-intricate-than-most-real-castles
- http://lifehacker.com/5304800/google-voice-is-cool-but-do-you-need-it
- http://gizmodo.com/5305791/smoking-booth-concept-uses-wall-of-air-to-make-smokers-feel-like-real-people
- http://gizmodo.com/5305574/michael-jackson-thriller-headphones-have-dual-meanings-now/gallery/
- http://gizmodo.com/5305571/giz-explains-how-to-choose-the-right-graphics-card
- http://gizmodo.com/5305551/gdgt-the-data-driven-gadget-site-is-live
- http://gizmodo.com/5305501/matte-black-macbook-pro-looks-like-a-deadly-stealth-ship/
- http://gizmodo.com/5305500/bono-gets-laser-jacket-public-probably-gets-eye-damage
- http://io9.com/5305769/more-augmented-reality-software-that-will-change-the-future
- http://lifehacker.com/5305094/how-to-crack-a-wi+fi-networks-wep-password-with-backtrack
- http://lifehacker.com/5304572/firefox-35-officially-available-for-download
Labels:
art,
augmented reality,
firefox,
gizmodo,
graphics cards,
lifehacker,
links,
security,
tech,
wifi
Wednesday, July 01, 2009
Tuesday, June 30, 2009
Tweet Buffer: Twuffer
Hmm, I quite like this idea, simply because it's a neat utilisation of twitter which you might think should have been part of the original web app (twitter) but is just a sensible extension - and a good example of third party expansions to open API's:
Creating A Shortcut To Open Current File In Explorer From Visual Studio
Here's a neat little item that most people won't know about in Visual Studio 2008 - opening the directory of the current file in windows explorer:
Monday, June 29, 2009
Local And Global Temporary Tables In SQL Server
Some good information for those wishing to create temp tables in their stored procs...
It seems that CREATE TABLE #tablename is very local, however ## is not so local after all...
It seems that CREATE TABLE #tablename is very local, however ## is not so local after all...
Thursday, June 25, 2009
Tuesday, June 23, 2009
Monday, June 22, 2009
Google Feeds - Why RSS Should Be Embraced
Well, having previously thought Google didn't like to provide RSS feeds (you can see the content essentially being stolen) here's how they decided to implement it:
Or, for broader information try:
If you want to filter and perform cool things with your feeds (or any feed) Yahoo Pipes can help, or Feed Informer:
It's Done. And I'm Shattered.
Well, thankyou to everyone who has (or will have) sponsored me for yesterday - you can now hit me up at http://original.justgiving.com/matthewwebster/
You can check out my tweets at #londonbrighton or http://www.twitter.com/horacebury and my photos at http://www.twitpic.com/photos/horacebury
Sunday, June 21, 2009
London To Brighton Bike Ride For BHF
I would like to remind everyone that you can sponsor me for the London to Brighton (58 mile) bike ride on June 21, 2009: http://www.justgiving.com/matthewwebster
I really appreciate any and all sponsorship I can get.
If you want to take part, please visit BHF's website where, for the first year ever, you can sign up online: http://www.bhf.org.uk/
Friday, June 19, 2009
Too Awesome For Words...R2
http://www.wired.com/video/latest-videos/latest/1815816633/10000-fully-functional-r2d2/24892334001
R2-D2 droids for sale - $10,000 each.
Weirdness Abounds, Links An That...
I don't know what to say, just enjoy...
- http://lifehacker.com/5293823/heatmapper-helps-you-create-a-detailed-signal-strength-map
- http://lifehacker.com/5294758/feedstitch-combines-multiple-feeds-into-one
- http://lifehacker.com/software/feeds/geek-to-live--create-your-master-%20feed-with-yahoo-pipes-235726.php
- http://lifehacker.com/5295624/get-better-real+time-twitter-search-results-by-blocking-retweets
- http://gizmodo.com/5295656/microsoft-security-essentials-antivirus-software-codename-morro-available-on-june-23rd
- http://gizmodo.com/5296046/good-god-even-the-commodore-64-has-a-twitter-client
- http://gizmodo.com/5295987/myvibe-thighs+on-first-iphone-vibrator-app-approved-by-apple-nsfw
- http://www.tuaw.com/2009/06/18/diorama-will-tilt-your-mind/
Ok, so iPhone vibrators, MS do real security and feed stitching. It's all out there...
And the vid from the last link...
Wednesday, June 17, 2009
Today's Linked Fun, Augmented Reality
Movies, augmented reality Transformers and that...
- http://gizmodo.com/5292550/futuristic-movie-timeline-the-next-few-decades-will-be-eventful
- http://gizmodo.com/5293164/you-too-can-wear-the-head-of-optimus-prime-in-augmented-reality-of-course
- http://gizmodo.com/5292748/layar-first-mobile-augmented-reality-browser-is-your-real-life-hud
- http://www.youtube.com/watch?v=pzB4mIPdm9k&feature=player_embedded
- http://lifehacker.com/5292890/nexus-dock-has-leopard+style-eye+candy-effects
Labels:
augmented reality,
autobots,
gizmodo,
links,
youtube
Monday, June 15, 2009
Pretending To Be Windows 7, Links An That...
From lifehacker and gizmodo, the usual, but with a Windows 7 tilt...
- http://lifehacker.com/5288408/viglance-converts-the-vanilla-taskbar-into-a-windows-7+like-superbar
- http://lifehacker.com/5289805/powerresizer-brings-windows-7s-window-sizing-to-all
More Google Wave...
Some advice for excel users...
And some photoshop help...
Labels:
gizmodo,
google,
google wave,
lifehacker,
links,
photoshop,
windows
Friday, June 12, 2009
An Interesting Piece Of Research On Weight Loss
This seems to back up the information about simply moving about more each day eating more healthy meals, rather than cutting down drastically and exerting yourself ridiculously, to be the key to successful weight loss:
Subversion Explained
This enterprising young chap has broken the Subversion (SVN) source code control and versioning system down for all us pro techy geeks...
Labels:
blogs,
code,
help,
links,
programming,
scc,
subversion,
tech,
tutorials
Windows 7 To Ship Without IE In Europe
Yep, finally, it's true and Opera's whinging has finally paid off. Sort of...
Or will they?...
If they do, here's how to get a browser you like without a browser to download it with...
Labels:
arstechnica,
browser,
firefox,
ie,
links,
microsoft,
news,
opera,
the register
Favourites From Salami Tsunami
Yes, it's true, Dusty Scott, aka Pork Tornado, aka Salami Tsunami, is the greatest blogger in the world...
- http://salamitsunami.com/archives/123 - Just Cuts It Off At The Base
- http://salamitsunami.com/archives/93 - Peachtree Flight Centre Website Support
- http://salamitsunami.com/archives/209 - TurboBitch 2001
- http://salamitsunami.com/archives/77 - I Hate Comcast
- http://salamitsunami.com/archives/198 - Choad Rage
Swearwords
If you want to block swearwords on your site, here's some resources. Things to think about are your intended audience, the seriousness of your site and how strict you want to be...
Power Save, Bread And Back To The Future II
Lifehacker and Gizmodo to the rescue, again...
- http://lifehacker.com/5287092/switch-power-management-plans-with-a-hotkey
- http://lifehacker.com/5287212/make-fresh+baked-bread-in-five-minutes?skyline=true&s=i
- http://gizmodo.com/5287023/savant-virtual-control-makes-a-touch-interface-out-of-every-room-in-the-house?autoplay=true
- http://gizmodo.com/5286994/buy-the-hat-from-back-to-the-future-part-ii
- http://gizmodo.com/5067047/back-to-the-future-ii-jacket-on-ebay
- http://gizmodo.com/397866/back-to-the-future-mcfly-sneakers-unboxed-going-for-2000
Thursday, June 11, 2009
Good Links That Are Good - Google Wave And More
Some links that are definately worth checking out...
- http://lifehacker.com/5285944/the-google-wave-highlight-reel *****
- http://lifehacker.com/5285831/mozilla-updates-firefox-add+ons-site-with-collections
- http://i.gizmodo.com/5286761/scientists-discover-superconducting-material-thats-just-two-atoms-thick
- http://i.gizmodo.com/5286709/star-radio-communicator-iphone-app-is-not-at-all-like-anything-from-star-trek
- Edit youtube videos: http://www.tubechop.com/
Labels:
firefox,
gizmodo,
google wave,
lifehacker,
links,
nano technology,
youtube
Saturday, June 06, 2009
Acorn Gamez - Reliving The Wonder
While getting a bit hacked off with a PC yesterday, I went looking for some videos from years gone by. I found some videos by a guy who really should be linked: http://www.youtube.com/user/peetvanpeebles
Subscribe to:
Posts (Atom)