Thursday, August 13, 2009

Things I should do before I die...

  • Take the LSAT, Apply to Law School
  • Take the GMAT, Apply to Business School
  • Get a Degree in Engineering (Structural would be cool)
  • Be Scuba certified
  • Take Wilderness Survival training
  • Own my own (successful) business
  • Learn Spanish (Fluently)
  • Learn to weld (You can make anything welding)
  • Own a Ranch

Wednesday, March 11, 2009

Massive Error: The "AllowedRelatedFileExtensions" parameter is not supported by the "ResolveAssemblyReference" task. Verify the parameter exists on th

Error:

"The "AllowedRelatedFileExtensions" parameter is not supported by the "ResolveAssemblyReference" task. Verify the parameter exists on the task, and it is a settable public instance property."

Kind of a crap error in my opinion!

Solution:

Uninstall and reinstall the .NET Framework 2.0 ( and every other .NET Framework for surety.)

If you get something like this message when going through "Install/Remove Programs" (start->control panel):

"Patch Package could not be opened"

during uninstall (like I did :((( ) then use this guy (I call him the "Software Eradicator" because he is ruthless so be careful):

Download the Windows Installer CleanUp Utility package now.

{Referenced here:http://support.microsoft.com/kb/923100}

Now reinstall:
Download details: .NET Framework Version 2.0 Redistributable ...

And I installed the service pack too:
Download details: .NET Compact Framework 2.0 SP1 Redistributable

You are back on the road again.

Grats Googlers.

-Technage

Tuesday, March 10, 2009

C#, VB.NET, ListView Groups are not showing


Listview not showing groups? This could be your problem.

Scenarios:
  • I have done everything to display groups but they refuse to display!
  • Cannot see groups in listview
  • Listview has groupings but no groups at runtime
  • listview does not show groups
  • listview not showng groups
Solution:
Application.EnableVisualStyles()

Call it at the beginning of your App, this will only effect people who decide to add this to an older app in most cases.

I ripped my hair out for a while before finding this in the documentation. Grats googlers I did the work for you.

ListView groups are available only on Windows XP Home Edition, Windows XP Professional, Windows Server 2003 when your application calls the Application..::.EnableVisualStyles method. On earlier operating systems, any code relating to groups has no effect and the groups will not appear. For more information, see ListView..::.Groups.

p.s. - Another possibility is you are viewing in details but do not have a column added.
p.p.s. - Another possibility is you do not have listview1.showgroups = true.
p.p.p.s. - You can also set this in the properties rather than calling it. (Picture below p.p.p.p.s.)
p.p.p.p.s. - If you are running anything older than XP, Server 2003, etc you cannot view visual styles and are screwed until you update.

Tuesday, March 3, 2009

Coding Suggestion Box

Prior to becoming a programming stud *manly flex* I often wanted to be able to ask real programmers questions since programming was my career path from high school. I had many long nights trying to figure out my Pythagorean command line programs in Yahoo Programming chat rooms which seemed to have few to no real programmers!

Well folks I am a real programmer, though far from the best! And I am here to lend a helping hand to coders or future coders.

I am taking this idea from Raymond Chen (Old New Thing) at Microsoft. (Raymond is the GURU at windows API and the guts of the OS, in my opinion, if you ever need to figure out how to have a remote object send a keyboard play key to the computer serving your music up to the office this is the guy to ask how to get 'er done{yes I have a "Music server" program that lets me control our office computer with speakers, hey its all the way like 15ft away I can't get up to mute the bad songs everytime!}) and opening up a suggestion box for problems people would like to see if I could solve. Not that I think I am as good as Raymond but sometimes Celeb's like him focus on their niche and can't get to little things.

I love trying to solve problems and helping people in the process is great. If I really started posting all my problems and solutions I would be on to a gold mine of posts but sometimes I just want to get my own problems behind me. So I view this as a sort of giving back, I remember when I started programming and wished there were some people I could ask questions or bounce ideas off of.

Well I am stepping up to fill that role on this blog! Just post a comment on this and I will review it and try to come up with a solution.

Lets try and stick to my focuses though (if you want a quick answer) :
  • .NET (C# or VB.NET, ASP.NET)
  • JavaScript
  • Ajax
  • SQL (MySQL, SQLServer )
  • HTML
  • XML
I am generally ok in other stuff (Java, Perl, Python, VBS) but more often I might not know.

So anyway let me know if you want to give me a challenge!

Wednesday, February 25, 2009

Dynamically adding an anchor tag with Javascript

I found a post with someone trying to add this:



<a name="Example" onmouseover="Tip('Example')" onmouseout="UnTip()">[?]</a>


to the page for each LI that has Element Search inside it.



As part of my own quest to get more familiar with Javascript I am going to take
this example on.




They need to be able to do this dynamically which means javascript on the client
side.



CODE


<li><a href="http://www.blogger.com/example.aspx">Example</a></li>




Requirments


The LI's are generated depending on user preferences, so we cannot just replace them.


We cannot alter the data pulled, only add functions after the data has loaded.







Here is what the poster had:



CODE



var items = gid('sideMenu').getElementsByTagName("li");

for(var i=0;i<items.length;i++){

    if(items[i].innerHTML == "Element Search"){

        var somehtml = document.write("<a name=\"Example\"
onmouseover=\"Tip('Example')\" onmouseout=\"UnTip()\">[?]</a>");

     
     items[i].appendChild(somehtml);

    }

}






This is a good start but Document.Write() does not really make an HTMLelement we
can grab.



Here is a different approch.  Lets use the createElement and createTextNode
functions that are on the document object.  In this way we are using the DOM
(Document Object Model) and not just writing to the document text.

CODE



for(var i=0;i<items.length;i++){

    if(items[i].innerHTML == "Element Search"){

        var anchorTag = document.createElement('a');

        anchorTag.appendChild(document.createTextNode("[?]"));



        anchorTag.setAttribuate('name', 'Example');

        anchorTag.setAttribute('onmouseover', 'Tip("Example")');

        anchorTag.setAttribute('onmouseout', 'UnTip()');

        items[i].appendChild(anchorTag);    

    }

}




If I get an example to test this I will but for now I am going to send it off to
that user.  Now we have created elements and dynamically added them using Javascript
to the DOM this should be a much more robust method.

Friday, December 19, 2008

How to know when your blog sucks

Not even the spammers comment when you allow anonymous commenting! bu-bum-CHA

Thursday, October 23, 2008

Ron White

Election over no more clutter!

Monday, October 13, 2008

It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level

It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level.

This error popped up for me when I had accidentally added some websites below my main website. This is caused by settings in the web.config's of lower subdirectories having settings that can only be on the main config's file. Settings of this type include authentication, session state.

I have heard rumor that you can leave those there by marking the folder in the following way, but I have not needed it so I cannot be sure:

Right Click on the virtual directory - select properties and then click on
"Create" next to the "Application" Label and the textbox. It will automatically create the "application" using the virtual directory's name. Now the application can be accessed.

Hopefully this is helpful to others who get an extra web.config in their subdirectories though.

Wednesday, October 8, 2008

XSL Whitespace ... Adding a XSL space between elements

I had a problem recently where I could not seperate two elements from my XML with a space. I had an XSL file where I was trying to seperate two elements but you cannot use HTML &signs; in an XSL file (you would think marking them CDATA would work but sadly no.) It was a bugger at first but I finally sorted it out this is how:

<xsl:value-of select="count"></xsl:value-of<>/span<
<xsl:text> </xsl:text>
<span style="max-width: 100px;" ><xsl:value-of select="subjecttrunc"></xsl:value-of>


Yep you see it it is as easy as adding those tags <xsl:text> </xsl:text> with a space between them of course.

Now I just need to solve showing multiple spaces, so far that has eluded me because multiple of these together still results in one space.

No great errors to post

Since I have not had any great errors I would find useful lately I have to blog about other stuff. So I will now ask a question I often ask people.

How many savage (like island cannibals) 50-60 lb. kids could you take out (immobilize permanantly or kill) before you were overrun? Assuming there is a limitless amount, you are surrounded by said limitless amount (fleeing would do no good), and they do not have to wait for a 1 on 1 fight.

I thought about this because a 2 year old 60lb pitbull would take me to town probably, but a 60 lb kid despite weight just isnt the champion a 60lb pitbull is.

Tuesday, October 7, 2008

Brand Advocacy 08

My company made a cool site: Brand Advocacy 08. The graph below which is now the battle of lightsabers was actually brand advocacy of phone brands. This site my company made is the same thing but applied to the presidential election. Totally unsolicited opinions, I believe that makes it better.

Friday, October 3, 2008

I wants...

I want:
  • to learn to play guitar mo'better
  • to learn to throw knives (or so other equally cool projectile)
  • to get Mario Kart for the Wii
  • to get the Jedi game for the Wii (one with swords)
  • to finish my stupid massive website idea and have it come to full fruition so I can be like I did that and its cool.
  • to learn to scuba dive.
That is all for now!

Wednesday, October 1, 2008

To Bail or Not

I think this is an interesting debate. I honestly am not that keen on banks and I understand that credit will tighten, but honestly. I do not think that large banks are the best creditors. Somtimes you should have at least some cash to prove your creditworthiness, and lately things have been too loose. If you jump into the freezing lake after reading the sign, "Do not jump into the freezing lake if you are prone to freezing." I do not think it is my job to jump in and save you. On the other hand, the foreclosures will not stop due to the bailout (which in my evil way {not being able to afford the crapload prices around me} I like) it is all about trying to ensure investors that money can be made in the mortgage area so that people can still buy. Honestly I think until we see the white of the eyes of our enemy we should not shoot. That is all I got for ranting today.

Tuesday, August 5, 2008

Mastering Dates

It might just be me but for a while I found dates confusing. Without a calendar I was lost, I still am, but I have resolved to do something about it. Thus I blog and hopefully ingrain it in my brain and maybe share some useful tools to others wonder about the topic. The thing I find most useful is the day of the week calculation. I find myself wondering "How do I calculate the day of the week? 18 days out, 19, 43???" So here is my attempt at overcoming it. Something they never taught us in school eh?

Regarding Months.
Any odd month before and including July has 31 Days, after that it is every even month including August. February is the outcast with 28 or 29 days depending on the leap year.

Regarding Weeks.
The easiest way I have found to Master the day of the week problem is making sure you know the days a month has. Then imagine the week as a 0 based enumeration (Sunday is 0 add 1 for each day up to Saturday 6.)

Todays Date is Tuesday, August 5, 2008
  1. Take the current day, Tuesday, which would be 2.
  2. Keeping in mind the month's number of days choose the day you need out there. Sept 7th.
  3. 31 - 5 means 26 days left in August, Plus the 7 days into September = 33.
  4. Now add 33 + 2 (current day of the week) = 35. Now divide 35 by 7 = 0. Which would be Sunday. The remainder is the day of the week from the enumeration, Sunday is 0.
This should work decently for any number and for the most part you can do this in your head. It was way easier than trying to count out the week especially far out.

Here is the enumeration in case its confusing:
  • 0 - Sunday
  • 1 - Monday
  • 2 - Tuesday
  • 3 - Wednesday
  • 4 - Thursday
  • 5- Friday
  • 6 - Saturday
If you memorize the ends and middle its easy to know the others.

I know this is random, but I just found it interesting.

Wednesday, June 18, 2008

The Last Temptation of Crust

Al Finkerton, Street Aristocrat, is enticed by a seductive pie at a Bus Stop.


One of my friends, Dax Norman, is a graphic designer who just got his masters at Ringling. This was his thesis animation, careful it is not for those with a weak stomach, it is amazing what can be done with 3D animation these days. Congratulations Dax this is awesome. Now one day when I invent my awesome game programming company I can dominate the world! (with a great graphic designer!) I just have to rip him away from those white Ipod/Iphone toting Apple weirdos. (Props to him getting a job at Apple ... Wait a second where is my Apple hookup?!) I got a DVD copy with full DVD case featuring Finkerton, the main character, along with the town as a backdrop. If you look closely you will see a sign that says, "Swee-atch" this is the invention of Dax I think anyway I find myself swapping it in often for "Sweet" lately so I thought I would give credit where credit is due. I give it two thumbs up. The title I hope you notice is a play on "The Last Temptation of Christ." A closing comment is I have never seen such a tasty bandage. You can check out some of Dax's art I really like it, I do not know if you can buy any of it, he is mostly in animation of course.

Is that done yet?

I grill allot so I find this chart useful! I also find hitting these temperatures hard but at least its safe or so it seems. So if you are curious about the cooked temperature of chicken or beef or most things this will be a useful guide. I believe this is provided somewhere else by the USDA if you want to look for it.

Meat Internal Temp. Centigrade
Fresh ground beef, veal, lamb, pork 160°F 71°C
Beef, veal, lamb roasts, steaks, chops: medium rare 145°F 63°C
Beef, veal, lamb roasts, steaks, chops: medium 160°F 71°C
Beef, veal, lamb roasts, steaks, chops: well done 170°F 77°C
Fresh pork roasts, steaks, chops: medium 160°F 71°C
Fresh pork roasts, steaks, chops: well done 170°F 77°C
Ham: cooked before eating 160°F 71°C
Ham: fully cooked, to reheat 140°F 60°C
Ground chicken/turkey 165° F 74°C
Whole chicken/turkey 180° F 82°C
Poultry breasts, roasts 170° F 77°C


Steak done!
Pork done!
Chicken done!
Grill Done!
and
I'm done!

Wednesday, June 11, 2008

Do you ever look at it...

And go, “Sweet cheese who came up with that syntax, I think if I could write a compiler I would come up with something more elegant than that load of crap.” I do.

For i As Integer = 0 To msgids.Length - 1

‘Do some crap

Next



I hate the for loops in VB, they are something totally different and crappy than any other for loop I have crossed in my life. I was thinking about this while coding and just had to share and see if anyone else out there agrees. VB.NET For loops go like this:

For i As Integer = 0 To msgids.Length - 1
'Do some crap
Next


The "To" is just so dumb, so assumptive and stupid! Now lets look at C++ derived for loops.


for(int i = 0; i < msgids.Length; i++)
{
//Do some crap
}

(In case it stays like that pretend < is actually a less than sign /shrug)

Is it just me or is the C++ style so much more elegant and so much more clear. You do not have to make assumptions you know that what we compare to each time is i but you also know you could change that at anytime to be j*i or whatever, robust and clear vs. odd and assumptive.

After programming in VB.NET for oever a Year (company forced) I have to say I missed the hell out of C++ based languages, luckily my current projects which I will reveal eventually have gotten me back into C#, Javascript, etc where the For loop actually seems logical again.

Rant over and out.

Tuesday, June 10, 2008

AJAX+ASP.NET = Win: Screw the Iframe idea ... at least for now...

Last post I talked about using an Iframe to delete a relation between two objects. Well I changed my mind and decided to go the Javascript only route with a XMLHttpRequest object. Basically this is AJAX or something very close to it and worked amazingly well. I was concerned that I would not be able to leverage ASP.NET like so many people leverage Java to use pages to return something other than a page, but I figured out a way around that (which I show at the very bottom.)

This is obviously an Intro to Ajax type situation. This is not a big class but a simple method to do an XMLHttpRequest. You could write a larger overarching Ajax framework, but this example shows the basics behind it.
The script I used is this:

This is the script to make the actual sender, it takes into account the different browsers we might have to accomodate.


XMLHTTP VAR Code:

var xmlhttp


if


(!xmlhttp && typeof XMLHttpRequest!='undefined')


{


   try


   {


     
xmlhttp = new XMLHttpRequest();


   }


   catch (e)


   {


      xmlhttp=false;


   }


}


if (!xmlhttp && window.createRequest)


{


   try


   {


      
xmlhttp = window.createRequest();


   }


   catch (e)


   {


      xmlhttp=false;


   } 

}


This section does a call to the ASPX Remove page passing it the parent and child id's. If the return is false, this means we did not have an error, otherwise we did and we use our favorite Javascript Debugger Firebug to figure out what the problem is. Luckily I have tried this code and it fits my needs and works perfectly. (I do know that run is probably the dumbest function name ever, but I didnt even expect this to work :). I guess I should change it!)



Example Code:



function run(i , j, element)


{


  
//This grabs the element name we passed which when we remove we are hiding


  
element = element + "";




  
//The URL of the aspx page that is going to accept this request and


  
// delete the relation in the database



  
url="./remove.aspx?pid="+i+"&cid="+j



  

//The meat! We use the xmlhttp from the code that creates it way above 

   //We are using the "GET" method, sending it the URL, and true means asynchronous response.


  
// this is not sending the request just creating the object, we send further down.



  
xmlhttp.open("GET",url,true);



  

// Now we defie an function to handle when the status of the XMLHttp object changes.



  
xmlhttp.onreadystatechange=function()


   {


       // ReadyState = 4 means all done


      
if (xmlhttp.readyState==4)


       { 

         
//Read the response text, In my case I am only returning


         
// false when the backend was unable to process the move


         
// so we should probably have an else to show failure but I didnt do that yet:)


         
if(xmlhttp.responseText == "false") 

          { 

            
document.getElementById(element).style["visibility"] = "hidden"; 

          }


       }


   }


  
//I tell the backend that this is a form 

   xmlhttp.setRequestHeader('Accept','message/x-formresult')




   // I send the request


  
xmlhttp.send(null)

return false

}



Now if you are anything like I was when I started off down this path you might be wondering, well wtf does remove.aspx do??? I will show you that too but if you only cared about the java you are done :).





This is the only function in Remove.aspx and all it does is send back the exceptions/"" or the word false if it was executed successfully.

The Response.End is particularly important so that you only send what you write to the Response, otherwise it will send whatever design etc that is included in the actual page and that would just be crippling yourself because you would have to sift through all that crap on the Javascript side.

So this is sort of a way to give yourself utility function calls with no UI problems. Technically this might be mixing UI and Business logic but the sheer power it provides is just too powerful to pass up.


ASPX CODE:


protected void Page_Load(object sender, EventArgs e)


{


  
int parentid;


  
int childid;


  
cret ret = new cret();


  

if (Request.QueryString["pid"] != null && Request.QueryString["cid"] != null && Int32.TryParse(Request.QueryString["pid"], out parentid) && Int32.TryParse(Request.QueryString["cid"], out childid))
{
Response.ClearHeaders();
Response.ClearContent();
Response.ContentType = "text/plain";
ret = DBData.removeParentalLink(parentid, childid);

Response.Write(ret.err);
Response.End();

}
}


If there are any questions or comments feel free.

Monday, June 9, 2008

The Iframe workaround

I am programming in ASP.NET and one of the unfortunate results of this is that you have to basically load a page each time that you want to perform some action because it is a server based language. So I was going to have to do a page redirection and reload on a page that wants to remove a relation between two objects because you have to know what both objects are and there will be several choices on the page so it is not as easy just knowing them like so many things on pages are. Well I am going to do some quasi AJAX to use javascript to call a URL change to a .src in an iframe to get around this annoying little feature, this way we remove the relation without having to disorient the user with page change. So I will call removeLink.aspx?id1=22&id2=55 and we will remove the relation between 22 and 55. GENIUS! If this works pretty well I will post the basics of how to do it I am blogging this so I remember to do it as well.

Wednesday, June 4, 2008

I did a century - Reach the Beach

It was hard but fun and I never posted about it here because I guess I forgot I have been putting my biking accomplishments up here, but other than the century I have totally wussed out in the biking area, I have not ridden to work recently but immediately after the race I came down with flu/pneumonia-like symptoms, I am still hacking up some gnarly loogies. I am pretty happy about having done this though, if I had to do it again, I would pass, we did one hill that was straight up 800ft of elevation gain, I would rather do rollers all day than have a bunch of giants to conquer and that is what we had sections of giants that made you just want to lay down on the road and call the sag team. Interesting events included seeing (then doing) a run through a graveyards sprinkler system. We tried to keep it as respectful as possible by waiting for the sprinklers to come back to the roads or paths to throw ourselves into them. It was also the hottest set of days I have seen in Oregon spring time it was 95F+. I was also called a genius by several people, as they joined me sitting under the one shade tree on an exceptionally long jaunt through the treeless Oregon farmland. It was fun though!

.NET MySQLConnection - How to handle it...

I am trying to figure out the best way to handle a MySQLConnection in C#, though in reality any connection has the same principles (SQLServer, ODBC, etc.) Basically from what I understand Opening and Closing the connection is slow, so I want to minimize my open and closes, however I have to do several things when adding database objects and I also want to minimize the length of functions and allow repititious code to be reused.

So we have conflicting goals:
  • Open and close DB connection as little as possible
  • Break up long functions into smaller callable functions (so that adding relations for instance can be called without adding two or even one object to relate)
It's bad because when you go from one function to another it is always scary to send it the connection out (or byref) which is how I think I would have to send it for its open state to be maintained and so that you do not have to sit there and run the risk of opening multiple connections to the database if you pass it by value.

My ultimate solution to this quandary:
  • Public static MySqlConnection in the DBData Class which can be referenced within each function and its state can be checked and maintained (if you opened it you close it, if it was open you leave it)
I am not sure if this is the best option but it gives me the most flexibility and so far has come off without a hitch, that I have noticed anyway. I welcome comments or other suggestions and thoughts.

Thursday, May 29, 2008

JavaBat

http://javabat.com/

Interesting introduction or refreshment on Java. Provides little programming problems and runs test cases against your function to make sure its doing what it is supposed to. These are nice little teasers especially towards the complicated side that you don't normally have to face but give you some good insight.

Wednesday, May 28, 2008

Great duplicate removal query...

This is a great query to replace duplicates within a table, the define characteristics are comapring a series of fields that should be the same and then using the unique ID identifier between the table aliases A and B so that you only delete the greater ID. In doing this you will leave the lowest ID giving you one unique row the lowest ID row. Very Great!

delete Table_1 A
where exists
(select * from Table_1 B where A.field_1 = B.field_1 and A.field_2 = B.field_2 and A.field_3 = B.field_3 and A.field_4 = B.field_4 and A.id > B.id)

Thursday, May 22, 2008

Error - GetTypeHashCode() : no suitable method found to override

I usefully hijacked this from: http://blog.stackley.net/article.php?story=20070117165732356

I found it very useful so I want to propagate it. I found a need for it while transferring my site from vb.net to C#.


After creating an ASP.NET web form using Microsoft Visual Studio 2005 Team Suite, I renamed the form from it's default name "Default.aspx" to a more user-friendly name "Order.aspx" within MS VS. After adding more code to the C# code-behind page, I discovered the following line: "public partial class _Default"

Being new to the ASP.NET programming language, I changed the "_Default" to "Order" thinking MS VS had failed to rename items within the code it generates. This caused the following error to display at debug/run time: "GetTypeHashCode() : no suitable method found to override"

There were several other errors displayed as well.

The class names must match between the .aspx and .aspx.cs web pages. Here is what the lines in each file should look like:

In the ASPX source file: %@ Page Language="C#" codefile="FormName.aspx.cs" Inherits="FormName_aspx" %

In the ASPX.CS source file: public partial class FormName_aspx : Page

Once I changed the .ASPX file to match the class name in the .ASPX.CS file, the errors were resolved.

Thursday, May 8, 2008

PHPAdmin does not allow Stored Procedures

I tried very hard to add stored procedures to my MySQL database that is being served on my webserver. I converted my code from the SQLServer code I have gotten more used to writing (until 5.0 MySQL had no stored procedures) the syntax is not quite the same but close enough to just iron out the kinks and throw it into MySQL ... or so I thought. I removed all the syntax changes I saw needed from the MYSQL 5.0 Manual (which is a nice resource) well I was going into one of those pits where you know something is wrong and the fix is not obvious. I assumed it might be the fact I needed to change the delimiter so I tactfully added "DELIMITER ?" which did not help at all. I could tell this was the problem though something was wrong with the delimiter because I would get a slight change in some functions removing verses adding the semicolons. Finally I searched "PHPADMIN STORED PROCEDURES" on google and I found what I needed it was right there on the site the whole time but not placed very tactfully in my case. The solution was staring me in the face at the bottom of the PHPADMIN page, in the bottom under the SQL syntax textbox was a textbox labeled delimiter with a semicolon in it. I changed that to \\ because that is what the post suggested and violas. Stored procedure added.

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

Engrish.com

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)

System.Text.RegularExpressions.Regex.

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()

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



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: 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.
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.

THE CODES:

FindForm.VB




FindForm.Designer.VB

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!