Wednesday, October 10, 2012

SMB/UNC Path Translator Bookmarklet

I needed a quick way to translate a UNIX-style SMB path to a Windows-style UNC path and vice versa.

For example:
From: smb://my-server/path/to/file
To: \\my-server\path\to\file
OR
From: \\my-server\path\to\file
To: smb://my-server/path/to/file
So I created the bookmarklet below. To use it, drag the link below to your bookmark bar. Then click it, enter a path, and click OK. It will return a translated path that you can then copy and paste.

Path Translator

Thursday, September 27, 2012

Using KDiff3 on Mac with Subversion

I love TortoiseSVN. So I was quite disappointed when I moved from a PC to a Mac and was no longer able to use it. There are several alternatives for Mac, but the one function that I haven't been able to easily find is a way to do a graphical diff between my working copy and the current version of the file. So I wrote a Perl script to do it for me. To get this to work, there were a few prerequisites:

- Install KDiff3
- Save this file in a directory that is part of the PATH
- Create a temp directory in my home directory

Then I just open a Terminal window to the directory where my working copy resides and issue the command svndiff filename. I'm sure it's not perfect but it does the trick for me.

By the way, if you have questions or suggestions or just find this useful, please drop me a comment. Thanks.

#!/usr/bin/perl
###############################################################################
#     Program : svndiff
#     Written : 09/27/2012
#      Author : carmond
# Description : Opens KDiff3 to compare working copy of file with 
#               current version in Subversion (ver 1.6) repository
#      Syntax : svndiff <filename>
#    Modified :
###############################################################################

($file) = @ARGV;

if (!file) {
 print "Syntax: svndiff <filename>\n";
 edit;
}

if (!(-e $file)) {
 print "$file does not exist\n";
 exit;
}

if ($file =~ m|/|) {
 $file =~ m|(.+)/(.+)|;
 $path = $1;
 $file = $2;
}
else {
 $path = `pwd`;
 chomp $path;
}

$svn_entries = "$path/.svn/entries";
if (!(-e $svn_entries)) {
 print "Could not find $svn_entries\n";
 exit;
}

open (IN, $svn_entries);
for ($i = 1; $i <= 5; $i++) {
 $repository = <IN>;
 chomp $repository;
}
close (IN);

$temp_file = "$ENV{'HOME'}/temp/$file";
unlink $temp_file if $temp_file;

$cmd = "svn export $repository/$file $temp_file";
`$cmd`;

if (!(-e $temp_file)) {
 print "Error getting file from repository\n";
 exit;
}

$cmd = "/Applications/kdiff3.app/Contents/MacOS/kdiff3 $temp_file $path/$file";
`$cmd &`;

Monday, July 30, 2012

Exporting the Windows Task Manager Process List

I'm trying to make a case for a new computer at work. One of the things I want to show (besides the incredibly slow boot time) is that I am maxing out my RAM. To do that, I wanted to get a list of tasks running that I could import into a spreadsheet to figure out how how much memory my day-to-day applications consume (Outlook, Eclipse, SQL Developer, Firefox, etc.) versus all of those background processes that I don't even know what they do. Here's how I did it:
Start -> Run -> cmd
tasklist > tasklist.txt
Then open tasklist.txt in Excel as a fixed-width file and go to work.

Wednesday, April 25, 2012

Change Folder Name Using mod_rewrite

For anybody out there that may be needing to do a simple directory name replacement using mod_rewrite:
RewriteEngine On
RewriteRule ^(.+)\/abc\/(.+)$ $1\/xyz\/$2
So http://blah.com/abc/image.jpg becomes http://blah.com/xyz/image.jpg

Tuesday, April 10, 2012

Outlook Messages with Word Attachments

I hate getting emails at work with Word attachments. It just takes too long to open the attachment especially when the content could have been easily included in the message. Let's make a pact that any time we have a meeting agenda, job posting, etc. that has minimal formatting, we will copy and paste it into the message instead. Outlook is smart enough to know what to do with it (most of the time) and it will save everybody some time.

Friday, April 6, 2012

jQuery Newbie Mistake

I just made a jQuery newbie mistake but the worst part about it was that the code still worked in all browsers...except IE7. So I didn't even know that I had done it wrong until one of the developers discovered it.

Here is what I tried to do:

$("blah").each(function(index) {
this.id = newID;
this.name = newID;
});
Here is what I should have done:

$("blah").each(function(index) {
$(this).attr("id", newID);
$(this).attr("name", newID);
});
Once I changed my code to the latter, it starting working correctly in IE7.

Thursday, April 5, 2012

Using Color to Prevent Accidents

We are all familiar with the use of color for keeping our attention: stop lights, construction signs, warning labels, etc. To try to minimize the number of mistakes I make, I color code my terminal sessions.

On Windows I use PuTTY for creating a secure shell session into the servers that I need to access. One of the options it to set a background color for the session.


For production I set the background color to red and for development I set the background to green. The red color is a warning to myself: "You are on the production server. Don't screw things up!" Then for each server I log into, I save a session, and create a shortcut to it. In PuTTY the syntax is putty.exe -load "session_name". For example:

c:\putty.exe -load "dev"
c:\putty.exe -load "prod"

Color can't fix my stupid mistakes, but it has helped me to stay focused.

On the topic of color, I just read this article on Wired.com about how red keeps you focused and blue makes you more creative. Next step is to use Firefox Personas to color code my Firefox windows: red for coding and blue for designing.
 
Blogger Templates