Monday, April 28, 2008

Green Peace overshoots

Recently I have seen some articles touting the fact that Green Peace is on this whole issue of polar bears drowning. Reading about it recently reminded me of when my cousin, visiting me, was stopped in the street by one of greenpeace's minimum wage professional botherers (PB's)(job description: Stand firm with notebook, as someone comes by pretend to want to engage in friendly conversation then spring angry guilt trap!) Anyway the PB told my cousin that the polar bears were drowning because of global warming because they swam out to sea hunting seals. Dying because they were out of food, blah blah blah, gimme money. "Do you understand why we need your support and money?" asked the PB. "Yes," responded my cousin, "because you are going to ship food down to the polar bears. I am totally on board with that." PB, "... ... Um, no that is not what I meant I mean to fight global warming?" Cousin, "Why would you want to do that when we have the obvious polar bear problem?" I loved that it was the funniest, wittiest comment I have seen shot at one of the PB's. TTFN.

Tuesday, April 22, 2008

A personal favorite, this site is hilarious. You should totally check it out. The blatant slaughtering of the english language, I know that I am not a master of their language, so I should not talk so much smack, but it is just how some people try to go over the top and explain or use too much that is so hilarious.

Monday, April 21, 2008

Biking for the groceries

I successfully biked for groceries yesterday. This included going up a giant hill both directions (I live next to a river, therefore I am in the river vally the only safe route out makes you go up that hill then to get back you have to do that same climb in the other way.) I had to leave my bike outside unguarded as I speedwalked to pick up 2 cartons of milk (skim and whole, whole is for my coffee I am that picky) and three blocks of cheese, I got several odd looks since I was in full bike gear and forgot to take off my helmet. At least the cash register guy was impressed. I need a new bag though my current one is killing me. Though I have found a way to make it fit securely on my back. Anyway thats what I have been up to.

Friday, April 18, 2008

Taking Biking to a whole new area.

Honestly this was just too funny and cool not to share. Taking biking to a whole new level. Some canadians decide to take a piece of art made from an old buick regal and tons of bike parts (a statement about consumption) and take it on a joyride around Toronto. This bike-car hybrid supposedly has a max speed of 9.3 mph(15 km/h.) I say POSH!, lets get the US biking team in that bad boy and show em what that baby can do. Talk about a gas friendly hybrid :).

Tuesday, April 15, 2008

D'oh! - My Overcomplication of Regex

Some more screwing around with regex more has made me realize I have overcomplicated capture replacement, it is a simple as using a replace and just throwing in the $1, etc into the Regex.Replace functions replace string. I mean what I do works but it is totally unnecessary so I thought I would throw that out there. Apparently they already though of that when they did replace, I wonder why they didnt think of the tristate check treeview since a checkbox can be tristate. Sometimes it is better not to ask why!

The way I did it works well enough but you can see how it could be done below without a temp variable, and it is a little less confusing than using Regex.Result.

Anyway I thought I should share my ignorance, and enlightenment.

ElseIf cbRegEx.Checked = True AndAlso System.Text.RegularExpressions.Regex.IsMatch(txtfind.Text.ToLower, cmbFind.Text) Then
If System.Text.RegularExpressions.Regex.IsMatch(txtfind.Text.Substring(txtfind.SelectionStart, txtfind.SelectionLength), cmbFind.Text) Then

'Smarter, less lines System.Text.RegularExpressions.Regex.Replace(txtfind.Text.Substring(txtfind.SelectionStart, txtfind.SelectionLength), cmbFind.Text, cmbReplace.Text)

'Dumber Many more lines, except the highlighting which is needed
Dim mc As System.Text.RegularExpressions.Match

mc = System.Text.RegularExpressions.Regex.Match(txtfind.Text.Substring(txtfind.SelectionStart, txtfind.SelectionLength), cmbFind.Text)

temprep = cmbReplace.Text

temprep = mc.Result(cmbReplace.Text)


Dim tempstart As Integer = txtfind.SelectionStart

Dim templen As Integer = txtfind.SelectionLength

txtfind.Text = txtfind.Text.Remove(tempstart, templen)

txtfind.Text = txtfind.Text.Insert(tempstart, temprep)

txtfind.SelectionStart = tempstart

txtfind.SelectionLength = temprep.Length

pastend = FindIt()


pastend = FindIt()

End If

Monday, April 14, 2008

One of the coolest web development tools I have seen. Firebug is a firefox add-on that gives you insane website visualization abilities right inside of fire fox. Want to see what that menu would look like unbolded and a different color, its as easy as going to the firebug CSS tab and clicking those CSS features off. I have to say I am super impressed just looking at the highlighting alone will amaze you. Given you should probably not design everything for firefox, but jeez this is a powerful tool.

I forgot to mention, its free. And it allows you to look at any sites inner workings, it is really nice. So you can see how that great site did its design, very cool.

Sunday, April 13, 2008

Sunburn's Nasty Bite

My arms look allot like this guys. This weekend was a lesson why as a coder (usually a dark, yet monitor lit, room dweller) you should not go off on a whim and ride a bike 60+ miles on the sunniest day Oregon has had all spring. I think it should be a lesson to all coders do not let your loved ones convince you to do crazy things like riding 60 miles in training for riding 100 miles. Some will try to throw out the snarky "Heard of Sunblock?" line, but I am a man dangit. I am not wearing no sissy sun block, me and this guy to the left says so. Luckily my arms usually mist over into a tan, I doubt the guy left can say the same.

