Programming Music

June 11th, 2010

I can’t recall a time I have engineered any code worth its salt while not listening to music… One of my favorites is Metal/Alternative, Chillout/Ambient/Smooth Jazz/Downtempo and Native American. Grab winamp and check it out:

ShoutCast:

http://scfire-dtc-aa02.stream.aol.com:80/stream/1039

http://scfire-mtc-aa03.stream.aol.com:80/stream/1018

http://scfire-ntc-aa08.stream.aol.com:80/stream/1080

http://64.62.164.208:3002

*I use Pandora too, but this is free and they tend to have far fewer commercials/interruptions.

Uncategorized

Working with Regular Expressions

May 11th, 2010

Just a quick note, to help write your regular expressions I highly recommend The Regulator for developing, tweaking, and testing before deployment into your code. It is available on source forge here:

http://sourceforge.net/projects/regulator/

One caveat, sometimes the config file gets screwed up and the program wont load anymore. Navigate to the directory and delete the config file then restart and you’re good to go.

Another tool you’ll need in your arsenal is a good reference, and the best I have found can be located here:

http://www.regular-expressions.info/

Keep on coding`

Regular Expressions

Regular Expressions: Forward and Backward Lookups

May 11th, 2010

Several years ago I read the regular expression syntax and was instantly hooked because it made parsing text just so darn simple. But one thing particular to regex that I never actually had a need for was forward and backward lookups, much less both of those within the same regular expression…. that is, until now.

Problem:

Write a regular expression to pull out everything not within {brackets}.

Ex. Input:

{ed ut perspiciatis}test{unde omnis iste} foo {natus error sit voluptatem}

This should pull out “test” and “foo” (as well as the space prefixed to “foo”, and the space suffixed to “foo”. These are underliend and in red above for your reference.

I would like to point out that I could not simply replace everything in brackets since I was modifying the string to be in a paticular format (in my case another programming language). And with that having been said, it does (and I might add quite suddenly) occur to me it would have been simpler, and for that matter faster, to have a simple regular expression such as ({.*?}) and then use the the index and length parameters of the GroupsCollection to pull out everything else, yet for some reason I got caught in the theoretical enjoyment of doing it the hard way :)

And so here it is:

(?<!{[^}]*?)(?<=^|\s|})(?<Text>[^{][^}]*?)(?<TrailingChar>\s|$|{)

Couple cool things here: 1. named groups which come in handy when you’ve got a lot of groups. Why count up the index if you can just name it? I also feel this makes it easier to understand and work with the regex in the future in case you have to revisit it.

The regular expression used above did require me to use .Replace(…., new MatchEvaulater(customFunc)). This is another cool feature I had never used before but it kept things quite simple and neat in the code.

Anyway, just a note about what Forward and Backward Lookups are and how they work:

Basically a lookup is just that, it looks up a match either to the left (backward) or to the right (forward) but since its only “looking” it doesn’t append that match to the MatchCollection.

To look forward (?>=[a-z]{1}) to look backward (?<=[a-z]{1}) , and then you can negate these like so (?>[a-z]{1}) and (?<![a-z]{1}) … *obviously  you can replace [a-z]{1} with whatever you need/want.

Let this serve as a reminder to both myself and you, if things seem overly complicated it’s probably because your making it that way. But hey, this is fun so who cares?

Regular Expressions

Working with multiple NICs

May 10th, 2010

Ever since the programmers.org server crashed due to a hard drive failure (mind you, while I was doing a defrag) it has been dropping off-line periodically (we are talking months here). I spent an enormous amount of time trying to figure out what was happening and why… all to no avail.

Finally one day after it dropped offline I trotted over to the console to see that it’s IP address was cut short. Oddly the last 2 digits seemed to have been cropped off. Checking all of the TCP/IP settings on both NICs in the machine the only thing I could find with any similarity was the DNS of the second NIC which was set to the LAN DNS… that similarity was that its string size and the string size of the newly cropped ip address were the same. Weird.

After tinkering around a bit with the settings I clicked apply and noticed a message I had seen previously but not really read. It said, as best I can recall, something to the effect of “Multiple DNS are intended for redundancy and may not function properly if not on the same network.”

HUH? What’s this I thought…. when I suddenly realized I did not need the second NIC to have a DNS at all since it was being used to communicate with the NAS and not the outside world. PLUS the other NIC was set as the primary so I could still browse the web from the machine as need be. Voila. No warning message, and no more server falling offline. Finally.

Until next time, happy coding 8-)

Uncategorized

jQuery Google Suggest goes Live on DiscMakers.com!

May 5th, 2010

Special thanks to the work of Charles Kline and the rest of the dev team at DM for giving GSuggest a shot. They also integrated the Google Search API too and everything fits together quite nicely. Check it out!

http://www.discmakers.com/websearch/Index.aspx?SearchTerms=digipaks

jQuery Google Suggest

SQL Server Reporting Services and rsAccessDenied

April 28th, 2010

Since this saved me what would have undoubtedly become a migraine, I thought I would repost it here. All credit goes to the original Author (see the jump):

SQL Server Reporting Services and rsAccessDenied

rsAccessDenied was all that stood between me and high fives from the customer.  The message from SQL Server Reporting Service (SRS) even displayed the clients log on name – so SRS KNEW who it was denying.  No impersonation was going to solve this one.

The Redirect string was fine, because it worked in test and on the server for those of us with admin rights.  (Yeah, I know — but this a practical blog — remember?)  So I fired up Report Manager to see what it had to say about the security settings on my report folders.  All I saw was the built in administrator and no way to add any more.

Hmmm.  At the Home folder level, I could add roles.  Since my client had access to the box, she must be in some local group or another, so I added Guests and Users with SRS Browser capacity.  I sauntered over to the client and acted as if I expected the report to work now.  It did.  I took my bows and made my exit with no small relief.

If this stuff was easy, nobody would need developers.

Uncategorized

Working with SSRS 2005

April 27th, 2010

Recently asked to replace Crystal Reporting Services with SQL Server Reporting Services I went about reading, testing, reading, and testing yet again the features of SSRS.

I found the Report Designer (SQL Server Business Intelligence Development Studio) to be a bit clunky… but, it does work once you get the hang of it. My main complaint is that its so tedious to reference values =Fields!foobar.Value … not sure why these aren’t aliased as with Crystal Reports. And the WYSIWYG leaves me scratching my head a bit b/c it just doesn’t work as fluidly as one would expect it to.

Dipping a bit more into the programming I found I could use the Microsoft Report Viewer to display the report by specifying a URL (in contrast to using the web services which I did not need). Unfortunately it took me a full two hours to determine how to set parameter values! …. While I may have moments of lunacy, last I checked I was not an idiot, so why was this not made more clear by the documentation since it seems like such a common need?

For those of you facing the same issue, here is how you do it:

//dynamically set parameter values

ReportParameter reportParams = new ReportParameter(”paramName”, “yourValue”);

reportViewer1.ServerReport.SetParameters(new ReportParameter[] {reportParams});

*Note that the parameters are case sensitive.

Uncategorized

Generating Excel Reports in Binary Format

April 26th, 2010

Some years ago I wrote a .NET Class that used the Microsoft Office Interop Services (Microsoft.Office.Interop.Excel). While I wrote it nearly complete to the exact specification I found it was never quite fast enough since a) it was using COM and b) I had to deal with the .NET wrappers for that unmanaged code. Knowing I had to produce the report in binary for optimal performance I pretty much gave up on ever discovering the format of the file… until today, while researching SQL Server Reporting Services when I came across these links:

“OpenOffice.org’s documentation of the Microsoft Excel File Format”

“Microsoft Office Excel 97 - 2007 Binary File Format Specification (*.xls 97-2007 format)”

Happy coding.

Uncategorized

Best Free Image Converter (png to gif)

April 12th, 2010

If you do any web programming you will eventually need to do some image conversions. This is especially true if you download icon libraries that are in PNG and need to convert them to transparent GIFs.

My favorite and free program for this is ImageMagick. You will find the command line tool especially useful for doing batch conversions.

http://www.imagemagick.org/script/index.php

Note: If you can use PNG stick with it as you will lose opacity layers if you convert these to GIF. Unfortunately some older browsers don’t support PNG so I typically use GIF for compatibility reasons.

Uncategorized

Direct2d (hardware acceleration) FireFox

April 8th, 2010

This is amazingly fast… check it out. IE 9 is supposed to have hardware acceleration too…. (btw: this won’t work on XP)

http://www.basschouten.com/blog1.php/2010/03/02/presenting-direct2d-hardware-acceleratio

Uncategorized