<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-14193236281833595</id><updated>2011-11-27T17:07:31.533-08:00</updated><category term='ruby'/><category term='regex'/><category term='jquery'/><category term='csharp'/><category term='postgresql'/><category term='tfs'/><category term='javascript'/><category term='unit test'/><category term='sql'/><category term='rails'/><category term='nant'/><category term='code'/><category term='xhtml'/><category term='rjs'/><category term='rhino.mocks'/><category term='mssql'/><category term='rake'/><title type='text'>Code Samples</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://house9-code-samples.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/14193236281833595/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://house9-code-samples.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>House 9</name><uri>http://www.blogger.com/profile/08045832658861127427</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>20</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-14193236281833595.post-4689517809895899705</id><published>2010-03-23T08:32:00.000-07:00</published><updated>2010-03-23T08:45:24.452-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='rails'/><title type='text'>sorting rails view with will_paginate plugin</title><content type='html'>This solution for sorting data on rails index actions does NOT use ajax. Sometimes sorting with ajax is nice but often it is not actually as user friendly; breaking the browser back button, etc...&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Disclaimer 1: this code is probably using all kinds of ruby anti-patterns :) - but it is a very simple implementation and so I just went with it...&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Disclaimer 2: the title of the post might be a little miss leading as you can use this with or without the &lt;a href="http://wiki.github.com/mislav/will_paginate/"&gt;will_paginate&lt;/a&gt; plugin. In my case I am using it with the &lt;a href="http://wiki.github.com/mislav/will_paginate/"&gt;will_paginate&lt;/a&gt; plugin - and I highly recommend it!&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;put this file in your rails lib directory /lib/sort_index.rb&lt;/div&gt;&lt;div&gt;&lt;script src="http://gist.github.com/341278.js?file=sort_index.rb"&gt;&lt;/script&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;in your controller code, set up the SortIndex::Config (you can have more than one if you have multiple actions that need to support sorting&lt;/div&gt;&lt;div&gt;&lt;script src="http://gist.github.com/341290.js?file=sort_index_controller_usage.rb"&gt;&lt;/script&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;then in your view code render your table headers using the sort object&lt;/div&gt;&lt;div&gt;&lt;script src="http://gist.github.com/341295.js?file=sort_index_view_usage.html.erb"&gt;&lt;/script&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Does not support the following:&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;additional attributes on the anchor tags&lt;/li&gt;&lt;li&gt;additional attributes on the table header tags&lt;/li&gt;&lt;li&gt;additional query string parameters - might add this later, would be nice for search results&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/14193236281833595-4689517809895899705?l=house9-code-samples.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://house9-code-samples.blogspot.com/feeds/4689517809895899705/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=14193236281833595&amp;postID=4689517809895899705' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/14193236281833595/posts/default/4689517809895899705'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/14193236281833595/posts/default/4689517809895899705'/><link rel='alternate' type='text/html' href='http://house9-code-samples.blogspot.com/2010/03/sorting-rails-view-with-willpaginate.html' title='sorting rails view with will_paginate plugin'/><author><name>House 9</name><uri>http://www.blogger.com/profile/08045832658861127427</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-14193236281833595.post-8786394631213865767</id><published>2010-01-06T10:03:00.000-08:00</published><updated>2010-01-06T10:10:08.689-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ruby'/><title type='text'>Ruby Http Get with Net::HTTP</title><content type='html'>&lt;script src="http://gist.github.com/270459.js"&gt;&lt;/script&gt;&lt;br /&gt;Resources&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://ruby-doc.org/stdlib/libdoc/net/http/rdoc/classes/Net/HTTP.html"&gt;Net::HTTP ruby docs&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://stackoverflow.com/questions/1252210/parametrized-get-request-in-ruby"&gt;Stackoverflow post&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="display:none"&gt;&lt;br /&gt;require 'net/http'&lt;br /&gt;require 'uri'&lt;br /&gt; &lt;br /&gt;def get_html_content(requested_url)&lt;br /&gt;  url = URI.parse(requested_url)&lt;br /&gt;  full_path = (url.query.blank?) ? url.path : "#{url.path}?#{url.query}"&lt;br /&gt;  the_request = Net::HTTP::Get.new(full_path)&lt;br /&gt; &lt;br /&gt;  the_response = Net::HTTP.start(url.host, url.port) { |http|&lt;br /&gt;    http.request(the_request)&lt;br /&gt;  }&lt;br /&gt; &lt;br /&gt;  raise "Response was not 200, response was #{the_response.code}" if the_response.code != "200"&lt;br /&gt;  return the_response.body       &lt;br /&gt;end   &lt;br /&gt; &lt;br /&gt;# this will fail with ArgumentError: HTTP request path is empty&lt;br /&gt;s = get_html_content("http://www.google.com")&lt;br /&gt;# these should be fine&lt;br /&gt;s = get_html_content("http://www.google.com/") &lt;br /&gt;s = get_html_content("http://github.com/search?q=http")&lt;br /&gt;# above code does not handle redirects but raises exception for non-200 &lt;br /&gt;s = get_html_content("http://www.yahoo.com/") # http 302&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/14193236281833595-8786394631213865767?l=house9-code-samples.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://house9-code-samples.blogspot.com/feeds/8786394631213865767/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=14193236281833595&amp;postID=8786394631213865767' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/14193236281833595/posts/default/8786394631213865767'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/14193236281833595/posts/default/8786394631213865767'/><link rel='alternate' type='text/html' href='http://house9-code-samples.blogspot.com/2010/01/ruby-http-get.html' title='Ruby Http Get with Net::HTTP'/><author><name>House 9</name><uri>http://www.blogger.com/profile/08045832658861127427</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-14193236281833595.post-3625095906681473058</id><published>2010-01-06T09:56:00.000-08:00</published><updated>2010-01-06T10:02:09.714-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ruby'/><category scheme='http://www.blogger.com/atom/ns#' term='regex'/><title type='text'>Ruby Regex to remove script tags</title><content type='html'>&lt;script src="http://gist.github.com/270463.js"&gt;&lt;/script&gt;&lt;br /&gt;Resources&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://rubular.com/"&gt;Rubular&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://jamesmckay.net/2008/05/how-to-match-any-character-including-newlines-in-a-javascript-regular-expression/"&gt;Match any character in RegEx&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://ruby-doc.org/core/classes/String.html#M000817"&gt;Ruby String gsub&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/14193236281833595-3625095906681473058?l=house9-code-samples.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://house9-code-samples.blogspot.com/feeds/3625095906681473058/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=14193236281833595&amp;postID=3625095906681473058' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/14193236281833595/posts/default/3625095906681473058'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/14193236281833595/posts/default/3625095906681473058'/><link rel='alternate' type='text/html' href='http://house9-code-samples.blogspot.com/2010/01/ruby-regex-to-remove-script-tags.html' title='Ruby Regex to remove script tags'/><author><name>House 9</name><uri>http://www.blogger.com/profile/08045832658861127427</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-14193236281833595.post-820072932624060179</id><published>2009-09-25T07:58:00.000-07:00</published><updated>2009-10-07T07:30:43.632-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='xhtml'/><category scheme='http://www.blogger.com/atom/ns#' term='jquery'/><title type='text'>Attribute "target" exists, but can not be used for this element.</title><content type='html'>These days I am all about valid xhtml and was surprised to receive this validation error when using the target attribute on an anchor tag.&lt;div style="font-style: italic;"&gt;&lt;blockquote style="background-color: yellow;"&gt;Attribute "target" exists, but can not be used for this element.&lt;/blockquote&gt;&lt;/div&gt;&lt;br /&gt;&lt;script src="http://gist.github.com/193604.js"&gt;&lt;/script&gt;&lt;br /&gt;&lt;div&gt;I found a nice work around that does not involve window.open, using jquery we can hack the attribute on 'after' the dom has loaded.&lt;/div&gt;&lt;br /&gt;&lt;script src="http://gist.github.com/193608.js"&gt;&lt;/script&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;div&gt;Now instead of target='_blank' you can just use class='target-blank', if the browser does not support javascript it will not open in a new window but the link will still work - and we have our valid xhtml.&lt;/div&gt;&lt;br /&gt;Resources&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://www.cre8asiteforums.com/forums/index.php?showtopic=58559"&gt;cre8asiteforums&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://validator.w3.org/#validate_by_input+with_options"&gt;W3C Markup Validation Service&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://jquery.com/"&gt;JQuery&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/14193236281833595-820072932624060179?l=house9-code-samples.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://house9-code-samples.blogspot.com/feeds/820072932624060179/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=14193236281833595&amp;postID=820072932624060179' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/14193236281833595/posts/default/820072932624060179'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/14193236281833595/posts/default/820072932624060179'/><link rel='alternate' type='text/html' href='http://house9-code-samples.blogspot.com/2009/09/attribute-target-exists-but-can-not-be.html' title='Attribute &quot;target&quot; exists, but can not be used for this element.'/><author><name>House 9</name><uri>http://www.blogger.com/profile/08045832658861127427</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-14193236281833595.post-9082252536594241735</id><published>2009-08-21T13:09:00.000-07:00</published><updated>2009-08-21T14:06:22.504-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='rails'/><category scheme='http://www.blogger.com/atom/ns#' term='jquery'/><title type='text'>Ajax error handling with ruby on rails and jquery</title><content type='html'>&lt;p&gt;This sample is just a slight modification of this post '&lt;a href="http://www.railsfire.com/article/handling-ajax-errors-and-displaying-friendly-error-messages-users"&gt;Handling AJAX errors and displaying friendly error messages to users&lt;/a&gt;'. Basically I wanted to maintain the existing rails error handling for non-ajax pages and then have good handling for errors in both development and production mode; i.e. get errors in the browser when in development mode and show a nice message when in production mode.&lt;/p&gt;&lt;p&gt;Modify /app/controllers/application.rb; add the rescue_from macro and the handler_exception method&lt;/p&gt;&lt;br /&gt;&lt;script src="http://gist.github.com/172342.js"&gt;&lt;/script&gt;&lt;p&gt;Then add a global javascript method for presenting the errors; most likely in application.js&lt;/p&gt;&lt;script src="http://gist.github.com/172345.js"&gt;&lt;/script&gt;&lt;p&gt;Then a sample usage, jquery making an ajax post to a rails controller action&lt;/p&gt;&lt;script src="http://gist.github.com/172347.js"&gt;&lt;/script&gt;&lt;p&gt;in development mode the error message is returned in an easier to read view in the firebug console and an alert message is presented that has a truncated version of the error&lt;/p&gt;&lt;div&gt;&lt;img src="http://lh4.ggpht.com/_vmq8pP42BnQ/So8KnG3kC8I/AAAAAAAACpY/MfilcJSygvQ/s800/ajax_error_development.png" alt="dev mode" /&gt;&lt;/div&gt;&lt;p&gt;in production mode just a friendly error message.&lt;/p&gt;&lt;div&gt;&lt;img src="http://lh4.ggpht.com/_vmq8pP42BnQ/So8JB8thiUI/AAAAAAAACpQ/g-OZI0E94Qk/s800/screen-shot-002.png" alt="production mode" /&gt;&lt;/div&gt;&lt;p&gt;Resources&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://www.railsfire.com/article/handling-ajax-errors-and-displaying-friendly-error-messages-users"&gt;Handling AJAX errors and displaying friendly error messages to users&lt;/a&gt;&lt;/li&gt;&lt;li&gt;Rails source code &lt;a href="http://api.rubyonrails.org/classes/ActionController/Rescue.html"&gt;rescue.rb&lt;/a&gt;&lt;/li&gt;&lt;li&gt;Rails views source on your install lib/action_controller/templates/rescues&lt;/li&gt;&lt;li&gt;&lt;a href="http://docs.jquery.com/Ajax/jQuery.ajax"&gt;jquery ajax&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/14193236281833595-9082252536594241735?l=house9-code-samples.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://house9-code-samples.blogspot.com/feeds/9082252536594241735/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=14193236281833595&amp;postID=9082252536594241735' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/14193236281833595/posts/default/9082252536594241735'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/14193236281833595/posts/default/9082252536594241735'/><link rel='alternate' type='text/html' href='http://house9-code-samples.blogspot.com/2009/08/ajax-error-handling-with-ruby-on-rails.html' title='Ajax error handling with ruby on rails and jquery'/><author><name>House 9</name><uri>http://www.blogger.com/profile/08045832658861127427</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh4.ggpht.com/_vmq8pP42BnQ/So8KnG3kC8I/AAAAAAAACpY/MfilcJSygvQ/s72-c/ajax_error_development.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-14193236281833595.post-8581082806605433433</id><published>2009-08-04T13:54:00.000-07:00</published><updated>2009-08-04T14:00:30.373-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='sql'/><title type='text'>Get list of MSSQL jobs that are currently running</title><content type='html'>The following sql statement will return information about the currently executing MSSQL jobs.&lt;div&gt;Run it against the msdb database&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt; &lt;div&gt;&lt;span class="Apple-style-span"   style="font-family:Arial;font-size:100%;"&gt;&lt;span class="Apple-style-span"  style=" white-space: pre;font-size:13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;script src="http://gist.github.com/161536.js"&gt;&lt;/script&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;Resources&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ms186722.aspx"&gt;MSDN: sp_help_job&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.sqlteam.com/article/controlling-jobs-in-transact-sql"&gt;Controlling Jobs in Transact-SQL&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/14193236281833595-8581082806605433433?l=house9-code-samples.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://house9-code-samples.blogspot.com/feeds/8581082806605433433/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=14193236281833595&amp;postID=8581082806605433433' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/14193236281833595/posts/default/8581082806605433433'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/14193236281833595/posts/default/8581082806605433433'/><link rel='alternate' type='text/html' href='http://house9-code-samples.blogspot.com/2009/08/get-list-of-mssql-jobs-that-are.html' title='Get list of MSSQL jobs that are currently running'/><author><name>House 9</name><uri>http://www.blogger.com/profile/08045832658861127427</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-14193236281833595.post-1809440887057519647</id><published>2009-04-23T21:31:00.000-07:00</published><updated>2009-04-23T22:05:33.171-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='rails'/><category scheme='http://www.blogger.com/atom/ns#' term='postgresql'/><title type='text'>PGError: ERROR:  invalid byte sequence for encoding "UTF8": 0xa7 (ActiveRecord::StatementInvalid)</title><content type='html'>Working on a rails application and have decided to make the switch from MySql to &lt;a href="http://www.postgresql.org/"&gt;Postgresql&lt;/a&gt;; ran into a few minor issues along the way and one really annoying and unexpected issue&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;span style="font-style:italic; background-color:yellow;"&gt;PGError: ERROR:  invalid byte sequence for encoding "UTF8": 0xa7 (ActiveRecord::StatementInvalid)&lt;br /&gt;HINT:  This error can also happen if the byte sequence does not match the encoding expected by the server, which is controlled by "client_encoding".&lt;/span&gt;&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;The above error was being generated when I was trying to save model objects that had their string and text attributes assigned from data that had been scrapped using http with &lt;a href="http://scrubyt.org/"&gt;scRUBYt&lt;/a&gt;. After searching on Google the only 'work-around' I found was to use base64 encode and decode when reading and writing to these model attributes / database columns&lt;br /&gt;&lt;br /&gt;Given the following migration&lt;br /&gt;&lt;script src="http://gist.github.com/100947.js"&gt;&lt;/script&gt;&lt;br /&gt;Our model before and then after applying the work-around&lt;br /&gt;&lt;script src="http://gist.github.com/100943.js"&gt;&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;Resources&lt;div&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/aa02ee4750670d06/f2d5c89dafae30a1?lnk=gst&amp;amp;q=postgresql+base64"&gt;String encoding / Importing Feeds&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.ruby-forum.com/topic/146059"&gt;override AR default attribute accessors&lt;/a&gt;&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/14193236281833595-1809440887057519647?l=house9-code-samples.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://house9-code-samples.blogspot.com/feeds/1809440887057519647/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=14193236281833595&amp;postID=1809440887057519647' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/14193236281833595/posts/default/1809440887057519647'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/14193236281833595/posts/default/1809440887057519647'/><link rel='alternate' type='text/html' href='http://house9-code-samples.blogspot.com/2009/04/pgerror-error-invalid-byte-sequence-for.html' title='PGError: ERROR:  invalid byte sequence for encoding &quot;UTF8&quot;: 0xa7 (ActiveRecord::StatementInvalid)'/><author><name>House 9</name><uri>http://www.blogger.com/profile/08045832658861127427</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-14193236281833595.post-4620160985437746322</id><published>2009-04-09T11:51:00.000-07:00</published><updated>2009-04-09T12:46:46.057-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='tfs'/><category scheme='http://www.blogger.com/atom/ns#' term='nant'/><title type='text'>UPDATE: NAnt build with TFS changeset as revision number</title><content type='html'>this is a small revision to a previous post &lt;a href="http://house9-code-samples.blogspot.com/2008/04/nant-build-with-tfs-changeset-as.html"&gt;NAnt build with TFS changeset as revision number&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;apparently there is a limitation on the size of the number used in each segment of a .net assembly version so this is a slight update to the c# code that gets the latest changeset from TFS - changes start at "if(latestChangsetId &gt; 65534)"&lt;br /&gt;&lt;br /&gt;&lt;textarea class="csharp" name="code" rows="10" cols="80"&gt;&lt;br /&gt;public static void ScriptMain(Project project) &lt;br /&gt;{&lt;br /&gt; project.Log(Level.Info, "Connect to " + project.Properties["tfs.server"]);&lt;br /&gt; TeamFoundationServer tfs = new TeamFoundationServer(project.Properties["tfs.server"]);&lt;br /&gt;&lt;br /&gt; // Get a reference to Version Control.                     &lt;br /&gt; Type type = typeof(VersionControlServer);&lt;br /&gt; VersionControlServer versionControl = (VersionControlServer)tfs.GetService(type);&lt;br /&gt;&lt;br /&gt; project.Log(Level.Info, "get changesetId for " + project.Properties["tfs.fullpath"]);&lt;br /&gt; IEnumerable changeSets = versionControl.QueryHistory(project.Properties["tfs.fullpath"], VersionSpec.Latest, 0, RecursionType.Full, null, null, null, 1, true, false);&lt;br /&gt; int latestChangesetId = 0;&lt;br /&gt;&lt;br /&gt; // there is only one&lt;br /&gt; foreach(Changeset c in changeSets)&lt;br /&gt; {&lt;br /&gt;  latestChangesetId = c.ChangesetId;&lt;br /&gt; }   &lt;br /&gt; &lt;br /&gt; string revision = String.Empty;&lt;br /&gt; if(latestChangsetId &gt; 65534)&lt;br /&gt; {&lt;br /&gt;   // use the last 4 numbers only&lt;br /&gt;   revision = latestChangesetId.ToString().Substring(latestChangesetId.ToString().Length - 4, 4);&lt;br /&gt; }&lt;br /&gt; else&lt;br /&gt; {&lt;br /&gt;   revision = latestChangesetId.ToString();&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; project.Log(Level.Info, "ChangesetId is " + latestChangesetId.ToString());&lt;br /&gt; project.Log(Level.Info, "Revision will be  " + revision);&lt;br /&gt; &lt;br /&gt; project.Properties["project.version.revision"] = revision;&lt;br /&gt;}&lt;br /&gt;&lt;/textarea&gt;&lt;br /&gt;&lt;br /&gt;see also &lt;a href="http://michaelsync.net/2007/01/12/assemblyversion-buildno-limitation"&gt;AssemblyVersion - BuildNo Limitation &lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/14193236281833595-4620160985437746322?l=house9-code-samples.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://house9-code-samples.blogspot.com/feeds/4620160985437746322/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=14193236281833595&amp;postID=4620160985437746322' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/14193236281833595/posts/default/4620160985437746322'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/14193236281833595/posts/default/4620160985437746322'/><link rel='alternate' type='text/html' href='http://house9-code-samples.blogspot.com/2009/04/update-nant-build-with-tfs-changeset-as.html' title='UPDATE: NAnt build with TFS changeset as revision number'/><author><name>House 9</name><uri>http://www.blogger.com/profile/08045832658861127427</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-14193236281833595.post-3064536910374403047</id><published>2009-03-26T09:15:00.001-07:00</published><updated>2009-03-26T09:24:44.837-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='sql'/><category scheme='http://www.blogger.com/atom/ns#' term='mssql'/><title type='text'>Get Filenames and Database names from MSSQL</title><content type='html'>I was doing some clean up on one of our database servers; we have many databases created with backup/restore for testing purposes I was checking for the largest ldf files and making sure those databases were in simple mode and then shirking the data files, there were a few files I could not match to the databases because the mdf and ldf file names were different from the actual database file name - found the following queries using a few google searches&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;script src="http://gist.github.com/86181.js"&gt;&lt;/script&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;script src="http://gist.github.com/86182.js"&gt;&lt;/script&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/14193236281833595-3064536910374403047?l=house9-code-samples.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://house9-code-samples.blogspot.com/feeds/3064536910374403047/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=14193236281833595&amp;postID=3064536910374403047' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/14193236281833595/posts/default/3064536910374403047'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/14193236281833595/posts/default/3064536910374403047'/><link rel='alternate' type='text/html' href='http://house9-code-samples.blogspot.com/2009/03/get-filenames-and-database-names-from.html' title='Get Filenames and Database names from MSSQL'/><author><name>House 9</name><uri>http://www.blogger.com/profile/08045832658861127427</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-14193236281833595.post-5107591891161512461</id><published>2009-02-16T14:57:00.000-08:00</published><updated>2009-02-16T15:06:58.415-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='javascript'/><category scheme='http://www.blogger.com/atom/ns#' term='jquery'/><title type='text'>use jquery to disable a button when clicked</title><content type='html'>&lt;a href="http://jquery.com/"&gt;jquery&lt;/a&gt; is such a great javascript library, the more I use it the more I like it&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;script src="http://gist.github.com/65438.js"&gt;&lt;/script&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;NOTE: the above code snippets are untested - cut, pasted and modified from real code that was tested (and worked!)&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/14193236281833595-5107591891161512461?l=house9-code-samples.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://house9-code-samples.blogspot.com/feeds/5107591891161512461/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=14193236281833595&amp;postID=5107591891161512461' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/14193236281833595/posts/default/5107591891161512461'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/14193236281833595/posts/default/5107591891161512461'/><link rel='alternate' type='text/html' href='http://house9-code-samples.blogspot.com/2009/02/use-jquery-to-disable-button-when.html' title='use jquery to disable a button when clicked'/><author><name>House 9</name><uri>http://www.blogger.com/profile/08045832658861127427</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-14193236281833595.post-7766044818318595654</id><published>2008-11-01T08:33:00.000-07:00</published><updated>2008-11-01T08:52:27.697-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='rails'/><category scheme='http://www.blogger.com/atom/ns#' term='rake'/><title type='text'>Calling rake tasks from another rake task</title><content type='html'>This turns out to be pretty straight forward, but was not obvious&lt;br /&gt;&lt;br /&gt;&lt;textarea class="ruby" name="code" rows="10" cols="60"&gt;&lt;br /&gt;  Rake::Task['task_name'].execute&lt;br /&gt;&lt;/textarea&gt;&lt;br /&gt;&lt;br /&gt;A rake task to rebuild the development database&lt;br /&gt;&lt;textarea class="ruby" name="code" rows="10" cols="60"&gt;&lt;br /&gt;desc 'drop, create and rebuild development db'&lt;br /&gt;task(:rebuild_development_db) do&lt;br /&gt;  puts "drop the db"&lt;br /&gt;  Rake::Task['db:drop'].execute &lt;br /&gt;  puts "create the db"&lt;br /&gt;  Rake::Task['db:create'].execute&lt;br /&gt;  puts "run the migrations"&lt;br /&gt;  Rake::Task['db:migrate'].execute&lt;br /&gt;  # do other stuff...&lt;br /&gt;end&lt;br /&gt;&lt;/textarea&gt;&lt;br /&gt;&lt;br /&gt;Resources&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://www.railsenvy.com/2007/6/11/ruby-on-rails-rake-tutorial"&gt;http://www.railsenvy.com/2007/6/11/ruby-on-rails-rake-tutorial&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://pastie.org/153991"&gt;Pastie code sample Rake calling Rake&lt;/a&gt;&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/14193236281833595-7766044818318595654?l=house9-code-samples.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://house9-code-samples.blogspot.com/feeds/7766044818318595654/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=14193236281833595&amp;postID=7766044818318595654' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/14193236281833595/posts/default/7766044818318595654'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/14193236281833595/posts/default/7766044818318595654'/><link rel='alternate' type='text/html' href='http://house9-code-samples.blogspot.com/2008/11/calling-rake-tasks-from-another-rake.html' title='Calling rake tasks from another rake task'/><author><name>House 9</name><uri>http://www.blogger.com/profile/08045832658861127427</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-14193236281833595.post-3008401956456441050</id><published>2008-05-18T07:54:00.001-07:00</published><updated>2008-05-18T08:02:30.372-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='sql'/><category scheme='http://www.blogger.com/atom/ns#' term='mssql'/><title type='text'>MSSQL drop and re-add constraints</title><content type='html'>One of the guys at work hooked me up with this code - quite useful if you want to do a bunch of data inserts but don't want to worry about the order you apply the inserts because of foreign key constraints&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Before performing data actions:&lt;/span&gt;&lt;br /&gt;&lt;textarea class="sql" name="code" rows="10" cols="60"&gt;&lt;br /&gt;-- generate these and run&lt;br /&gt;SELECT&lt;br /&gt;'ALTER TABLE ' + so.NAME + ' NOCHECK CONSTRAINT ALL'&lt;br /&gt;FROM sysobjects so&lt;br /&gt;WHERE xtype = 'u'&lt;br /&gt;&lt;/textarea&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;After performing data actions:&lt;/span&gt;&lt;br /&gt;&lt;textarea class="sql" name="code" rows="10" cols="60"&gt;&lt;br /&gt;-- generate these and run&lt;br /&gt;SELECT&lt;br /&gt;'ALTER TABLE ' + so.NAME + ' CHECK CONSTRAINT ALL'&lt;br /&gt;FROM sysobjects so&lt;br /&gt;WHERE xtype = 'u'&lt;br /&gt;&lt;/textarea&gt;&lt;br /&gt;&lt;br /&gt;Thanks to ET for this code bit!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/14193236281833595-3008401956456441050?l=house9-code-samples.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://house9-code-samples.blogspot.com/feeds/3008401956456441050/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=14193236281833595&amp;postID=3008401956456441050' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/14193236281833595/posts/default/3008401956456441050'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/14193236281833595/posts/default/3008401956456441050'/><link rel='alternate' type='text/html' href='http://house9-code-samples.blogspot.com/2008/05/mssql-drop-and-re-add-constraints.html' title='MSSQL drop and re-add constraints'/><author><name>House 9</name><uri>http://www.blogger.com/profile/08045832658861127427</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-14193236281833595.post-2854849542978407339</id><published>2008-05-10T13:25:00.000-07:00</published><updated>2008-05-10T13:29:38.977-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='rails'/><title type='text'>Rolling Over Rails production.log file</title><content type='html'>Just came across this on a rails forum (post by Freezzo), rails production.log files can grow very large - but no chron job required - this is very handy.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;textarea class="ruby" name="code" rows="10" cols="60"&gt;&lt;br /&gt;config.logger = Logger.new("#{RAILS_ROOT}/log/#{ENV['RAILS_ENV']}.log", 'daily')&lt;br /&gt;&lt;/textarea&gt;&lt;br /&gt;&lt;br /&gt;where 'daily' can be 'daily' to 'weekly', 'monthly', '5mb', etc...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/14193236281833595-2854849542978407339?l=house9-code-samples.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://house9-code-samples.blogspot.com/feeds/2854849542978407339/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=14193236281833595&amp;postID=2854849542978407339' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/14193236281833595/posts/default/2854849542978407339'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/14193236281833595/posts/default/2854849542978407339'/><link rel='alternate' type='text/html' href='http://house9-code-samples.blogspot.com/2008/05/rolling-over-rails-productionlog-file.html' title='Rolling Over Rails production.log file'/><author><name>House 9</name><uri>http://www.blogger.com/profile/08045832658861127427</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-14193236281833595.post-2815808217419473178</id><published>2008-04-20T15:08:00.001-07:00</published><updated>2008-04-20T16:03:18.917-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='tfs'/><category scheme='http://www.blogger.com/atom/ns#' term='nant'/><title type='text'>NAnt build with TFS changeset as revision number</title><content type='html'>This code sample is a &lt;a href="http://nant.sourceforge.net/"&gt;nant&lt;/a&gt; script that &lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;deletes the CommonAssembly.cs file (linked to all projects)&lt;/li&gt;&lt;br /&gt;&lt;li&gt;uses the nant &lt;a href="http://nant.sourceforge.net/release/latest/help/tasks/asminfo.html"&gt;asminfo&lt;/a&gt; task to recreate the CommonAssembly.cs file, but after we query TFS for the changeset (revision) number which is used in the version number&lt;/li&gt;&lt;br /&gt;&lt;li&gt;build the solution in release mode using the ide.exe (there are other - better ways, but this one works)&lt;/li&gt;&lt;br /&gt;&lt;li&gt;xcopy files to C:\temp\{app} and clean up all the source files&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;basically I just put together a few bits that I found on other blogs (should have saved the urls - doh!), most were related to using svn for source control and then I added in the code block for the c# stuff to query TFS.&lt;br /&gt;&lt;br /&gt;A quick note about the linked CommonAssembly.cs file, visual studio has an option when you are adding an existing file to a project to select 'linked', click the arrow on the 'Add' button when you select your existing file&lt;br /&gt;&lt;br /&gt;what this script does not do - get latest from TFS, I usually do that part manually or from ccnet&lt;br /&gt;&lt;textarea class="xml" name="code" rows="10" cols="80"&gt;&lt;br /&gt;&lt;project name="YourApp" default="do-build" xmlns="http://nant.sf.net/release/0.85-rc4/nant.xsd"&gt;&lt;br /&gt; &lt;!-- Version settings --&gt;&lt;br /&gt; &lt;property name="project.config" value="release" /&gt;&lt;br /&gt; &lt;property name="project.version.major" value="1" /&gt;&lt;br /&gt; &lt;property name="project.version.minor" value="0" /&gt;&lt;br /&gt; &lt;property name="project.version.build" value="0" /&gt;&lt;br /&gt; &lt;property name="tfs.server" value="http://yourTFSserver:8080/" /&gt;&lt;br /&gt; &lt;property name="tfs.fullpath" value="$/yourTeamProject/someDirectory/andSoOn/" /&gt;&lt;br /&gt; &lt;property name="company" value="${project::get-name()}"/&gt;&lt;br /&gt; &lt;property name="project" value="${project::get-name()}"/&gt;&lt;br /&gt; &lt;property name="copyright" value="${company}, ${datetime::get-year(datetime::now())}"/&gt;&lt;br /&gt; &lt;property name="temp-target-dir" value="C:\temp\yourApplication"/&gt;&lt;br /&gt;&lt;br /&gt; &lt;!-- the public target --&gt;&lt;br /&gt; &lt;target name="do-build" depends="version, compile-release, copy-to-temp-dir"/&gt;&lt;br /&gt;&lt;br /&gt; &lt;target name="compile-release"&gt;&lt;br /&gt;  &lt;!-- delete the previous log files --&gt;&lt;br /&gt;  &lt;delete file="clean_log.txt" failonerror="false"&gt;&lt;/delete&gt;&lt;br /&gt;  &lt;delete file="compile_log.txt" failonerror="false"&gt;&lt;/delete&gt;&lt;br /&gt;  &lt;!-- clean --&gt;&lt;br /&gt;  &lt;echo message="Clean bins" /&gt;&lt;br /&gt;  &lt;exec program="c:\program files\microsoft visual studio 9.0\common7\ide\devenv.exe" workingdir="."&gt;&lt;br /&gt;   &lt;arg file="YourSolutionFileNameHere.sln" /&gt;&lt;br /&gt;   &lt;arg value="/out" /&gt;&lt;br /&gt;   &lt;arg value="clean_log.txt" /&gt;&lt;br /&gt;   &lt;arg value="/clean" /&gt;&lt;br /&gt;   &lt;arg value="${project.config}" /&gt;&lt;br /&gt;  &lt;/exec&gt;&lt;br /&gt;  &lt;!-- build --&gt;&lt;br /&gt;  &lt;echo message="Build for ${project.config}" /&gt;&lt;br /&gt;  &lt;exec program="c:\program files\microsoft visual studio 9.0\common7\ide\devenv.exe" workingdir="."&gt;&lt;br /&gt;   &lt;arg file="YourSolutionFileNameHere.sln" /&gt;&lt;br /&gt;   &lt;arg value="/out" /&gt;&lt;br /&gt;   &lt;arg value="compile_log.txt" /&gt;&lt;br /&gt;   &lt;arg value="/rebuild" /&gt;&lt;br /&gt;   &lt;arg value="${project.config}" /&gt;&lt;br /&gt;  &lt;/exec&gt;&lt;br /&gt; &lt;/target&gt;&lt;br /&gt; &lt;br /&gt; &lt;target name="version"&gt;&lt;br /&gt;  &lt;property name="project.version.revision" value="0"/&gt;&lt;br /&gt;  &lt;!-- this block get the changesetid for this 'solution' and sets project.version.revision --&gt;&lt;br /&gt;  &lt;script language="C#"&gt;&lt;br /&gt;   &lt;references&gt;&lt;br /&gt;    &lt;include name="C:\someDirectoryWhereYouHaveThisDll\Microsoft.TeamFoundation.Client.dll" /&gt;&lt;br /&gt;    &lt;include name="C:\someDirectoryWhereYouHaveThisDll\TeamFoundation\Microsoft.TeamFoundation.VersionControl.Client.dll" /&gt;&lt;br /&gt;   &lt;/references&gt;&lt;br /&gt;   &lt;imports&gt;&lt;br /&gt;    &lt;import namespace="Microsoft.TeamFoundation.Client" /&gt;&lt;br /&gt;    &lt;import namespace="Microsoft.TeamFoundation.VersionControl.Client" /&gt;&lt;br /&gt;   &lt;/imports&gt;&lt;br /&gt;   &lt;code&gt;&lt;br /&gt;    &lt;![CDATA[&lt;br /&gt;     public static void ScriptMain(Project project) &lt;br /&gt;     {&lt;br /&gt;        // see c# code sample in next section...&lt;br /&gt;     }&lt;br /&gt;    ]]&gt;&lt;br /&gt;   &lt;/code&gt;&lt;br /&gt;  &lt;/script&gt;&lt;br /&gt;  &lt;br /&gt;  &lt;property name="project.version.full" value="${project.version.major}.${project.version.minor}.${project.version.build}.${project.version.revision}"/&gt;&lt;br /&gt;&lt;br /&gt;  &lt;echo message="MARKING THIS BUILD AS VERSION ${project.version.full}" /&gt;&lt;br /&gt;  &lt;delete file="CommonAssemblyInfo.cs" failonerror="false"/&gt;&lt;br /&gt;  &lt;asminfo output="CommonAssemblyInfo.cs" language="CSharp"&gt;&lt;br /&gt;   &lt;imports&gt;&lt;br /&gt;    &lt;import namespace="System" /&gt;&lt;br /&gt;    &lt;import namespace="System.Reflection" /&gt;&lt;br /&gt;    &lt;import namespace="System.Runtime.InteropServices" /&gt;&lt;br /&gt;   &lt;/imports&gt;&lt;br /&gt;   &lt;attributes&gt;&lt;br /&gt;    &lt;attribute type="ComVisibleAttribute" value="false" /&gt;&lt;br /&gt;    &lt;attribute type="AssemblyVersionAttribute" value="${project.version.full}" /&gt;&lt;br /&gt;    &lt;attribute type="AssemblyFileVersionAttribute" value="${project.version.full}" /&gt;&lt;br /&gt;    &lt;attribute type="AssemblyCopyrightAttribute" value="${copyright}" /&gt;&lt;br /&gt;    &lt;attribute type="AssemblyProductAttribute" value="${project}" /&gt;&lt;br /&gt;    &lt;attribute type="AssemblyCompanyAttribute" value="${company}" /&gt;&lt;br /&gt;    &lt;attribute type="AssemblyConfigurationAttribute" value="${project.config}" /&gt;&lt;br /&gt;    &lt;attribute type="AssemblyInformationalVersionAttribute" value="${project.version.full}" /&gt;&lt;br /&gt;   &lt;/attributes&gt;&lt;br /&gt;   &lt;references&gt;&lt;br /&gt;    &lt;include name="System.dll" /&gt;&lt;br /&gt;   &lt;/references&gt;&lt;br /&gt;  &lt;/asminfo&gt;&lt;br /&gt; &lt;/target&gt;&lt;br /&gt;&lt;br /&gt; &lt;target name="copy-to-temp-dir"&gt;&lt;br /&gt;  &lt;mkdir dir="${temp-target-dir}" /&gt;&lt;br /&gt;  &lt;exec program="xcopy" verbose="true"&gt;&lt;br /&gt;   &lt;arg value=".\YourWebProjectDirectory" /&gt;&lt;br /&gt;   &lt;arg value="${temp-target-dir}" /&gt;&lt;br /&gt;   &lt;arg line="/e /r /y /q" /&gt;&lt;br /&gt;  &lt;/exec&gt;&lt;br /&gt;&lt;br /&gt;  &lt;delete&gt;&lt;br /&gt;   &lt;!-- probably a better way to do this? --&gt;&lt;br /&gt;   &lt;fileset basedir="${temp-target-dir}"&gt;&lt;br /&gt;    &lt;include name="*.cs" /&gt;&lt;br /&gt;    &lt;include name="*/*.cs" /&gt;&lt;br /&gt;    &lt;include name="*.csproj*" /&gt;&lt;br /&gt;    &lt;include name="*/*.otherfiletypes" /&gt;&lt;br /&gt;   &lt;/fileset&gt;&lt;br /&gt;  &lt;/delete&gt;&lt;br /&gt;  &lt;br /&gt;  &lt;!-- fix up the web.config --&gt;&lt;br /&gt;  &lt;echo message="update the configuration ${temp-target-dir}\web.config" /&gt;&lt;br /&gt;  &lt;xmlpoke &lt;br /&gt;   file="${temp-target-dir}\web.config"&lt;br /&gt;   xpath="/ns:configuration/ns:system.web/ns:customErrors/@mode"&lt;br /&gt;   value="On"&lt;br /&gt;  &gt;&lt;br /&gt;   &lt;namespaces&gt;&lt;br /&gt;    &lt;namespace prefix="ns" uri="http://schemas.microsoft.com/.NetConfiguration/v2.0" /&gt;&lt;br /&gt;   &lt;/namespaces&gt;&lt;br /&gt;  &lt;/xmlpoke&gt;    &lt;br /&gt; &lt;/target&gt; &lt;br /&gt;&lt;br /&gt;&lt;/project&gt;&lt;br /&gt;&lt;/textarea&gt;&lt;br /&gt;&lt;br /&gt;the c# bit that goes in the nant script block above&lt;br /&gt;&lt;textarea class="csharp" name="code" rows="10" cols="80"&gt;&lt;br /&gt;public static void ScriptMain(Project project) &lt;br /&gt;{&lt;br /&gt; project.Log(Level.Info, "Connect to " + project.Properties["tfs.server"]);&lt;br /&gt; TeamFoundationServer tfs = new TeamFoundationServer(project.Properties["tfs.server"]);&lt;br /&gt;&lt;br /&gt; // Get a reference to Version Control.                     &lt;br /&gt; Type type = typeof(VersionControlServer);&lt;br /&gt; VersionControlServer versionControl = (VersionControlServer)tfs.GetService(type);&lt;br /&gt;&lt;br /&gt; project.Log(Level.Info, "get changesetId for " + project.Properties["tfs.fullpath"]);&lt;br /&gt; IEnumerable changeSets = versionControl.QueryHistory(project.Properties["tfs.fullpath"], VersionSpec.Latest, 0, RecursionType.Full, null, null, null, 1, true, false);&lt;br /&gt; int latestChangesetId = 0;&lt;br /&gt;&lt;br /&gt; // there is only one&lt;br /&gt; foreach(Changeset c in changeSets)&lt;br /&gt; {&lt;br /&gt;  latestChangesetId = c.ChangesetId;&lt;br /&gt; }   &lt;br /&gt;&lt;br /&gt; project.Log(Level.Info, "ChangesetId is " + latestChangesetId.ToString());&lt;br /&gt; project.Properties["project.version.revision"] = latestChangesetId.ToString();&lt;br /&gt;}&lt;br /&gt;&lt;/textarea&gt;&lt;br /&gt;&lt;br /&gt;nant is awesome!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/14193236281833595-2815808217419473178?l=house9-code-samples.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://house9-code-samples.blogspot.com/feeds/2815808217419473178/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=14193236281833595&amp;postID=2815808217419473178' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/14193236281833595/posts/default/2815808217419473178'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/14193236281833595/posts/default/2815808217419473178'/><link rel='alternate' type='text/html' href='http://house9-code-samples.blogspot.com/2008/04/nant-build-with-tfs-changeset-as.html' title='NAnt build with TFS changeset as revision number'/><author><name>House 9</name><uri>http://www.blogger.com/profile/08045832658861127427</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-14193236281833595.post-3721545324179255787</id><published>2008-02-16T09:05:00.000-08:00</published><updated>2008-02-16T10:35:50.530-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='rhino.mocks'/><category scheme='http://www.blogger.com/atom/ns#' term='code'/><category scheme='http://www.blogger.com/atom/ns#' term='unit test'/><category scheme='http://www.blogger.com/atom/ns#' term='csharp'/><title type='text'>Rhino.Mocks - the basics</title><content type='html'>Started using Rhino.Mocks recently (Awesome!!!) - just wanted to list a few of the basics; the official Rhino Mocks Documentation is very good and available &lt;a href="http://www.ayende.com/Wiki/(S(0asrslmlg1jh5355jtljowre))/Rhino+Mocks+Documentation.ashx"&gt;here&lt;/a&gt;. These examples are a bit rough, they have not been compiled; there may be typos.&lt;br /&gt;&lt;br /&gt;using&lt;pre class="c-sharp" name="code"&gt;using Rhino.Mocks;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The mock repository&lt;br /&gt;&lt;textarea class="c-sharp" name="code" rows="10" cols="60"&gt;&lt;br /&gt;// use the mock repository to create the mocked objects&lt;br /&gt;MockRepository mocks = new Rhino.Mocks.MockRepository();&lt;br /&gt;// example&lt;br /&gt;System.Object someObject = mocks.CreateMock&lt;System.Object&gt;();&lt;br /&gt;// set up the behaviour you want from calls to your mocked object &lt;br /&gt;Rhino.Mocks.Expect.Call(someObject.Equals(someParameter)).Return(false);&lt;br /&gt;// then don't forget&lt;br /&gt;mocks.ReplayAll();&lt;br /&gt;// now do stuff that calls your mocked object Equals method&lt;br /&gt;...&lt;br /&gt;&lt;/textarea&gt;&lt;br /&gt;&lt;br /&gt;Mock a call to the db&lt;br /&gt;&lt;textarea class="c-sharp" name="code" rows="10" cols="60"&gt;&lt;br /&gt;// create our mocked repository object - IProductRepository, the real one calls the db&lt;br /&gt;IProductRepository repository = mocks.CreateMock&lt;IProductRepository&gt;();&lt;br /&gt;// tell rhino.mocks when we call the method GetProduct with the argument 33 to return null&lt;br /&gt;Rhino.Mocks.Expect.Call(repository.GetProduct(33)).Return(null);&lt;br /&gt;// get the mocking ready&lt;br /&gt;mocks.ReplayAll();&lt;br /&gt;// pass our mock to our product service layer&lt;br /&gt;ProductService service = new ProductService(repository);&lt;br /&gt;// service.GetProduct makes a call to the mocked repository.GetProduct which will return null&lt;br /&gt;IProduct product = service.GetProduct(33);&lt;br /&gt;// should be null&lt;br /&gt;Assert.IsNull(product);&lt;br /&gt;&lt;/textarea&gt;&lt;br /&gt;&lt;br /&gt;Ignore any arguments&lt;br /&gt;&lt;textarea class="c-sharp" name="code" rows="10" cols="60"&gt;&lt;br /&gt;// any call to GetProduct will return null no matter the value of the arg&lt;br /&gt;Rhino.Mocks.Expect.Call(repository.GetProduct(null)).Return(null).IgnoreArguments();&lt;br /&gt;&lt;/textarea&gt;&lt;br /&gt;&lt;br /&gt;mock a method that returns void&lt;br /&gt;&lt;textarea class="c-sharp" name="code" rows="10" cols="60"&gt;&lt;br /&gt;IProduct product = new Product("003092", "Sierra Nevada", 6.49);&lt;br /&gt;// this void call will handle our product 003092&lt;br /&gt;Rhino.Mocks.Expect.Call(delegate { repository.Save(product); });&lt;br /&gt;// this void call will handle any argument&lt;br /&gt;Rhino.Mocks.Expect.Call(delegate { repository.Save(null); }).IgnoreArguments();&lt;br /&gt;&lt;/textarea&gt;&lt;br /&gt;&lt;br /&gt;Handle multiple calls to the same method&lt;br /&gt;&lt;textarea class="c-sharp" name="code" rows="10" cols="60"&gt;&lt;br /&gt;IProduct product = new Product("003092", "Sierra Nevada", 6.49);&lt;br /&gt;// note the .Repeat.Any()&lt;br /&gt;Rhino.Mocks.Expect.Call(repository.GetProduct("003092")).Return(product).Repeat.Any();&lt;br /&gt;// send the mock to our product service object&lt;br /&gt;ProductService service = new ProductService(repository);&lt;br /&gt;// find by sku calls GetProduct on the mocked Product repository&lt;br /&gt;IProduct beer = service.FindBySku("003092");&lt;br /&gt;// find decent beer calls GetProduct on the mocked Product repository also&lt;br /&gt;IProduct decentBeer = service.FindDecentBeer();&lt;br /&gt;&lt;/textarea&gt;&lt;br /&gt;&lt;br /&gt;Partial Mock&lt;br /&gt;&lt;textarea class="c-sharp" name="code" rows="10" cols="60"&gt;&lt;br /&gt;// create a partial mock with constructor args (our product repository again)&lt;br /&gt;IProductService service = mocks.PartialMock&lt;IProductService&gt;(repository);&lt;br /&gt;// our test case data&lt;br /&gt;IUser loggedOnUser = new User("John", "Doe", CustomerType.Gold);&lt;br /&gt;// mock product service calls to GetLoggedOnUser&lt;br /&gt;Rhino.Mocks.Expect.Call(service.GetLoggedOnUser()).Return(loggedOnUser);&lt;br /&gt;// get the mocking ready&lt;br /&gt;mocks.ReplayAll();&lt;br /&gt;// now GetDiscount is not a mocked method but it does call the mocked GetLoggedOnUser method&lt;br /&gt;decimal discount = service.GetDiscount();&lt;br /&gt;// assert the result&lt;br /&gt;Assert.AreSame(44.4M, discount, "Gold customer discount not correct?");&lt;br /&gt;// NOTE: this will not work (compile) unless the mocked method GetLoggedOnUser is public&lt;br /&gt;&lt;/textarea&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/14193236281833595-3721545324179255787?l=house9-code-samples.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://house9-code-samples.blogspot.com/feeds/3721545324179255787/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=14193236281833595&amp;postID=3721545324179255787' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/14193236281833595/posts/default/3721545324179255787'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/14193236281833595/posts/default/3721545324179255787'/><link rel='alternate' type='text/html' href='http://house9-code-samples.blogspot.com/2008/02/rhinomocks-basics.html' title='Rhino.Mocks - the basics'/><author><name>House 9</name><uri>http://www.blogger.com/profile/08045832658861127427</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-14193236281833595.post-3254076477142630494</id><published>2007-10-18T19:17:00.000-07:00</published><updated>2007-10-18T19:43:16.698-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ruby'/><category scheme='http://www.blogger.com/atom/ns#' term='javascript'/><category scheme='http://www.blogger.com/atom/ns#' term='rjs'/><category scheme='http://www.blogger.com/atom/ns#' term='rails'/><title type='text'>Rails RJS and newline characters</title><content type='html'>ok this one really got me, I was generating a javascript alert from the server via an rjs file, i.e.&lt;br /&gt;&lt;br /&gt;&lt;blockquote style="BORDER-RIGHT: 1px dashed; PADDING-RIGHT: 5px; BORDER-TOP: 1px dashed; PADDING-LEFT: 5px; BACKGROUND: #ffffff; LEFT: 65px; PADDING-BOTTOM: 5px; BORDER-LEFT: 1px dashed; WIDTH: 360px; PADDING-TOP: 5px; BORDER-BOTTOM: 1px dashed; POSITION: relative"&gt;&lt;p style="BACKGROUND: #ffffff; WIDTH: 100%"&gt;&lt;em&gt;&lt;span style="color:#009900;"&gt;# rjs render a javascript alert on the client&lt;/span&gt;&lt;/em&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;page&lt;span style="color:#000000;"&gt;.alert&lt;/span&gt; '&lt;span style="color:#990000;"&gt;Errors\nError 1\nError 2&lt;/span&gt;'&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt;and it kept on printing my error message as Errors&lt;span style="color:#ff0000;"&gt;\n&lt;/span&gt;Error message 1&lt;span style="color:#ff0000;"&gt;\n&lt;/span&gt;Error message2 - note that the newline characters were being escaped and rendered literally&lt;br /&gt;&lt;br /&gt;I found this &lt;a href="http://www.agmweb.ca/blog/andy/1937/"&gt;informative post&lt;/a&gt; which lead me to change my code from using single quotes to using double quotes - nasty.&lt;br /&gt;&lt;br /&gt;&lt;blockquote style="BORDER-RIGHT: 1px dashed; PADDING-RIGHT: 5px; BORDER-TOP: 1px dashed; PADDING-LEFT: 5px; BACKGROUND: #ffffff; LEFT: 65px; PADDING-BOTTOM: 5px; BORDER-LEFT: 1px dashed; WIDTH: 460px; PADDING-TOP: 5px; BORDER-BOTTOM: 1px dashed; POSITION: relative"&gt;&lt;p style="BACKGROUND: #ffffff; WIDTH: 100%; HEIGHT: 54px"&gt;&lt;em&gt;&lt;span style="color:#009900;"&gt;# this one will output the newlines in the javascript alert message&lt;/span&gt;&lt;/em&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;page&lt;span style="color:#000000;"&gt;.alert&lt;/span&gt; "&lt;span style="color:#990000;"&gt;Errors\nError 1\nError 2"&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;here is the final code, looping through each error on the model object (product in this case) and outputing a newline on the javascript alert for each error&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;blockquote style="BORDER-RIGHT: 1px dashed; PADDING-RIGHT: 5px; BORDER-TOP: 1px dashed; PADDING-LEFT: 5px; BACKGROUND: #ffffff; LEFT: 65px; PADDING-BOTTOM: 5px; BORDER-LEFT: 1px dashed; WIDTH: 481px; PADDING-TOP: 5px; BORDER-BOTTOM: 1px dashed; POSITION: relative; HEIGHT: 301px"&gt;&lt;p&gt;&lt;em&gt;&lt;span style="color:#009900;"&gt;# rjs file&lt;/span&gt;&lt;/em&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;page&lt;/span&gt;.alert &lt;span style="color:#3333ff;"&gt;"&lt;/span&gt;&lt;span style="color:#cc0000;"&gt;#{get_message_for_show_server_error}&lt;/span&gt;&lt;span style="color:#3333ff;"&gt;"&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;em&gt;&lt;span style="color:#009900;"&gt;# helper file&lt;br /&gt;&lt;/span&gt;&lt;/em&gt;&lt;span style="color:#993399;"&gt;def&lt;/span&gt; get_message_for_show_server_error&lt;br /&gt;&lt;span style="color:#ffffff;"&gt;__&lt;/span&gt;s = "&lt;span style="color:#cc0000;"&gt;Errors &lt;/span&gt;"&lt;br /&gt;&lt;span style="color:#ffffff;"&gt;__&lt;/span&gt;&lt;span style="color:#3333ff;"&gt;@product&lt;/span&gt;.errors.full_messages.each &lt;span style="color:#993399;"&gt;do&lt;/span&gt; error&lt;br /&gt;&lt;span style="color:#ffffff;"&gt;____&lt;/span&gt;s = s + "&lt;span style="color:#cc0000;"&gt;\n&lt;/span&gt;" + error.to_s&lt;br /&gt;&lt;span style="color:#993399;"&gt;&lt;span style="color:#ffffff;"&gt;__&lt;/span&gt;end&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#3333ff;"&gt;&lt;span style="color:#ffffff;"&gt;__&lt;/span&gt;return&lt;/span&gt; s&lt;br /&gt;&lt;span style="color:#993399;"&gt;end&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="BACKGROUND: #ffffff; WIDTH: 100%"&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/14193236281833595-3254076477142630494?l=house9-code-samples.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://house9-code-samples.blogspot.com/feeds/3254076477142630494/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=14193236281833595&amp;postID=3254076477142630494' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/14193236281833595/posts/default/3254076477142630494'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/14193236281833595/posts/default/3254076477142630494'/><link rel='alternate' type='text/html' href='http://house9-code-samples.blogspot.com/2007/10/rails-rjs-and-newline-characters.html' title='Rails RJS and newline characters'/><author><name>House 9</name><uri>http://www.blogger.com/profile/08045832658861127427</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-14193236281833595.post-8159705293247259563</id><published>2007-09-01T10:37:00.000-07:00</published><updated>2007-09-01T11:15:30.411-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ruby'/><category scheme='http://www.blogger.com/atom/ns#' term='code'/><title type='text'>Ruby Notes - part 1 - dynamic object creation</title><content type='html'>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 &lt;a href="http://www.ruby-forum.com/topic/96222"&gt;http://www.ruby-forum.com/topic/96222&lt;/a&gt;;&lt;br /&gt;&lt;br /&gt;in theses 2 examples - given an ActiveRecord object 'Project' and a database table named 'projects', invoke the Project and execute some methods on it&lt;br /&gt;&lt;blockquote style="BORDER-RIGHT: 1px dashed; PADDING-RIGHT: 5px; BORDER-TOP: 1px dashed; PADDING-LEFT: 5px; BACKGROUND: #ffffff; LEFT: 65px; PADDING-BOTTOM: 5px; BORDER-LEFT: 1px dashed; WIDTH: 360px; PADDING-TOP: 5px; BORDER-BOTTOM: 1px dashed; POSITION: relative"&gt;&lt;p style="BACKGROUND: #ffffff; WIDTH: 100%"&gt;&lt;em&gt;&lt;span style="color:#009900;"&gt;# using eval&lt;/span&gt;&lt;/em&gt;&lt;br /&gt;&lt;span style="color:#993399;"&gt;def&lt;/span&gt; test_dynamic_invoke_with_eval&lt;br /&gt;&lt;span style="color:#ffffff;"&gt;__&lt;/span&gt;object_name = &lt;span style="color:#3333ff;"&gt;"Project"&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#ffffff;"&gt;__&lt;/span&gt;o = eval(object_name)&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#ffffff;"&gt;__&lt;/span&gt;p &lt;span style="color:#3333ff;"&gt;"object name is '"&lt;/span&gt; + o.to_s + &lt;span style="color:#3333ff;"&gt;"'"&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#ffffff;"&gt;__&lt;/span&gt;p &lt;span style="color:#3333ff;"&gt;"object table name is '"&lt;/span&gt; + o.table_name + &lt;span style="color:#3333ff;"&gt;"'"&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#993399;"&gt;end&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;&lt;blockquote style="BORDER-RIGHT: 1px dashed; PADDING-RIGHT: 5px; BORDER-TOP: 1px dashed; PADDING-LEFT: 5px; BACKGROUND: #ffffff; LEFT: 65px; PADDING-BOTTOM: 5px; BORDER-LEFT: 1px dashed; WIDTH: 360px; PADDING-TOP: 5px; BORDER-BOTTOM: 1px dashed; POSITION: relative"&gt;&lt;p style="BACKGROUND: #ffffff; WIDTH: 100%"&gt;&lt;em&gt;&lt;span style="color:#009900;"&gt;# using Object.const_get&lt;/span&gt;&lt;/em&gt;&lt;br /&gt;&lt;span style="color:#993399;"&gt;def&lt;/span&gt; test_dynamic_invoke_with_object_const_get&lt;br /&gt;&lt;span style="color:#ffffff;"&gt;__&lt;/span&gt;object_name = &lt;span style="color:#3333ff;"&gt;"Project"&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#ffffff;"&gt;__&lt;/span&gt;o = Object.const_get(object_name)&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#ffffff;"&gt;__&lt;/span&gt;p &lt;span style="color:#3333ff;"&gt;"object name is '"&lt;/span&gt; + o.to_s + &lt;span style="color:#3333ff;"&gt;"'"&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#ffffff;"&gt;__&lt;/span&gt;p &lt;span style="color:#3333ff;"&gt;"object table name is '"&lt;/span&gt; + o.table_name + &lt;span style="color:#3333ff;"&gt;"'"&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#993399;"&gt;end&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;Check the ruby forum link above as well - the last entry posted by &lt;em&gt;'unknown (Guest)'&lt;/em&gt;; 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&lt;br /&gt;&lt;blockquote style="BORDER-RIGHT: 1px dashed; PADDING-RIGHT: 5px; BORDER-TOP: 1px dashed; PADDING-LEFT: 5px; BACKGROUND: #ffffff; LEFT: 65px; PADDING-BOTTOM: 5px; BORDER-LEFT: 1px dashed; WIDTH: 360px; PADDING-TOP: 5px; BORDER-BOTTOM: 1px dashed; POSITION: relative"&gt;&lt;p style="BACKGROUND: #ffffff; WIDTH: 100%"&gt;&lt;em&gt;&lt;span style="color:#009900;"&gt;# extend String&lt;/span&gt;&lt;/em&gt;&lt;br /&gt;&lt;span style="color:#993399;"&gt;class&lt;/span&gt; String&lt;br /&gt;&lt;span style="color:#993399;"&gt;&lt;span style="color:#ffffff;"&gt;__&lt;/span&gt;def &lt;/span&gt;to_class&lt;br /&gt;&lt;span style="color:#ffffff;"&gt;_&lt;/span&gt;&lt;span style="color:#ffffff;"&gt;__&lt;/span&gt;Object.const_get(&lt;span style="color:#3333ff;"&gt;self&lt;/span&gt;)&lt;br /&gt;&lt;span style="color:#ffffff;"&gt;__&lt;/span&gt;&lt;span style="color:#993399;"&gt;end&lt;/span&gt;&lt;span style="color:#ffffff;"&gt;__&lt;/span&gt;&lt;span style="color:#3333ff;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#993399;"&gt;end&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/14193236281833595-8159705293247259563?l=house9-code-samples.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://house9-code-samples.blogspot.com/feeds/8159705293247259563/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=14193236281833595&amp;postID=8159705293247259563' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/14193236281833595/posts/default/8159705293247259563'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/14193236281833595/posts/default/8159705293247259563'/><link rel='alternate' type='text/html' href='http://house9-code-samples.blogspot.com/2007/09/ruby-notes-part-1-dynamic-object.html' title='Ruby Notes - part 1 - dynamic object creation'/><author><name>House 9</name><uri>http://www.blogger.com/profile/08045832658861127427</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-14193236281833595.post-7199561344002204075</id><published>2007-02-11T12:09:00.000-08:00</published><updated>2008-02-16T09:24:15.877-08:00</updated><title type='text'>A client side (javascript) confirm box with ASP.NET</title><content type='html'>The following code sample illustrates a client side (javascript) confirm box in use with an aspx button, this presents the end user with a dialog box asking ''are you sure you want to submit this form?', it gives the user two options 'Ok' and 'Cancel', clicking ok will submit the form, clicking cancel will not&lt;br /&gt;&lt;br /&gt;This sample code uses 4 variations;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt;&lt;strong&gt;TestButton1&lt;/strong&gt; - a standard html input type 'button', which submits the page using hand coded js&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt;&lt;strong&gt;TestButton2&lt;/strong&gt; - a standard html input type 'submit', it has the default behaviour of submitting the form&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt;&lt;strong&gt;TestButton3&lt;/strong&gt; - an asp:button with the OnClientClick (rendered as onclick) declared in the mark up&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt;&lt;strong&gt;TestButton4&lt;/strong&gt; - an asp:button with the onclick defined in the code behind or c#&lt;/span&gt;&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;div&gt;The aspx page markup - JavaScriptConfirm.aspx&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="xml" name="code"&gt;&lt;br /&gt;&amp;lt;%@ Page &lt;br /&gt;  Language="C#" &lt;br /&gt;  AutoEventWireup="true" &lt;br /&gt;  CodeBehind="JavaScriptConfirm.aspx.cs" &lt;br /&gt;  Inherits="SandboxOne.JavaScriptConfirm" &lt;br /&gt;%&amp;gt;&lt;br /&gt;&amp;lt;!DOCTYPE...&amp;gt;&lt;br /&gt;&amp;lt;html&amp;gt;&lt;br /&gt;&amp;lt;head runat="server"&amp;gt;&lt;br /&gt;    &amp;lt;title&amp;gt;Javascript Confirm&amp;lt;/title&amp;gt;&lt;br /&gt;    &amp;lt;script language="javascript" type="text/javascript"&amp;gt;&lt;br /&gt;    function AreYouSure()&lt;br /&gt;    {&lt;br /&gt;        return confirm('are you sure you want to submit this form?');&lt;br /&gt;    }&lt;br /&gt;    &amp;lt;/script&amp;gt;&lt;br /&gt;&amp;lt;/head&amp;gt;&lt;br /&gt;&amp;lt;body&amp;gt;&lt;br /&gt;&amp;lt;form id="form1" runat="server"&amp;gt;&lt;br /&gt;    &amp;lt;input id="TestButton1"&lt;br /&gt;            type="button"&lt;br /&gt;            onclick="if(AreYouSure()) { document.forms[0].submit(); }"&lt;br /&gt;            value="A regular html 'button' button"&lt;br /&gt;    /&amp;gt;&lt;br /&gt;    &amp;lt;input id="TestButton2"&lt;br /&gt;            type="submit"&lt;br /&gt;            onclick="return AreYouSure();"&lt;br /&gt;            value="A regular html 'submit' button"&lt;br /&gt;    /&amp;gt;&lt;br /&gt;    &amp;lt;asp:Button ID="TestButton3"&lt;br /&gt;                OnClientClick="return AreYouSure();"&lt;br /&gt;                OnClick="InvokeServerSideMethod"&lt;br /&gt;                Text="A asp button"&lt;br /&gt;                runat="server"&lt;br /&gt;    /&amp;gt;&lt;br /&gt;    &amp;lt;asp:Button ID="TestButton4"&lt;br /&gt;                OnClick="InvokeServerSideMethod"&lt;br /&gt;                Text="A asp button c# wired OnClientClick"&lt;br /&gt;                runat="server"&lt;br /&gt;    /&amp;gt;&lt;br /&gt;&amp;lt;/form&amp;gt;&lt;br /&gt;&amp;lt;/body&amp;gt;&lt;br /&gt;&amp;lt;/html&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;The c# 'code-behind'&lt;br /&gt;&lt;pre name="code" class="c-sharp"&gt;&lt;br /&gt;public partial class JavaScriptConfirm : System.Web.UI.Page&lt;br /&gt;{&lt;br /&gt;    protected void Page_Load(object sender, EventArgs e)&lt;br /&gt;    {&lt;br /&gt;        // wire the client side onclick to TestButton4&lt;br /&gt;        this.TestButton4.Attributes.Add("onclick", "return AreYouSure();");&lt;br /&gt;&lt;br /&gt;        if(Page.IsPostBack)&lt;br /&gt;        {&lt;br /&gt;            Response.Write&lt;br /&gt;            (&lt;br /&gt;                String.Format("Page_Load, IsPostBack: {0}&lt;hr /&gt;", DateTime.Now.ToLongTimeString())&lt;br /&gt;            );&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    // the server side 'event' kicked off when asp:button is clicked&lt;br /&gt;    protected void InvokeServerSideMethod(object sender, EventArgs e)&lt;br /&gt;    {&lt;br /&gt;        Response.Write&lt;br /&gt;        (&lt;br /&gt;            String.Format("InvokeServerSideMethod, E: {0}&lt;hr /&gt;", DateTime.Now.ToLongTimeString())&lt;br /&gt;        );&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;div style="MARGIN: 0px 0px 15px"&gt;&lt;br /&gt;The 'key' here is the return in the onclick method; the javascript confirm will return true if 'Ok' is clicked and false if 'Cancel' is clicked, we must return this value from our buttons onclick event so that the form will not generate an HTTP POST (or PostBack if you like)&lt;br /&gt;&lt;br /&gt;if you do not include the return statement in the onclick the form will post back regardless of which button is clicked 'Ok' or 'Cancel'; for instance you do NOT want to do this &lt;pre name="code" class="html"&gt; onclick="AreYouSure();" &lt;/pre&gt;but instead do this &lt;pre name="code" class="html"&gt; onclick="return AreYouSure();" &lt;/pre&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/14193236281833595-7199561344002204075?l=house9-code-samples.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://house9-code-samples.blogspot.com/feeds/7199561344002204075/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=14193236281833595&amp;postID=7199561344002204075' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/14193236281833595/posts/default/7199561344002204075'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/14193236281833595/posts/default/7199561344002204075'/><link rel='alternate' type='text/html' href='http://house9-code-samples.blogspot.com/2007/02/client-side-javascript-confirm-box-with.html' title='A client side (javascript) confirm box with ASP.NET'/><author><name>House 9</name><uri>http://www.blogger.com/profile/08045832658861127427</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-14193236281833595.post-9120424885028599534</id><published>2007-02-11T09:05:00.000-08:00</published><updated>2008-02-16T08:11:28.451-08:00</updated><title type='text'>Generate a Guid from MSSQL</title><content type='html'>Really simple...&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;pre name="code" class="sql"&gt;SELECT NEWID()&lt;/pre&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;This returns a MSSQL datatype of uniqueidentifier&lt;br /&gt;read more here - &lt;a href="http://msdn2.microsoft.com/en-us/library/aa276822(SQL.80).aspx"&gt;http://msdn2.microsoft.com/en-us/library/aa276822(SQL.80).aspx&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/14193236281833595-9120424885028599534?l=house9-code-samples.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://house9-code-samples.blogspot.com/feeds/9120424885028599534/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=14193236281833595&amp;postID=9120424885028599534' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/14193236281833595/posts/default/9120424885028599534'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/14193236281833595/posts/default/9120424885028599534'/><link rel='alternate' type='text/html' href='http://house9-code-samples.blogspot.com/2007/02/generate-guid-from-mssql.html' title='Generate a Guid from MSSQL'/><author><name>House 9</name><uri>http://www.blogger.com/profile/08045832658861127427</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-14193236281833595.post-8931127431064025136</id><published>2007-02-11T08:54:00.000-08:00</published><updated>2007-02-11T08:54:01.954-08:00</updated><title type='text'>This blog is just for the code samples</title><content type='html'>my real blog is at &lt;a href="http://house9.blogspot.com/"&gt;http://house9.blogspot.com/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;there really is not anything that interesting there either...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/14193236281833595-8931127431064025136?l=house9-code-samples.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://house9-code-samples.blogspot.com/feeds/8931127431064025136/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=14193236281833595&amp;postID=8931127431064025136' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/14193236281833595/posts/default/8931127431064025136'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/14193236281833595/posts/default/8931127431064025136'/><link rel='alternate' type='text/html' href='http://house9-code-samples.blogspot.com/2007/02/this-blog-is-just-for-code-samples.html' title='This blog is just for the code samples'/><author><name>House 9</name><uri>http://www.blogger.com/profile/08045832658861127427</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
