Monday, January 12, 2009

GOW2 Glitch List

You hate them. We all do. top 7 glitches you should know I will admitedly atleast *try* the shotgun shield + unlimited lancer one soon. :)

Friday, July 27, 2007

Great DB Tool

I would highly rec http://www.dbwrench.com/ as a database tool. This does what I wish Visio would do. Amazing.

Saturday, June 09, 2007

IP Help

Here is a little something for any of you that are trying to do any sort of serious networking stuff in .net.

http://www.codeproject.com/cs/internet/iphlpapi.asp
I actually had this code, and was going to post it but then realized it lived on code project.

I found this as I tried to construct the fastest .net spider in the world :). My first take at it with WebRequest/WebResponse was tossed out quickly as being too slow. I turned to native code (yes, I know it's cheating, but it works fast) via winhttp. But for the life of me I couldn't figure out how to get the winhttp objects I was using to clean up and behave as fast as I wanted to.


Enter the IpHlpApi. This is a very cool little .net wrapper of some very useful windows apis. It will actually serve as an educator for C# folks on the complexities of the networking apis on windows. It will also serve to let you get done what you normally "protected" from in C# without having to write too much native code.

It is a very sweet bunch of widgets.

Sunday, May 06, 2007

Regex Woes Finally Solved

A while ago I posted a class called RegexWT (Regex With Timeout) as a way to get around the horror of what I perceive as a bug in the .net implementation of regular expressions. Essentially, if you have a system where you can't control the input to the regex there are some serious performance gotchas with .net if you are incredibly careful with your regex syntax. I had RegexWT created as a way to time out and clean up out of control regexs.

However, I found that when used heavily, the time out thread mechanism (see code) added so much overhead that it slowed down my entire application by almost 100%. I'm doing some seriously heavy stuff with regex, with some very complicated expression in an AI engine I'm writing...and at this point it seems I was damned if I do, damned if I don't. I could choose between having no chance of "day long" (and I do mean day long) hangs on a given expression, or a complete slowdown using my timeout class. What to do?
As I searched, it turns out I wasn't the only with this trouble: http://www.codinghorror.com/blog/archives/000488.html. This blog link quotes some hotmail developers on the perils they faced themselves.

Well, lucky for me, to the rescue comes SourceForge. After some frustrated searching, I finally found an implementation of pearl regex wrapped up for .net. What life saver! It's super efficient, and while some of the neat stuff in .net regex's isn't supported I can throw just about anything at this engine and it will handle it gracefully without ramping my performance.

Part of it that sucks is that it doesn't seem to support stuff like a "replace" method, but it's easy enough to just whip through the matches and do string replaces. Anyhow, so far this thing has saved me hours of headache. Props to the guys a Ghetsoft for providing.

http://sourceforge.net/projects/pcre-cs/

I haven't been very active in the SourceForge community, but this has won me over. I'm in the process of uploading all of my non-proprietary utility code onto SF now.

Thursday, April 26, 2007

Yahoo answers? Google answers but worse?

I recently had a question about source code copyright infringement and the use of outsourced overseas consulting and how to protect yourself. Not wanting to consult a legal team just yet, I decided to give Yahoo Answers, a much heralded service released recently. Well, to be completely honest I first thought of google answers, and then spun over to yahoo as google answers has closed down. My first answer was a spam advertisment for penis enlargement. The later didn't seem to take my question into account and was two links to articles on standard copyright law (um, yea, thanks). So, I'll keep it open for a bit, but as of now I'm not very impressed.

Saturday, April 21, 2007

Utility Code

Hi. I decided to add some utility code I put together a while ago. This may be helpful additions to your own tools. Sorry for the lack of formatting, I have a ton of work to do right now! I'll clean it up later.

Friday, March 02, 2007

Thinking More About Online News Sites

I was considering today why I like, Digg, Splotplex and Google news for varying reasons. Each approaches the idea of "Relevance" to you in a different way.

Digg lets people vote, assuming that if other people who are interested in the same things you are voting, then likely this story should be rated higher. It has it's flaws: See Wired for details.

Spotsplex goes off of what you've people have been looking at. But it has it's flaws as well. It suffers from click fraud, catchy headlines that draw you into a crappy article etc.

Google news, looks at what the major news providers are putting out and clusters them so that as a story begins the filter through the sphere, it knows this is a hot topic and raises it's relevance. At the same time it also looks at who is linking to stories where and boosts relevance there as well.

However, this doesn't translate well when it comes down to small indy published blogs. A small blog post that gets traction on Digg or Spotplex would take 3 times as long to filter into Google news (if at all).

The real deal would be a combination of all three techniques, (The Doogleplex?)however it brings up the question: Who is measuring blog linkage? If anyone.

It's would be a pretty amazing tool for providing weight to blogs. The usage for the service would be pretty simple. I have a google like spider, with a network of links. A user submits a link, any link and you immediately output the pages that link to the link (thats alot of links jeesh) and their scores. You would also need to take into account the number of links to the linker google style so that you didn't spam linkage from a lot of low level sites.

Interesting stuff. Anyway, my thoughts for the day. Back to hacking.

Thursday, March 01, 2007

Spotplex?

In regards to:
http://www.techcrunch.com/2007/02/28/exclusive-is-spotplex-a-better-digg/
Whether this is effective is all based on how you determine if I’ve read a story or not. I could simply employ the same tactics spammers and click fraudsters employ to boost my rating. (that said you can do the same thing on digg if you wanted to).

That being said at least “human” voters on digg have to actively lend their support. Where as on this site if I was duped into reading a crappy article by a catchy headline, it would count as a vote where I really wanted to bury. YouTube and others have this problem, where as Digg, which is far from perfect does not.

The only system that would work is something akin to google’s link based ranking. The more people linking to a story, likely the better it is.

Friday, December 08, 2006

Some Code Project Stuff

I really dig the codeproject. Two things I wanted to highlight on codeproject.com
First:
http://www.codeproject.com/cpp/Clean_Workspace.asp

This isn't such a big deal. However, this little project is a nice addition to any source try that you'll need to migrate of back up. It basically just kills binary files. Very nice.

The second is more significant and I'm really pleased to have found it. It is a port of OpenNLP in C#.

http://www.codeproject.com/csharp/englishparsing.asp

I love to fiddle around with Natural Language processing in computers and any application can be made a little smarter using parts of speech. This program includes a bunch of really useful tools including a tagger and a chunker. Plus, it's all in C#, so you won't need to learn java to enjoy OpenNLP.

It's a version or two behind and missing configs, but if you follow the comments I posted on the project page you should easily be able to put it together. If not, email me and I'll send you my full version.

Enterprise Desktop To the Rescue Again

Readers of my old blog, now long departed, will recall my great unending love for Microsoft's Enterprise Desktop. Which is essentially not unlike google desktop (which was brilliant) but with a few nifty features and unchained security :) that made it better.

My first love of MED when I realized that it would index all of the libs of the platform SDK for me and allow me to search for undefined symbols with a few keystrokes and a *.lib at the end of my search.

My latest love comes from this little feature: date:>11/05/04. Which is really great for when you are messing around with code and have forgotten to check it out. Point MED at a folder, search date:>11/05/04 and it will *recursively* (that little word being the key) search out all the files you modded after such and such date.

Wednesday, November 08, 2006

Deliver us from CMD.exe

My frustration with CMD hit a high point today. I was working in a command prompt and I came so utterly frustrated with clunky copy and pastes, and mistyping unix commands in does (ls for dir) that I decided there and then that I would either find a viable alternative or write one myself.

Luckily one pass on download.com saved me from having actually write one. I found this prgram called 4NT which is simply a better CMD.EXE.

Some features? Well for one, control C copies and control V pastes. Which in and of itself is worth the price of admission. But on top of that it supports an ALIAS command. So things like ALIAS ls=dir are possible. Allowing you never have to boggle your unix to dos syntax again.

Get it from CNET Download.com!

Monday, October 30, 2006

Serializing objects to an array with C#

The samples you'll find on MSDN surrounding the binaryformatter are always geared toward fileio. But if you don't want to serialize to a file, this is a helper for you:

String Hashing in C#

Cool little helper for MD5ing strings:


Note: the compare has in this class is really slow. I've been using a string compare with much better results.

Monday, October 16, 2006

Some things to know about driver development

The winddk. This is some cool stuff and really not as horribly complicated as the world would have you believe. Anyhow here are some cozy resources that will get you going with less frustration then I had when I started:

1) Get the DDK

