house9

random code and what not

TFS and the pain

We have been using TFS (Microsoft Team Foundation System) at work for Source Control for a few months now; we’ve run into numerous issues none of which I am going to get into now; this post is really just some notes for my future reference.

if you get into real trouble with TFS the following steps should almost definitely get you back to a fresh place
  • Start -> Programs -> Visual Studio 2005 Tools -> command line
  • tf workspaces
  • - this will show you your workspace name; probably the same as your machine
  • tf workspaces /remove:*
  • - this will remove local system cache of TFS
  • tf workspace /delete /server:{servername} {workspacename}
  • - this will remove from the server
  • - it will prompt you to verify - type in y
  • tf workspace /new /server:{servername} {newworkspacename}
  • - this will launch the GUI to map the server to your local system
  • - server = $/
  • - local = C:\TFS
  • cd C:\TFS
  • tf get
  • - pull down all the files

This maps the root of the TFS server to C:\TFS, you may of course want it mapped to another location on your drive.

Check out tf command on msdn

First Rails Project

so off and on the last month I have messed around with bits of rails stuff; reading books, coding associations, migrations, and installing plugins - oh yeah! ActiveScaffold is very sweet! finally got the integration with FCKeditor and the calendar control working as well; so now I am ready to actually build a web site.

a few years back I built a site for my wife’s cycling team. It is a pretty simple site but with data driven content, this seems like a good project to convert over to rails as it will give me a little bit of everything. So here we go…

Day 1 - 2007.09.21 2:00pm

rails nor_cal_velo, add it to svn, create a blank database on mysql, then onto the migrations; already had the database tables pencil sketched on paper, similar to what I had before in the previous site but this time a little simpler as I will be using ActiveRecord (of course) and not stored procedures…

4 hours later: migrations and db created, active scaffold hooked in and up and running for a single controller; but got side tracked trying to push before_create_save event down into a controller base class as I do not wish to duplicate the same code for every controller.
Posted to active_scaffold groups, got to be a way around this
http://groups.google.com/group/activescaffold/browse_thread/thread/58bc7fae33b62a57

going to do some html / css stuff for awhile and get the layout section taken care of then onto more active scaffold controllers

Day 2 - 2007.09.22
spent a few hours tweaking css overrides for active scaffold and figured out the issue with the controller base class see the thread above for the solution. Still have a small glitch with overrides of the Delete function, I am setting the is_active flag to false instead of actually deleting the record, everything works great except the ajax code actually removes the record from the visible list of records, if you refresh the page the inactivated record reappears and is marked as is_active = false as it should be

Side Tracked
Ok, got side tracked messing around with rails and some fun ajax stuff, my first rails project has changed to something much smaller in scope; I’ll be back on this project at some point though as long as the day job doesn’t consume me…

Ruby Notes - part 1 - dynamic object creation

I am starting to learn Ruby and Rails (just for fun) - took awhile to find a good example of creating an object at runtime given a string representing the objects name; finally came across this post http://www.ruby-forum.com/topic/96222;

in theses 2 examples - given an ActiveRecord object ‘Project’ and a database table named ‘projects’, invoke the Project and execute some methods on it

# using eval
def test_dynamic_invoke_with_eval
__object_name = “Project”
__o = eval(object_name)

__p “object name is ‘” + o.to_s + ”’”
__p “object table name is ‘” + o.table_name + ”’”
end



# using Object.const_get
def test_dynamic_invoke_with_object_const_get
__object_name = “Project”
__o = Object.const_get(object_name)

__p “object name is ‘” + o.to_s + ”’”
__p “object table name is ‘” + o.table_name + ”’”
end



Check the ruby forum link above as well - the last entry posted by ‘unknown (Guest)’; this is probably the true ruby way to do it? extend the String object with a helper method so you can turn any string into an object? code from that post

# extend String
class String
__def to_class
___Object.const_get(self)
__end__
end

Comments

Ahmed
Thank you very much for this article! It helped me creating an array from a string that represents nested arrays inside it (tree) without the need to parse the string to identify braces.

