sloppycode.net
An alternative to Vista's search
22nd November 2008

My search for an alternative for Vista's inbuilt indexing search was born from not being able to find "ildasm.exe" on my hard drive, convinced it was hiding somewhere (I'd actually deleted it by accident but that ruins my point). I went looking for an as-you-type file search, much like the way Vista search was touted in its product demos before release, but only looking for filenames and sizes. I've used Coppernic, Google Desktop etc. before but I've found them overkill for special developer needs. I don't really want content searching as I spend most of my time doing this via CTRL+F in Visual Studio or using wingrep. The only good point to Vista's search for me is the start menu search, and I'm not sure that's powered by the indexing search.

After a very limited bit of research I couldn't find anything that matched my criteria. I wish I'd 'searched' harder as I then set about doing a Friday afternoon mini-project to index all the files on my hard disk (a simple recursive method), by putting the file paths into a basic SQL Server table with 2 columns: Id/FullPath. I then enabled full text indexing and wrote a quick winforms frontend to do an as-you-type search using a Contains() and Freetext() search. It worked quite well except for the quirks with full text searching treating filenames as words.

I had grand plans to turn this into my own mini-alternative to WinFS. Before I embarked on this I double checked nobody had written some free software to do what I was doing. This time I searched lifehacker.com and neowin's forums. I found out via Neowin that someone had infact done what I was doing, without the 500mb addition of SQL Server (Express) in the install and featured everything I planned to add such as a winapi context menus and icons. It's called Everything and is free, the link is below. I definitely recommend it over Vista's search if you're just looking for filenames. I also find it a lot quicker to use than navigating through folders in explorer.

While I'm the subject of power tools, there's a few other's I'll link - two of which most people will probably have already. They're all freeware except wingrep which is nagware.

XNeat's clipboard manager
Brings up a list of your clipboard history for any application just by pressing CTRL+SHIFT.

Snippet Compiler
A C# editor that compiles your code, a nice way of testing bits of code without making 100s of new console projects in Visual Studio.

LINQ Pad
A tool for testing out LINQ (including to SQL,XML)

Wingrep 
As mentioned above, searches file contents using regex, and is fast.

Everything search tool

Using JQuery for Async/AJAX calls with ASP.NET
1st October 2008

I've added an article about about using JQuery and ASP.NET together, as an alternative to the inbuilt Atlas/ASP.NET Ajax controls. I wrote this off the back of a small project I made in my free time I called Soot, which is an online RSS reader that lets you filter feeds by category/website and date. It selects the feeds for you instead of allowing people to add their own, from a limited set of feeds with decent content. It loads the headlines + descriptions in dynamically, 10 at a time from the database which contains the feeds and the content (the feeds are retrieved hourly in a batch). More about it in the article which is here.

The Soot project isn't complete yet it still has some bugs in the UI and some bits to iron out with the content. I'm also writing an email digest, so it'll be possible to signup and get a list of 10 random headlines from categories or domains emailed every day.

.NET ORMs evaluated
29th September 2008

I've been busy making new content for the site in the form of articles over the past 2-3 weeks, the first of these is my own evaluation of .NET ORM platforms. It's biased towards what I like in ORMs but lists all the features you find in each ORM and pros/cons. It's mostly open source ORMs (which most .NET ORMs are anyway). The article can be found here.

Changing to a blog engine
26th September 2008

I've been considering (im)migrating the site onto a hosted blog over the last few months, mostly to save money on hosting which costs a fair amount with SQL Server included, but also to allow some decent commenting and feedback on the stuff I write and mess about with in my spare time. The site isn't deliberately aimed at being a monologue or kind of sermon of my code, it's just everytime I've tried comment systems they end up being filled with crap asking for help where the question should've been posted on a newsgroup/forum. Either that or viagra selling spam messages. I got analytical about moving to a hosted blog and wrote the pros and cons. The pros of a hosted blog as I see it are:

