Monday, April 28, 2008
Green Peace overshoots
Tuesday, April 22, 2008
Engrish.com
Monday, April 21, 2008
Biking for the groceries
Friday, April 18, 2008
Taking Biking to a whole new area.
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
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()
Else
pastend = FindIt()
End If
Monday, April 14, 2008
http://www.getfirebug.com/
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. http://www.getfirebug.com/
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
The bottom line to the
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: http://www.blogger.com Changed to: http://technage.blogger.com
- Search Up - Changes from searching in the downward direction to searching in the upward direction.
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.
THE CODES:
FindForm.VB
FindForm.Designer.VB