Archive

Posts Tagged ‘.NET’

Scoreboard Progress

February 27th, 2009

Just a quick update on what I’ve been working on. I’ve had a bit of success getting scoring and the scoreboard playing together (see video). Another feature that you don’t see in the video is that all the switches point value can be set via the C# app that I made.

I’ve added the source below. Keep in mind this is all just hacking at this point. It’s probably not very helpful but it can’t hurt.

The led matrix on the top isn’t broken, I just hooked it up wrong :-/
 

Source

Spin:

C#:

Misc:

 

 

Pinball, Programming/Development , , , , , , , , , , , , , , , , ,

Link A URL With Regex

February 25th, 2009

I recently had a need to find a url within a large amount of text and turn it into a hyper link. Knowing that I am just a regex noob I opted to find someone else that could just give me some regex :)  I started with regexlib.com but everything there was exceptionally simple. Simple usually works but the client I’m working with always finds clever ways to do something unexpected. So I needed something that would detect any URL that is possible under the sun.

After a few minutes I found Ivan Porto Carrero’s website which had the following regex:

(?#Protocol)(?:(?:ht|f)tp(?:s?)\:\/\/|~/|/)?(?#Username:Password)(?:\w+:\w+@)?(?#Subdomains)(?:(?:[-\w]+\.)+(?#TopLevel Domains)(?:com|org|net|edu|gov|mil|biz|info|mobi|name|aero|jobs|museum|travel|[a-z]{2}))(?#Port)(?::[\d]{1,5})?(?#Directories)(?:(?:(?:/(?:[-\w~!$+|.,=]|%[a-f\d]{2})+)+|/)+|\?|#)?(?#Query)(?:(?:\?(?:[-\w~!$+|.,*:]|%[a-f\d{2}])+=(?:[-\w~!$+|.,*:=]|%[a-f\d]{2})*)(?:&(?:[-\w~!$+|.,*:]|%[a-f\d{2}])+=(?:[-\w~!$+|.,*:=]|%[a-f\d]{2})*)*)*(?#Anchor)(?:#(?:[-\w~!$+|.,*:=]|%[a-f\d]{2})*)?

It’s a pretty stinkin’ big regex but it sure does the job. I tried it with any url I could think of as well as the ones listed on Ivan’s site.
So there you have it. A big change from the pinball stuff but I needed to store this one where I could find it easily. I’m sure I’ll need it again in the future!

Programming/Development , ,