Monday, May 9, 2011
Friday, February 4, 2011
PowerShell; download, parse, extract
Wrote my first powershell script and it finally clicked how it all ties together, and why I should spend a bit more time learning it. Generally when I need to do something quick and dirty I’ll fire up VS and create a console project or write a *.vbs script. Not anymore got a bit of love now for powershell just need to do it to “get it”.
Basically I wanted to download a webpage, parse it using a regex, then extract the named groups from the multiple matches, and finally output to a tab delimited text file. As I could not find a complete script that worked, I’m putting this one up, for others and for personal storage (as I’m likely to forget after the weekend).
$wc = New-Object System.Net.WebClient
$wc.Encoding = [System.Text.Encoding]::UTF8
$pagetext = $wc.DownloadString("http://www.cro.ie/ena/forms_s_se.aspx")
$matches = $pagetext | select-string -pattern "<strong>(?<form>.*?)</strong>(?<desc>.*?)</p>" -allmatches | %{$_.matches }
$extractedtext = $matches | %{ $_.groups['form'].value.trim() + "`t" + $_.groups['desc'].value.trim()}
add-content formtypes.txt $extractedtext
Friday, October 22, 2010
London .Net User Group: Open Mike Night
On Wednesday 20th October 2010 in organise an London .Net User Group (LDNUG) Open Mike Night.
Open Mike Night is a night to introduce new speakers to the community. Over the last year we have noticed not many new speakers coming through the ranks in LDNUG, this has been our own fault for not creating the arena for them to take to the stage.
There was 5 talks 10-15 minutes long on any topic related to been a developer. They all did very well, I know it is not easy as I was there once, my first talk was also a LDNUG 10 minute talk. So I wish them well on their journey and hope to see them presenting longer talks at bigger events!
Thanks you everyone for coming and making such an great night. I hope to see you at the next events and if you have any suggestions or questions please don’t hesitate to contact me.
Speaker details:
Talk: "Three years of running a Tiny software company.. All my mistakes.."
Name: James Knowles
Email: james@unwindsoftware.com
Twitter: http://twitter.com/unwindsoftware
Linkedin: http://uk.linkedin.com/in/unwindsoftware
Blog/website: http://blog.unwindsoftware.com/
Slide/code links: http://www.unwindsoftware.com/presentations/Three-years-of-running-a-Tiny-software-company.pptx
Talk: "Introduction to Sass"
Name: Garry Shutler
Email: garry@robustsoftware.co.uk
Twitter: http://twitter.com/gshutler
Linkedin: http://uk.linkedin.com/pub/garry-shutler/13/896/a98
Blog/website: http://www.robustsoftware.co.uk/
Slides: http://bit.ly/ldnugsassslides
Images: http://bit.ly/ldnugsassimages
Talk: "Pair programming, the good, the bad and the ugly"
Name: Sara Stephens
Email: sara@sarastephens.com
Twitter: http://twitter.com/developerdame
Linkedin: http://uk.linkedin.com/in/sarajstephens
Blog/website: http://www.developerdame.com/
Slide/code links: watch the blog
Talk: "Pair programming, the good, the bad and the ugly"
Name: Rachel Laycock
Email: rachellaycock@googlemail.com
Twitter: http://twitter.com/rachellaycock
Linkedin: http://uk.linkedin.com/in/rachellaycock
Blog/website: http://www.rachellaycock.com/
Slide/code links: watch the blog
Talk: "HTML5 basics"
Name: Robin Minto
Email: robin@minto.co.uk
Twitter: http://twitter.com/robinem
Linkedin: http://uk.linkedin.com/pub/robin-minto/22/496/799
Blog/website: http://robinminto.com/blog/
Slide/code links: http://robinminto.com/blog/2010/10/22/html5-basics-presentation/
Talk: "Cross platform mobile app development"
Name: Matt Lacey
Email: matt@mrlacey.co.uk
Twitter: http://twitter.com/mrlacey
Linkedin: http://uk.linkedin.com/in/mrlacey
Blog/website: http://blog.mrlacey.co.uk/
Slide/code links: http://blog.mrlacey.co.uk/2010/10/phonegap-at-ldnug.html
Main code is from www.phonegap.com
WP7 version is currently at www.github.com/mrlacey/phonegap-wp7
Next LDNUG Events:
Thursday 4th November 2010
Mads Torgersen from Microsoft will talk about C# 5. We will probably be the first people in Europe to present on it.
http://skillsmatter.com/event/open-source-dot-net/c-sharp-5
Thursday 18th November 2010
Sarah Taraporewalla (http://sarahtaraporewalla.com/) on Integration Points
This is still been organised so watch the mailing list for details
Other Events:
Saturday 22nd 2010
DeveloperDeveloperDeveloper! These FREE one day events build on the success of the previous DeveloperDeveloperDeveloper Days. As before, it is all about developers learning, sharing and interacting with each other in an informal and relaxed atmosphere.
http://developerdeveloperdeveloper.com/ddd8a/
Tuesday 26th October 2010
OpenSpaceBeers are a one hour open-space, organized in a pub, with an open bar, for all the creative juices of the IT community to come and reflect on their own practices.
http://openspacebeers.eventbrite.com/
If you could vote for Michelle Flynn as a way for thanking her for venue and beer that would be awesome. http://www.computerweekly.com/Articles/2010/10/20/243307/Vote-in-the-Computer-Weekly-IT-Blog-Awards-2010.htm
Thursday, February 4, 2010
DDD8: Introduction to Mono slides
Here are my slides from my talk at DDD8. Just like to say thank you to all who came, I know it was due to the John Skeet room been full :). Thanks for all the great questions, I really enjoy giving the talk this time, as last year I was terrified and don’t remember talking.
Friday, July 17, 2009
Visual Studio Fonts and Colours
I got tired of the colours in VS2008 so asked on twitter if anyone has some themes. Got a good response of links to themes.
Here are the main links I was sent:
Scot Hanselman’s Blog
http://www.hanselman.com/blog/VisualStudioProgrammerThemesGallery.aspx
Iain Holder’s Blog
http://tech-nous.blogspot.com/2008/10/visual-studio-2008-colour-schemes.html
Is your IDE Hot or Not
http://idehotornot.ning.com/
Mohamed Meligy
http://geekswithblogs.net/Mohamed/archive/2007/08/20/Dark-Visual-Studio-With-Resharper---My-VS-Settings-Colors.aspx
If you use ReSharper the normal settings people export don’t work correctly and you will have to do a lot of customisations yourself.
I based mine on Mohamed’s one and have done some changes, especially to XML and HTML views. I have found it much easier on my eyes and really enjoy it. So I thought I would share it with the interwebs.
Please remember these Fonts and Colours are for VS2008 + R#
Tools | Import and Export Settings | Import selected environment settings | Yes, save my current settings | Browse |VS2008R#Dark-FontsColours.vssettings | make sure it is importing Fonts and Colours only | Finish | Enjoy
Let me know if you like them.
Saturday, January 10, 2009
Windows 7 beta
After spending half a day fighting with MSDN subscriber downloads on the day of release on Thursday, anyone can now download it from http://www.microsoft.com/windows/windows-7/beta-ownload.aspx and give it a try. I of course had to test it out, see if the companies software I write installs and works on it ;). I fired up Windows 7 x86 in a Virtual Machine, I currently use VirtualBox which I think rocks ! about 35 minutes later it was done, install perfectly worked right off the bat. Runs a lot better than the Vista VMs I have and the only tweaking I had to do was use the Compatibility Troubleshooter to install the Guest Additions, but that was it.
Feeling confident with the new operating system I wipe my Dell XPS M1730 laptop and installed Window 7 x64 replacing my current Vista x64. It installed quickly ran and with no problems, only had to install the latest Nvidia drivers to get better resolutions, but then I had to do that on Vista too. You can pick Laptop Nvidia driver direct from Nvidia now and not the rarely update ones by laptop vendors. The rest of the hardware which was unknown after install was picked up by Windows update which was the Creative inbuilt laptop camera and the Ricoh Memory card reader. Been x64 bit I was a bit worried as Vista x64 half a year ago took me ages to get everything running and I really had to hunt around for the drivers, Windows 7 x64 just worked, nice.
It runs really well, it is slicker and snappier than Vista, it looks very much like Vista but the changes have made a huge difference. For a beta it is bloody good, well done Microsoft. Now to finish installing the useful software as TweetDeck won’t get any of my work done.
Tuesday, November 25, 2008
DDD7: How to develop .Net on Linux using Ubuntu distro
Wow, my first time presenting and a lot of panicking. I hope those who came enjoyed it, and now feel the world of Linux is a less scary place for us .Net developers.
Here is my presentation:
Every DDD session this year has been filmed; so if you missed it watch the DDD site for the video. Please also submit your feedback.
I will be doing a few posts on setting up Ubuntu and adding some addition content which I didn't have time to demonstrate.
Friday, October 10, 2008
"How to develop .Net on Linux using Ubuntu distro" now showing at DDD7
Thank you too everyone who voted for "How to develop .Net on Linux using Ubuntu distro" session at DDD7. Was not excepting this session to get chosen was hoping the WiX would be selected, if any at all. This is my first time speaking at DDD, or any large/medium event for that matter. So excited and very nervous at the same time, should be fun !
When: Saturday, November 22, 2008 - 9:00 to 17:00
Where: Microsoft, Thames Valley Park, Reading, Berkshire RG6 1WG, England
Watch out for registration as places go very quickly
Wednesday, September 3, 2008
DDD7 session voting now open
DeveloperDeveloperDeveloper! Day 7 which is been held on Saturday, 22nd November 2008 has now opened the voting for sessions to build the agenda for the day. I has submitted 3 sessions; How FIT are you ?, Introduction to Windows Installer XML (WiX) and How to develop .Net on Linux using Ubuntu distro. So please vote for me !
Friday, July 11, 2008
Alt.Net UK September Registration Open
The registration for the Alt.Net UK Conference is now open. For more information check out Ian Cooper's post Alt.Net UK September.
Friday, June 20, 2008
XSLT - javascript escaping
I could not find a way to do this without writing a template.
I started one then luckily through the power of the Internet found a better one. Done by Jeni Tennison found in the xsl-list archives and I have reproduce here.
<xsl:template name="escape-javascript">
<xsl:param name="string" />
<xsl:choose>
<xsl:when test='contains($string, "'")'>
<xsl:call-template name="escape-javascript">
<xsl:with-param name="string"
select='substring-before($string, "'")' />
</xsl:call-template>
<xsl:text>\'</xsl:text>
<xsl:call-template name="escape-javascript">
<xsl:with-param name="string"
select='substring-after($string, "'")' />
</xsl:call-template>
</xsl:when>
<xsl:when test="contains($string, '
')">
<xsl:call-template name="escape-javascript">
<xsl:with-param name="string"
select="substring-before($string, '
')" />
</xsl:call-template>
<xsl:text>\n</xsl:text>
<xsl:call-template name="escape-javascript">
<xsl:with-param name="string"
select="substring-after($string, '
')" />
</xsl:call-template>
</xsl:when>
<xsl:when test="contains($string, '\')">
<xsl:value-of select="substring-before($string, '\')" />
<xsl:text>\\</xsl:text>
<xsl:call-template name="escape-javascript">
<xsl:with-param name="string"
select="substring-after($string, '\')" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise><xsl:value-of select="$string" /></xsl:otherwise>
</xsl:choose>
</xsl:template>
Thursday, June 19, 2008
Calling all girl geeks
Girly Geekdom blog is running a competition to get more girls presenting at DDD this year. All you have to do is submit a session for DDD and if your session is selected you could win a 1 year MSDN subscription. For full details:
http://girlygeekdom.blogspot.com/2008/06/submit-ddd-session-win-msdn-premium.html
Wednesday, June 18, 2008
alt.net london beers
Had a good evening last night with the alt.net lads and lady. About 15 people turned up for either the beers and talk and/or dinner.This was only the second one and seeing if people will turn up. Mainly intros and telling others what you are doing technology wise. REST seemed to be the main topic for the main part "resources not services !".
Here are some photos from the evening http://www.flickr.com/photos/holytshirt/sets/72157605676029098/
Seb is still coming up with a format for the night. Which will follow something like this:
18:30 - 19:00 drinks
19:00 - 20:00 talk about a predetermined topic
20:00 - late dinner and each person comments on the topic, which gets posted up.
How should we tag our posts, photos ?
1. alt.net, london, beers
2. alt.net.uk.london.beers
Should we compile a list of attendees ?
See you next time !
String array to Int array
Note to self, putting it down in writing so I don't forget it for the umpteenth time.
string stringOfNumbers = "1,2,3,4,5,6,7";
string[] stringNumbers = stringOfNumbers.Split(',');
int[] numbers = Array.ConvertAll(stringNumbers, s => int.Parse(s));
Monday, May 19, 2008
How do I say => as used in lambdas
When I did my talk recently someone asked what the predicate c => c.CompanyId == (int) results.Element("ID") meant as they had not seen this syntax before. I explained it was the new lambda syntax in .net 3.5, I tried to read the code out and realised I did not know how to say "=>". I was stumped and it has been bugging me ever since.
I read this blog post this morning Reading Code Over the Telephone by Eric Lippert and he goes some way to helping me solve this riddle.
I personally would say c=>c+1 as "see goes to see plus one". Some variations that I've heard:
For a projection, (Customer c)=>c.Name: "customer see becomes see dot name"
For a predicate, (Customer c)=>c.Age > 21: "customer see such that see dot age is greater than twenty-one"
So taking Eric's advice my predicate would be said like this "Company see such that see dot company id is equal to the results element called ID". After reading the comments I thing I might like this one "Company see is used to evaluate see dot company id equal to the result element ID".
I like the idea that if your code is clear enough to read over the phone to someone then your code must be self explanatory, something to keep in mind when writing code.
I still have a feeling I will have to explain a bit more, maybe not, what do you think? How would you say it ? Is this clear enough ?
Friday, May 2, 2008
Acrobat 8, panning, zooming, page flipping speed up
Adobe has snuck in something new into their bloatware PDF reader. If your CPU supports it, you only see the option if it is supported, you can speed up panning, zooming and page flipping.
Edit|Preferences|Page Display
In the Rendering Section, if the check box “Use 2D GPU acceleration” appears check it.
For detail on its effects here is the detail.
Friday, April 25, 2008
LINQ to XML and SQL
From my presentation given at the London .Net User Group on 2008-04-28.
Since LINQ came out, we have been told about how LINQ creates a common way for developers to work with; XML, SQL, Objects, anything. But all the demos I have seen so far show examples of LINQ to SQL, LINQ to XML or LINQ to whatever. Never demonstrating mixing different "LINQs" together, maybe it is just me.
Recently a project required getting results from a web service and adding to it with data from a database. I thought this is a perfect opportunity to use LINQ as I want to create a single object based on data from two different sources.
The background to this is, the web service delivers a list of companies, but we require a flag to display if the company is still trading or not. Currently this is not available via the web service but the company can provide a csv file of company ids of the companies that are no longer trading, which you load into a table in your database. Once you receive your results from the web service you check to see if the id exists is in the database table.
First you need your XML and now days the new flavoured Object for working with XML is the XDocument class.
XDocument resultsXml = XDocument.Load(MapPath("Companies.xml"));
Next create the DataContext for the LINQ to SQL
DataClassesDataContext db = new DataClassesDataContext()
Now use LINQ to XML to get each company and use LINQ to SQL to see if the id exists in the database, the .Any translates to EXISTS in SQL.
var companies = from results in resultsXml.Descendants("COMPANY")
select new Company
{
Id = (int) results.Element("ID"),
Name = (string) results.Element("NAME"),
OutOfBusiness = db.OutOfBusinesses.Any(company => company.CompanyId == (int) results.Element("ID"))
};
As you can see this is not much code, think how much you would have to write to do this without LINQ.
Here is the demonstration code
Keep on keeping on !
Here we go...
I was trying to be retro and not have a blog, but it has not gone down well. So after much hassling and *gasps* "you don't have a blog?", here we go ... more like in the words of Pink Floyd "I sentence you to be exposed before your peers" ...
