This blog, along with all of its contents, will be moving to http://www.parallelcoding.com. Come read and enjoy!
Archive for the Uncategorized Category
SEO 301 Redirects for ASP .NET 1.1
Posted in Uncategorized on February 26, 2008 by relic411I recently worked on a project where any URL following the form of http://www.mydomain.com/subDomain/Default.aspx needed to 301 redirect to http://www.mydomain.com/subDomain/. Basically this calls for stripping the ‘Default.aspx’ off of any request that has it. The project was to be completed using Visual Basic .NET 1.1.
The solution is is to add a few lines of code in the Global.asax.vb file inside of the Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs) function. The final product looks like this:
Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs)
Dim oPath As String = Request.CurrentExecutionFilePath.ToLower
If Not oPath.EndsWith(“default.aspx”) Then Return
Response.Status = “301 Moved Permanently”
Response.AddHeader(“Location”, “http://www.myDomain.com” + oPath.Substring(0, oPath.IndexOf(“default.aspx”)))
End Sub
Debugging .NET 1.1 With Visual Studio 2003 on Windows XP x64
Posted in Uncategorized on January 24, 2008 by relic411In order to debug .NET 1.1 properly, it is necessary to uninstall the .NET 2.0 framework when you want to debug. The command to uninstall is:
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -u
The command to reinstall when your are done is:
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -i
Selecting a specific number of rows in TSQL
Posted in Uncategorized on December 25, 2007 by relic411The other day I had the need to select an exact number of rows in a TSQL stored procedure. The circumstances constrained me in multiple ways and I just so happened to come across this little gem of a trick for selecting a set number of rows without using TOP.
All one must do is use the following assigment:
SET @@ROWCOUNT = # of Rows To Select
Then perform the select statement and your in business!
Import CSV Using Rails Migration
Posted in Ruby, RubyGems, Uncategorized on October 10, 2007 by relic411Reposted from Rails Weenie:
Install FasterCSV (‘gem install fasterCSV’)
The code to use inside the migration is similar to:
FasterCSV.foreach(“#{RAILS_ROOT}/lib/symbols_database/security_list.csv“, :row_sep => “\r”) do |row|
field1,field2,field3 = row
Foo.create(:field1 => field1, :field2 => field2, :field3 => field3)
end