http://www.microsoft.com/whdc/devtools/ddk/default.mspx

2) Set up your environment and Learn to compile

http://www.catch22.net/tuts/kernel1.asp

3) Reference for Build.exe

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/DevTest_g/hh/DevTest_g/Build_Use_63fc451f-8429-41a5-ad58-e410dd38f762.xml.asp

4) The last piece that I didn't find a reasonable tutorial on googling was debugging. I've only been debugging win32 applications built with the DDK, so all I've been doing to debug is attaching to the process with Visual Studio. There is probably a way to do it without VS using WinDbg, but for just ticking around this suited me. I'll post an update once I get into it.

Making copy and paste easier in CMD.exe

I've been doing some DDK work in the cmd. Found this:

http://blogs.msdn.com/adioltean/archive/2004/12/27/332974.aspx
Makes copy and paste very simple.

Friday, October 06, 2006

RegexWT take 2

A while ago I posted some code for a Regular Expression wrapper class that allowed for time outs. With the post I mentioned that it was fairly untested. And it was. There were deadlock issues and null pointer problems. I've taken care of these first round of problems. The updated code is below:

Thursday, October 05, 2006

Remove SQL Dupes

Remote Debugging Tomcat with IntelliJ

For the linux n00bs out there: http://jroller.com/page/JamesGoodwill?entry=debugging_web_application_with_intellij