- A lot cheaper, or free infact
- Decent text editing tools, not Umbraco's unforgiving text editor (which means I end up writing most pages in raw HTML).
- Comments, pinging, all the other blog related features (which helps pagerank too).
- Decent tagging and searching
- Benefit from traffic from blogger.com or the wordpress' community

And the cons:

- It would take me months to transfer everything over.
- The taglines would no longer exist (which attract most traffic)
- None of the custom tools and references could be available, which I tend to use.
- About 2 months of Umbraco customisation work would be wasted
- I'd have no little sandpit to host asp.net side projects in.
- Most of the hosted blogs have poor integration for posting source code without pre-formatting it. All the source on the Umbraco system is stored in plaintext and then prettified.

Most importantly however is I rarely update the site with news (maybe monthly at most). I'm not talented at journalism (though once that was going to be my profession), nor am I on the bleeding edge of C# or ASP.NET or good enough/have the time to articulate something trivial into an interesting post, like you find on codinghorror.com. I find blogs where a developer posts his musings on something he has just found out with nobody reading or caring (i.e. zero comments) a bit depressing. The site would just be a disjointed mess of articles/code samples squeezed into a blog form.

So there you have it. If you wonder why the website is so "web 1.0"/2002 these are the reasons. I am hoping to improve the searching and tagging (or DC tagging mainly) soon and it'd be good to have comments and get feedback and suggestions for some of the code I distribute here. When Google Friends Connect finally arrives next year it should resolve a lot of this. Until that comes in 2009 you readers who on average spend 15 seconds a page will have to wait!

Chrome about pages
9th September 2008

Here's a small bit I've written about the about pages you get in google's decent fast new browser, Chrome (give it a year and it'll bloat). There are quite a few of them and give quite a transparent view of what's happening in the browser.

Ads and stats
20th July 2008

I've added some google ads to the site underneath the right navigation in a vein hope of generating some cash towards the hosting. They're quite unobtrusive and the same colour as the site so it's not really a huge eye-sore or masses of popups or pop-unders. As the images below show, a lot of you use Firefox which probably means you have ABP installed. Somehow gmail manages to work around ABP and show mail adverts. It's funny that Google's main revenue is adverts, but they're pushing a browser that is made to block them so easily. Anyway if you're feeling curious, click that big red ABP toolbar button in Firefox and make it green for sloppycode.net, you might find an advert of interest! (of course I'm not trying to break the google T+C by suggesting you click them, just admire the layout)

abp.gif 

I'm guessing 99% of the audience for the site are developers so it's no surprise most are running at 1280 resolution, fellow LCD users with giant carbon footprints. What's surprising is how few use 800 now, this resolution was roughly 80% back in 2002/2003. This means I can extend the width of the site which I designed for between 800 and 1024 pixels.

resolutions.gif

browers.gif

Small update
14th July 2008
Here's a reference page and article I've spent a few hours writing up and making vaguely readable:

C# design patterns
UML class diagram cheat sheet

I also got my first batch of spam for the little private experiment I was doing with spam email (see the honey trap below). It wasn't exactly the opening of floodgates of spam, there were only 5. They all came from Holland and Germany, promising the usual lifestyle enhancements (larger dick, viagra).

Summer collection

1st June 2008

It's that time again! A summer update is here - I've written up a lot of stuff I had on google docs into (hopefully) readable articles around .NET and C#. Four in total, plus the System.IO one which I've added in there.

C#/.NET performance and architecture
Some common issues with C# and .NET architecture and performance, such as abstract vs interfaces, boxing, equals().

Type visibility
A small reference sheet/article about type visibility in C#.

Inside .NET assemblies
"Under the hood" look at metadata tables, assemblies and the architecture of .NET/CLI.

.NET Formatting strings
A reference and look at .NET formatting strings including DateTime, numerical (including rounding and significant figures) and creating your own with IFormattable.

The articles are annotations and my own exploration of C#.NET based on 3 excellent books I've been reading over the past months:

Inside NET IL Assembler
CLR Via C#: Applied .NET Framework 2.0 Programming
C# in Depth