Best,
Ahmed Nabhan

Ruby and Rails

Taking a few hours a week to try and learn Ruby and Rails

notes and links for future reference

Books

Ruby and Rails resources

IDE and text editors for Windows

Some notes and code stuff

Ubuntu really is easy

Just installed Ubuntu Desktop on my ‘old’ (not that old really) Dell Dimension 2400 Celeron. Don’t use this computer much anymore and have been wanting to check out Ubuntu.

well the install was way too easy.
- downloaded the iso image from http://www.ubuntu.com/getubuntu/download
- burned it to a cd using
InfraRecorder
- put that in the old 2400 and selected boot from CD-ROM
- Ubuntu OS booted from the CD and I was up and running at that point; but only from disc
- Had to click the install short cut on the desk top and wait a short while


That was it - no driver issues at all!!!
I was on my network and downloading the Ubuntu updates immediately, browing the internet with FireFox and watching avi files with Totem …

One really cool thing with Ubuntu (maybe Linux in general?) with out any additional installs I could navigate to my other Windows machines and pull files off the File Shares; simple as going to ‘Places’ -> ‘Network’ -> ‘Windows Network’ -> selecting the machine to browse to

Later I might look into setting up Samba so I can share from Windows to the Linux machine

Definitly going to install the Ubuntu Server Edition on my laptop soon and create a simple web site using Ruby on Rails, just need to find that ‘extra’ time

Thanks to my Dad for turning me on to Ubuntu!

What would Kwai Chang Caine do?

What would Kwai Chang Caine do?

we’ve all heard of ”What would Jesus do?”, but at this point I am more interested in what Kwai Chang Caine would do;

here are just a few great quotes from the Kung Fu series, I don’t want to list too many as each should really be cherished on it’s own…


“If one’s words are not better than silence, one should keep silent.”

“In every loss there is gain. As in every gain there is loss.”

“Our soul does not keep time, it merely records growth.”

And my favorite…
“I seek not to know all the answers but to understand the questions.”

Comments

Anonymous
"We own nothing. Even our bodies are loaned to us. Empty shells. Concentrate on the infinite and ignore the temporal." - Kwai Chang Caine

Kung Fu revisited

Kung Fu revisited

I recently got a chance to watch the first season of ‘Kung Fu’ (starring David Carradine) on DVD; I had not seen this show since I was a kid. I really did enjoy it then, but I really appreciate it alot more now and for different reasons; then it was all about the kung fu action, the wild west and Shaolin priests;

It is amazing how this show doesn’t really feel very dated, well maybe just a little but in that cool 1970’s kinda way. I highly recommend that you watch this show - especially if you have never seen it.

Check out http://www.kungfu-guide.com/ for indepth information on the show or just go to Amazon and order the first season - you will not be disappointed!

http://www.amazon.com/exec/obidos/ASIN/B00013F38K/continguidetothe

Selenium and file uploads

I have recently started using Selenium for testing web applications; pretty sweet (you know it had to be good coming from ThoughtWorks); anyhow I ran into an issue with testing File uploads; after a couple of Google searches it turns out that Selenium is using javascript requests to manipulate all the html controls and there is a built in security feature (in the browser) that does not allow file uploads to be controlled via javascript. This is probably a real good thing, I sure wouldn’t want personal files being randomly uploaded to someone else’s web server.

Anyhow if you simply change the browser string to *chrome it will work (at least against localhost, haven’t tried it against any of our beta sites yet)

selenium = new DefaultSelenium(“localhost”, 4444, *chrome”, http://www.google.com/);

Read more about chrome and other experimental browser launchers here

More on Selenium
Selenium uses JavaScript and Iframes to embed a test automation engine in your browser. This technique should work with any JavaScript-enabled browser. Because different browsers handle JavaScript somewhat differently, we usually have to tweak the engine to support a wide range of browsers on Windows, Mac OS X and Linux.
- From http://www.openqa.org/selenium-core/