July 17th, 2008 Luke
Someone I take very seriously does a lot of Ruby on Rails work - and as a result of that, I figured that I should at least take a look at the framework.
Over the weekend, I whipped up a quick little app, without using source control - it’s a quick project, and I’m not really concerned if it suddenly vanishes into the ether.
However, when it finally came time to deploy it, there was a bit of a hiccup: Capistrano’s deployment process usually involves some sort of source control - whether that’s Subversion, CVS, Darcs, or something different entirely(like Git).
Luckily however, getting Capistrano to deploy your app when it’s not under source control is a matter of only 3 lines of code, inside deploy.rb:
set :repository, "."
set :scm, :none
set :deploy_via, :copy
Once you’ve made those changes, all you need to do is run your deployment commands from within your project’s directory - and Capistrano will copy all the files over for you, without requiring you to have them under source control.
Posted in capistrano, deploy, ruby | No Comments »
July 15th, 2008 Luke
If you’ve worked much with DotNetNuke, you may have noticed a bit of an odd bug: if you use IE7 and click on the printer icon next to a module for a printer-friendly page, the CSS on the page you clicked the icon on…breaks.
This is because the way that DotNetNuke’s module actions work is to inject Javascript into the page, using Response.Write() - having a <script> tag at the start of the HTML document makes IE7 throw up.
The fix is actually very simple(for a developer), however - you need to download the DotNetNuke source, and change line 159 of Library\Components\Skins\ActionBase.vb to this:
159
| Page.ClientScript.RegisterStartupScript(Me.GetType(), "DotNetNuke.NewWindow", String.Format("<script>window.open('{0}','_blank')</script>", Command.Url)) |
Once that’s finished, build your DotNetNuke library - and copy the resulting DotNetNuke.dll into the bin directory of any website that you want to add the fix to. If you’re feeling really lazy, you can download my copy of the dll(built for version 4.8.4) below:
DotNetNuke IE7 print bugfix DLL
Posted in bug, dotnetnuke | No Comments »
June 25th, 2008 Luke
For a recent project, I had to deal with a fair number of controls on a page that all needed to be disabled at once. This is the function that I wrote to do so:
void DisableControls(List types, ControlCollection controls) {
foreach(Control control in controls) {
if(types.Contains(control.GetType())) {
((WebControl)control).Enabled = false;
}
}
}
Posted in ASP.Net, Code, csharp, snippet | No Comments »
June 10th, 2008 Luke
For a recent project, we needed to store as many possible values into 3 characters as we could, based on a numeric ID. So, we created a function that would convert that ID to base 62, which we could then use to increase the number of available combinations that we could store. Here’s the function:
public const string base62digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
public string ToBase62(int input)
{
int modulo;
string sTemp = "";
do
{
modulo = input % 62;
sTemp = base62digits.Substring(modulo + 1, 1) + sTemp;
input = input / 62;
} while (input != 0);
return sTemp;
}
It’s been modified from the VB code to do the same thing, which you can find here.
Posted in Code, conversions, csharp | No Comments »
May 28th, 2008 Luke
I recently encountered a situation where I needed to left-pad a string to a certain number of characters with 0’s. This is the SQL to do it:
RIGHT('000' + rtrim(column_name),3)
The ‘000′ is your padding characters, column_name is what you’re padding, and the 3 is how many characters you want back.
Posted in MSSQL | No Comments »