On the plus side it was fun to ride 60 miles and be like , I did that I went how far I go in a car in one hour, the same distance in 5-6 hours ... ok it does not sound good when you say it that way ... but I have no combustion engine and did it, there that sounds better. The only bad thing is when you are out 15 miles from no where and go "Geez ... if I hit a piece of glass I am screwed because I did not bring an extra tube." It would suck to walk 15 miles to No Where (Dayton, OR) and try to find a tube there. I am not kidding about it being no where, they do not have a single chain restaraunt, and the only stoplight in town is just a blinking light. Careful also the only restroom in the park is a Honeybucket with some suspect liquid puddling in the bottom of the floor. Laters.

Friday, April 11, 2008

My Homage to OCR A Extended

A true programmer will have noticed my title is indeed OCR A Extended. I find OCR A Extended to be one of the best programming fonts because it is monospaced (fixed width) font. It has great readability when it comes to coding, it also gives clear distinctions between all characters(OCR being optical character recognition should give this away!)

The bottom line to the right left (I hated to look on the right) gives a prime example, notice the O(oh) out front is different from the 0 (zero) and the Z is different from the 2. This is also true with 1 and l among the various other font faux pas. It is critical to development to be able to tell what is what and that is one reason I like OCR A Extended. I would not want to read a novel in it but when coding I find this font to be a step above the rest. The look also has that classic computer tech look so that you know you are working on code not Gigi's Wedding invitations. Which is obviously not great for reading code! I think I will make a poll, even though my blog still lays undiscovered like a cautious lion ready to strike ... Where was I? Anyway comment if you agree or disagree. Ciao!

Thursday, April 10, 2008

Find Replace Regex (regular expressions) Form, VB.NET (.NET Framework)

My latest tool, Standalone Find/Replace in VB.NET, to be added on anywhere (including your and my existing projects!) It is a simple standalone find replace form which uses a reference to a object to search it. You will probably only find this useful if you, like I, have to accommodate higher end users doing text editing (usually REGEX stuff in my case.) It is also a good example of leveraging Regex better than many I have seen elsewhere so I thought I would share it. It could be easily ported to C# using SharpDevelop.

It currently accepts the reference to a listview or textbox (with the idea of leaving room for other items I may find useful in the future) and finds text normally or using REGEX matching (.NET regexs, Rock on.)

I have not implemented the replace in the listview because I myself display tables or objects using a listview, but the listview is just to give the user an idea of what is going on in the object behind the scenes and editing the listview will have no effect on the object (unless you wanted to write a listview to object backward conversion for everything you do). Therefore, if you want it to work on your own objects you would have a code that in on your own, and if you want it to replace in listviews you will have to do that too! (unless I suddenly find the need) I think the find option alone on a listview is great though. The "Include subitems" checkbox is listview specific to be able to search all columns or not, optionally.

I got most of the motivation for the GUI from EditPlus a great text editing program which also has a powerful regular expression find replace built in I highly suggest it.

The options:
  • Include Subitems - As I said above this checkbox makes it where you can search all columns of a listbox instead of just the first, though you can turn it off when you are only concerned about the first column (or text) of the listviewitems.
  • Use Regex - makes the top box search by regular expression and has the bottom box replace by regex one of the great options is you can capture in the top area and then put those back in with $1, $2, $3, etc.
    • For instance (This is a bit complex but most would probably get it):
      • Topbox: (ab)(c) Bottom box: $2$1 Text found: abc Changed to: cab
      • Topbox: (http://)[^\.]+(\.[^/]+/) Bottom Box: $1technage$2 TextFound: Changed to:
  • Search Up - Changes from searching in the downward direction to searching in the upward direction.
This makes heavy use of general string functions as well as System.Text.RegularExpressions.

It contains a great use of MatchCollection.Result() which handles the reinsertion of the captures.

I can do some more chatting and example giving but for now I want to throw it out there and see if anyone has questions or is interested.

Sorry for the crudeness of the textboxes below, but I do not have a real place to host the files except on this blog. And due to the fact these are very small I just put them down there in the text areas to be copied out. If that is too annoying I can add them in a pre.

The codes I have published below are a great example for why one should have a replacer like this because the carriage returns in normal code for VB.NET are resulting in <br />'s to be placed in the code. I assume its a blogger bug, but if anyone knows a great trick to fix it that would be great I looked at some of the FAQ and the groups discussion no one had a definitive way to fix the problem except for removing the carriage returns, but for proper coding format that is the dumbest idea ever. Do people actually use Textarea for something other than displaying code???

NOTE: So use the tool to fix the code once you have compiled it, have it replace the double tabs (\t\t) with a single newline (\n) in regex mode. That should make it pretty again.




Wednesday, April 9, 2008

Blog of a Tech Fiend

This blog is to be devoted to my tech crap, programming and life in general, but the big news today is I commuted to work today on my brand spanking new Bianchi road bike. It is a 10 mile commute with a ton of large hills, so I am impressed I made it. I have to admit there were times I said, F this I am going to go back to the bus, but I persevered, CARPE DIEM! Yes, it is too cool for school. I decided to start a blog maybe to share random pieces of code and projects I have invented, so enjoy crazy world, though mainly I expect to go unnoticed!