February 20th, 2008 Luke
Have you ever been working on a project and needed a relative path for something?
Under C# itself you could use something like ~/path/to/foo, but that won’t work on a website - the tilde doesn’t always get expanded.
However, there is a nicer way. If you use Page.ResolveClientUrl(), you can easily resolve files from their ASP.net path of ~/path/to/foo to a relative path like folder/path/to/foo, or even path/to/foo, depending on where the page that is making the call to Page.ResolveClientUrl() is located. Here’s an example of how to use the code:
string myPath = Page.ResolveClientUrl("~/admin/pages.aspx");
If that code had been called from the file located at ~/admin/page2.aspx, myPath would be “pages.aspx”. If it had been called from ~/foo/main/default.aspx, myPath would be “../../admin/pages.aspx”.
Posted in csharp, snippet | No Comments »
February 12th, 2008 Luke
I’ve been reading a lot about version control lately, and thinking that I should set up some sort of version control for myself.
At the suggestion of a friend from work, I set up Git on my home Linux server. It’s been a week or so now, and I like it.
The problem is, Git doesn’t have my personal killer feature of source control: FTP exports.
One of my main goals in using source control was being able to keep my projects under source control, and easily export different revisions to my production environment - this would happen over FTP, of course.
Upon further examination, it looked like Git couldn’t do this out of the box - it’s ‘export’ functions were limited to just pushing to other Git repositories.
But then a thought struck me: I know Perl. Why didn’t I just build my own tool?
And so I did. You can check out git-export at the git-export Google Code page.
At the moment, all it can do is export the current HEAD revision of the repository you are in, and then transfer it to a folder that you specify - but I’m planning on adding the ability to pass in the name of a specific commit(maybe even tag, later) so that you can export different revisions if need be.
Initially, it doesn’t work over FTP. But if you use curlftpfs to mount an FTP folder as if it were a normal folder and then use git-export, you’ll be able to transfer the files over FTP. I’ll write a tutorial on how exactly to do it soon.
Posted in git, perl, scm, utility | No Comments »
February 7th, 2008 Luke
I’ve spent the last week and a half or so working on setting up a Linux server to have around the house - I think that it will help for me to be able to do my developing on an internal box, and then just deploy it out to the world when the project is ready(I will have more ready soon, I hope - my portfolio is looking a little bit bare).
At any rate, I managed to get a server up and running, under Ubuntu 7 Server - and decided to embark down the muddled path that is source control.
A friend recommended Git, and so that is what I’ve installed(and am therefore using). But when you’re running on a Mac, OS X creates files called .DS_Store inside every directory - which are not what I want to have under version control. I only want the files I create to be under version control.
To that end, Git allows you to setup a list of patterns that it will use to ignore files with. That list is inside myrepo/.git/info/exclude. Here’s what mine looks like:
.DS_Store
And with that simple change, the .DS_Store file is automatically excluded(although I could still force it to be added using git add -f).
Posted in git, linux, scm | 3 Comments »