Tuesday, October 03, 2006

Regular Expression with Time out

I have a odd scenario where due to unpredicability of input, there was a good chance that a regex I needed to run would time out. Couple that with the fact that I needed to run hundreds of them at a time, I was in some trouble.

So, I found this thread:

http://weblogs.asp.net/justin_rogers/archive/2004/05/22/139337.aspx

So first, big ups to Justin rogers for posting.

In response I had this RegexWT class built in C# (Regex With Timeout). Which is essentially a wrapper around Regex where the fun methods all have an extra parameter specifying a millisecond time out.

Okay, so onto the code. First a disclaimer: 1) Use at your own risk. I haven't been through this code tooth and nail, so there may be some hidden baddies. 2) I know, already that there are some bugs that I haven't tracked down. Since putting into an engine I'm running, I've gotten a few exceptions after heavy abuse. However, I wanted to post it anyhow and will post updates as I make modifications. 3) If you see any baddies, please feel free to comment.

Here is the code, sorry for the mess as soon as I figure out how to get blogger to handle attachments I'll post the project files.

Monday, October 02, 2006

Debugging a user with limited privileges with visual studio 2003

* Open your project in vs2003

* To make your life easier add a Sleep(30000) to your entry point. This will give you time to attach to your process later.

* Compile under debug

* Create a user with limited privledges on your developement machine

* Copy the debug version of your exe to from debug directory to a directory that your new user will have access to. I've been using "Application Data" under the user's documents and settings folder. Program files is probably fine under normal circumstances, but my program needed to write to it's current dir. Application Data will allow write access if you need it.

* From a command prompt run:

C:\>runas /profile /user:[mylimiteduser] "[path to my exe]"

Then you'll be prompted:

Enter the password for limited:

Here, enter the password for you limited user. Then it will say:

Attempting to start [your path will be displayed] as user [your limited user]

* Now that the exe is started, while it sleeps, use visual studio to attach to the process and debug native and clr.

* Set a breakpoint and you are set to go.

Tuesday, September 26, 2006

Create a vs2005 CAB without pain

If you've written an mfc activex in Visual Studio 7 or Visual Studio 8 and then tried to deploy with a cab file you've likely been ready to throw your computer out of a window.

So here's how to do it in a few easys steps.

1) Compile your control

2) Go to this website: http://support.microsoft.com/default.aspx?scid=kb;en-us;167158

3) Read it.

4) No. Really Read it, don't just copy the code snippet you find.

5) Copy the inf file code and put it into a file called setup.inf. Drop this file with your dll. (or ocx).

6) Open your file up in a dependency crawler, check if there are VS7 or VS8 mfc dependencies. These aren't on a cab somewhere that I know of yet (Note: if anyone from microsoft is watching, it would be nice if this support page to contain that info since it stops at VS6). Most likely this will be things like msvcr71.dll etc.

7) Anything that doesn't live in the mfc42.cab you'll need to add. Do by adding lines to your inf:

[Add.Code]
NetAnchorShell.dll=NetAnchorShell.dll
; These are the necessary supporting DLLs for MFC 4.2 ActiveX Controls
mfc42.dll=mfc42.dll
msvcrt.dll=msvcrt.dll

;YOU ADD THIS
msvcr71.dll=msvcr71.dll
olepro32.dll=olepro32.dll