These were coupled with tools like reflector and Microsoft Shared Source CLI on koders.com and on disk.


I've added in a commenting system via js-kit.com. It's a bit slow but works, so feel free to spam away. I'm hoping google releases Friend connect soon so I can replace the js-kit one and have a more meaningful community.

Over the coming months I'm going to write up some of my design patterns notes into articles (5 or so), something on bit shifting in c#, a small piece on friendly URL generators and a few personal projects.

New for Spring
29th March 2008

Don't worry, no more bad photos from Flickr, just an update to the site with new content. I've added five new bits and pieces:

Ascii and Unicode lookup table
A copy of the Windows charmap application in Javascript, but with HTML codes and special characters to save asciitable.com some bandwidth charges by me.

System.IO article
This is my "under the hood" look at all the classes in System.IO, along with lots of example code and reams of details about ASCII/UT8/Unicode/UT32 encoding in .NET.

XML documentation cheat sheet
Some commonly used .NET/C# XML documentation snippets if you're into that kind of thing, including a .snippet file.

.NET Regular Expression tester
A tool for testing regular expressions quickly, geared towards developers who use the .NET implementation although it should work with preg and ereg. Includes detailed error messages in the output and also does replacements.

.NET XPath tester
Another testing tool for trying out XPath queries on an XML source. Includes detailed error messages and the results syntax highlighted.

Multi-line search and replace
A very basic tool for doing quick multi-line search and replaces. I haven't found a tool that can do these yet except Dreamweaver - not Notepad++,Metapad, Visual Studio (there's a visual studio macro for doing it but I couldn't get it working).

Update: a small page to track where my email spam to this site originates from (an idea copied from the HoneyNet).

More from flickr
17th Dec 2007

At night on a beach in UAE (close to Dubai).

Photo of a United Arab Emirates beach at night

Regexs referencing strings: A leaky memory story in Statmagic
26th Nov 2007

I've been spending the last few months working on and off on a pet project I originally started writing in 2002 in PHP. I called the project Statmagic for some reason and the name has stuck. It's nothing groundbreaking just another web log file analyser. It's now in C# not PHP (and from the tests I ran could never be in PHP as its string handling was so slow). It's travelled through every version of .NET from 1.0 upwards, and is now enjoying 3.5's LINQ features with db4o, making aggregation so much simpler.

It's very close to completion now, the last few days I've been working on a memory leak that meant every single text log file it was reading was being kept in memory as a String. Not a huge problem most of the time as my intention is it'll be run daily on a small set of log files (it runs well on 360 log files, it just takes around 20 minutes per 120 files). I'm testing it with 120 files of 6mb at once and it managed to gobble up 1.2gb of memory as it kept going.

I tried out ANTS with it and narrowed it down to the fact a string was causing the problem (which I guessed was the case anyway), but couldn't find out where. I also tried out MemProfiler which gave me the answer to the lost memory but at the time I didn't realise it. So I scrapped the expensive tools and did the bodge it method of commenting out each method call until the problem was solved.

The main log reader in the application has a buffer of 16mb to read in textfiles with a StreamReader. I hadn't wrapped this in a using clause to dispose it which was adding to memory usage but wasn't the main problem.

Through trial and error I eventually found the problem was actually the logreader initialising 2 member variable Regex classes e.g. _regex1 and _regex2 in its constructor, and using them inside the main parsing method. For a reference issue which I'll admit I didn't entirely understand, these regexs were keeping hold of each 6mb log file.

My reasoning for doing this with the 2 regexes was that compiling them both once at start would speed things up. It didn't at all, and infact Regex reg = new Regex(..) created inside the method that loops through Matches, instead of using _myRegex solved the strings refusing to be GC'd. The parsing method usually goes through the entire text file, raising an event via a method called OnLineMatched each time it matches a line in the log file. So in the stack there are a lot of references being held onto via the event.

My guess would be that because the eventargs in this event was referencing a value from the regex's Match.Groups.value, it was in turn referencing the _myRegex object, which then had a reference to the 6mb string. The LogReader class itself was also not being destroyed from what I could tell.

MemProfiler was actually telling me this but I didn't realise it at the time.

Postcode/Zipcode webpage to google maps in C#
21st Nov 2007

I got my hands dirty with Google maps api for the first time yesterday. I'd used maplets but not much with the services or customising the control. I decided to write something that would take a webpage, usually some search results, grab the HTML and retrieve all postcodes (zipcodes).

From there, it plots them all onto a googlemaps control with markers. A lot of sites don't have this facility, or just show each result on a map on separate page which is why I wrote it. The api is nice and clean to use and seems to be incredibly well thought out, particularly for latency and performance. They even let you have 1 query per second which seems nice of them.

If you have a store locator or some search results with post/zip codes and want to plot them then you might want to try the example out.

The code and the example can be found here

Autumn leaves
15th Nov 2007

Something to brighten the frontpage up with, some leaves I took this morning with a Nikon D50.

 

Umbraco issues
14th Nov 2007

Being a site full of nerdy code, there's a big requirement for posting inline code. For some reason the default editor in Umbraco, Tiny MCE, strips your newlines from the pre tags when you update. I found this out when I was actually doing an Umbraco page for the site.

Anyway the short version is it's a config setting that's required in Tiny MCE - remove_linebreaks : false. Because Umbraco hardcodes its settings for Tiny MCE (except the commands and allowed tags), I had to hack the source about. The result is at (also fixes a Macro problem in firefox):

http://www.sloppycode.net/media/43259/tinymce.zip

Put that in your bin folder and no more pre problems. The umbraco page has more stuff on it.

Snipper release
6th Nov 2007

The snippet editor tool I've been working on, Snipper (as in Flipper faster than lightening) is now released on Codeplex. Grab it here.

Skype and port 19403
14th Oct 2007

Something tells me all those IPs below aren't owned by Skype. It can't help with all the echo and problems I already get with the Skypeout line.

skypeport.jpg

Site back up and running
1st Oct 2007

After 9 months of an empty holding page, the site is finally back and spreading itself around the internet again. The site was 90% converted to Umbraco back in January 2007, but then I had to put it aside to concentrate on things like truth tables, java.util, boundary errors, proof, recursion, efficiency etc. etc. It's amazing how much you can forget from 9 months without daily C# and SQL. The knowledges wasn't forgotten, it just needed a quick slap in the chops for it to re-surface again.

The site is now properly content managed instead of before when a few custom asp.net/winforms apps ran the show. No more stagnant content I hope, or glaring errors. Lots of the rubbish was removed from the site (leaving me with not much) but the ASP, FSO references are still there and still seem to be used a lot by unlucky souls doing legacy work or something.

The comment system has been removed from all the references. I added it back in 2003 to try to emulate the PHP community's comments on their docs. That failed miserably, probably from this not being an official site, with most comments being requests by people to do their code for them, people using it as a forum or non-english. There were a minority of good examples which were lost unfortunately, going through the entire FSO and ASP references to prune the comments was too much work for old technologies.

The taglines are backup again and performing quickly. They came from a lot of text files back in 2003 but haven't been tidied up much. There have been a number of sites like tagsgalore which have emerged since I made the system. I rarely use unix anymore but the unix cheat sheet is still there, if you want to add anything to it drop me an email via the contact page.

Finally, if you have any ideas why this site isn't showing at 100% in Firefox (or Safari) I would like to know. I have done plenty of 100% height sites before, with exactly the same code, but it's FF is being stubborn. I have a feeling it's the doctype which I'll experiment with, although it seems if this fixes it for FF, IE will then break.

Hope you find the site useful.

› Home
› C#
› Snippets
› Articles
› Tools
› Taglines
› ASP
› Dictionary Object
› FSO
› Unix cheat sheet
› Gaming
› CSS
› Yak
› Umbraco
› About
› Contact
› Privacy
› Projects
› Search
› Sitemap





Buy on Amazon



Buy on Amazon



Buy on Amazon



Buy on Amazon