; thiscab is a keyword which, in this case, means that the file
; can be found in the same .cab file as this .inf file
; file-win32-x86 is an x86 platform specific identifier
; See the ActiveX SDK - ActiveX Controls - Internet Component Download -
; Packaging component code for automatic download

[NetAnchorShell.dll]
file-win32-x86=thiscab
; *** add your controls CLSID here ***
clsid={YOURCLISD}
; Add your ocx's file version here.
FileVersion=1,0,0,001
RegisterServer=yes

;YOU ADD THIS
[msvcr71.dll]
file-win32-x86=thiscab
FileVersion=1,0,0,001
RegisterServer=no

8) Pop "CabArc.exe" into Enterprise desktop. Don't have enterprise desktop?

Get it at:
http://www.microsoft.com/windows/desktopsearch/enterprise/default.mspx

Here's why:
http://jm0rdetsky.blogspot.com/2006/04/desktop-search.html

That said you don't need it, but it's easier. This happens to live: C:\program files\microsoft visual studio 8\common7\tools\bin\CabArc.Exe

9) Open cmd and cd to where you files live. Then add them to cab with cabarc

C:\Documents and Settings\jm0rdetsky\Desktop\How To Build A Cab>

"C:\program files\microsoft visual studio 8\common7\tools\bin\CabArc.Exe" N Mycab.CAB mydll.dll setup.inf C:\Windows\system32\msvcr71.dll

Microsoft (R) Cabinet Tool - Version 5.00.2134.1
Copyright (C) Microsoft Corp. 1981-1999.

Creating new cabinet 'netANCHORShellCab.CAB' with compression 'MSZIP':
-- adding NetAnchorShell.dll
-- adding setup.inf

Completed successfully

10) Sign your cab (if you don't sign it, it won't work in IE under medium security settings.

How to sign? http://www.verisign.com/support/code-signing-support/code-signing/identity-authentication.html

And your done.

ASP.NET Treeview Trouble

ASP.net is shiny, happy and does 90% work that you would normally need to do yourself while building a site for you.

However, as with anything, if something else is doing 90% of your work for you, when it comes time for the 10% it doesn't do you're going to scratch your head. Not that this is a bad thing, but you can't expect the people creating the abstractions to think of everything. (I mean, they aren't me... ;)

This sort of happened to me when it came to hiding links using the ASP.net treeview control and an ASP.net sitemap. Apparently, you can change your config file to trim pages that a user doesn't have access to, but I couldn't figure out a way to trim pages that I only wanted anonymous users to see. IE like a login link. If you grant access to anon users then everyone sees it, regardless of permissioning. So, whenever I hit an issue like this that I can't solve through one google, I post it for the rest of world.

Anyhow, if you've landed here looking how to trim links in general or a tutorial on the ASP.net treeview, you should go here:
http://www.asp.net/learn/videos/default.aspx?tabid=63

And check out the "Securing my site with memberships and roles tutorial". I don't feel like reposting all that content and they do a really good job in the video tutorial.

But you'll notice they leave the "enroll" link visible regardless of who is logged in. This isn't normal, and I couldn't figure out a way to trim it through the channels that asp.net provides. I finally did it by removing treeview links on the fly.

I pop this code into my secured master page template:



The key here in the PreRender event. When this fires,
I just remove the links I don't want to show up. This
code runs pre master page, so the any pages that are
supposed to have the "logged" in treeview use this template.

Sort of sucks that I had to do it that way, I'm curious if there is a better way to do it. But if you are stuck, there you go.

MYSQL Dump vs SQL Server Data Export

If you used mysql you must give praise to mysqldump. This is the shiznit of export tools. I just generates a script with inserts. When you need the data elsewhere, you just run the script! So why the hell isn't this in SQL server that has a DTS package system that can summon demons to do it's bidding but can't generate insert scripts. I'm obviously not the only one who feels this way. This fella wrote a C# app that does just that. I'm just glad I didn't have to write it. Nice job. http://www.eggheadcafe.com/articles/20040913.asp

Working with Certs in .NET

While not a complete policy, this here snippet shows you the guts of how to work with certs, validate them when working with https. Which is nice. To define an acutal policy, you just handle non-zero valoes of certificateproblem(see bottom).

The possible values are in the msdn under ICertificatePolicy.

XMLHTTP in C++

Lots of people use XMLHTTP (otherwise know as XMLHttpRequest) in VB, C# and AJAX scripting. But I had a hard time getting it running in C++ especially when dealing with conversion of strings.

Here is some code that handles it:

Thursday, August 31, 2006

Welcome.