Archive for the ‘Uncategorized’ Category

Developing for Open Source Languages on Windows the Better Way

July 8th, 2010

When working with php, rails, python, etc, windows is sufficient, but definitely leaves something to be desired. The ports of these languages are definitely second class. With Microsoft’s backing php support with IIS is improving, but it’s not the same. And usually you are going to deploy those apps on a linux/bsd web server, so it’s nice to know if there are any nuances. A lot of developers opt for a mac if they are developing in these types of languages. But macs can be pricey, and buying a new machine to work on other platforms seems overkill.

Now I do have a mac, but have a windows 7 laptop at work, and sometimes I do work in ruby on various projects. So I have worked out a way that I think is worth sharing. At it’s core, the idea is to use a vm, but there are some other tweaks that make this method even better.

Install VirtualBox. It’s from Sun Oracle and it’s freely available.

Create a virtual machine with Ubuntu. Or your favorite flavor of linux or bsd. I used the server version of ubuntu.

Setup Networking (Optional). You can use bridge mode, but for added security I used NAT for the adapter on the virtual machine. To then access the machine locally, forward your local ssh port to the virtual machine using the following instructions.

Install Putty with Tools and XMing in Windows. Available here and here, these tools will let you do ssh with X forwarding in windows.

Setup a Connection in Putty.
connection info

Enable X-Forwaring in Connection.
X-Forwarding

Setup SSH Tunnels.
ssh tunnel

Setup a Proxy connection in Firefox
proxy

Create your user and install your language platforms in the virtual machine. For example in ubuntu, you’re looking for “sudo apt-get install ruby-1.8″.

Install your preferred editor in the virtual machineEmacs, Vim, Eclipse, Netbeans, etc.

Your environment is now setup. I’ll give an example with ruby:

  • Start the virtual machine
  • Start XMing
  • Connect with Putty
  • Start your editor (for example “emacs &”)
  • Open Firefox
  • Start your app (for example “ruby script/server”)
  • Go to http://localhost:3000 in Firefox

This virtual machine does not require a lot of software installed, and a small amount of ram (like 128mb) should be sufficient. And by backing up your virtual machine (which should be pretty small), you have backed up your entire development environment without getting the documents, media, etc that you have on the windows side.

Hopefully you find this helpful if you want to develop in environments that lend themselves to this environment.

Function Name Instead of Lambda in Linq Functions

February 8th, 2010

I did not realize that functions can fill in for predicates directly without lambda notation. To illustrate, consider the following:

void Main()
{
	var words = new List<string>()
	{
		"therapists",
		"s words",
		"slang",
		"mustache",
		"sean connery"
	};

	var s_words = words.Where(w => w.StartsWith("s" ,StringComparison.CurrentCultureIgnoreCase));

	foreach(var word in s_words)
	{
		Console.WriteLine(word);
	}
}

It works, but it’s a rather long lambda, which is why I broke it out of the for loop. Let’s put that logic into a function, getting this:

void Main()
{
	var words = new List<string>()
	{
		"therapists",
		"s words",
		"slang",
		"mustache",
		"sean connery"
	};

	foreach(var word in words.Where(w => SWords(w)))
	{
		Console.WriteLine(word);
	}
}

public bool SWords(string word)
{
	return word.StartsWith("s" ,StringComparison.CurrentCultureIgnoreCase);
}

That’s better. And you might find yourself using your test in other places in the code, so it’s useful to have the function. What I found out recently, is that you can go one step further:

void Main()
{
	var words = new List<string>()
	{
		"therapists",
		"s words",
		"slang",
		"mustache",
		"sean connery"
	};

	foreach(var word in words.Where(SWords))
	{
		Console.WriteLine(word);
	}
}

public bool SWords(string word)
{
	return word.StartsWith("s" ,StringComparison.CurrentCultureIgnoreCase);
}

In this example, the savings may not look drastic. But for several chained methods you can gain a lot of brevity and clarity.

Mary Kate watches me work

November 25th, 2009


Mary Kate watches me work, originally uploaded by thoolihan.

Emacs on Windows Over SSH with Putty Tools

November 12th, 2009

With a little help from StackOverflow, I got emacs over ssh working on windows. This is trivial on mac/linux, but can be a challenge on windows. dired mode works too!

To summarize:
1. Download putty installer with all the tools.
2. Put putty install in the path
3. Generate a key with PuttyGen
4. Copy public key to your server
5. Append public key to your .ssh/authorized_keys file (be sure to remove extraneous puttygen text, just get the key)
6. Load up pageant and add your private key (this can be automated on windows boot)
7. Add the following to your .emacs config
(require ‘tramp)
(setq default-tramp-method “plink”)

As long as pageant is running with your key, you can edit your remote files using the format ssh://user@server:path/to/file

ASP.Net Comments

July 7th, 2009

Here’s a strange one I’ve never run into. I was recently helping a developer figure out why some controls were not binding and showing on the page.

I noticed they were using html style comments in their page around some controls instead of .net style comments. This was the problem. Server side code still runs, and controls still render inside of html comments. No harm in that, right? The controls can’t do anything because they are in comments.

Wrong. These were validation controls. They added javascript events to the page. Those javascript events expected dom elements that didn’t exist.

You can argue that this shouldn’t have come up in the first place, as I think most ASP.Net developers know to use server side comments, however, I thought the result was interesting.

Also, it was interesting to note that if you had some boiler plate comment you wanted in your source, you could use asp to deliver the content…

    <!--
      #both of these are valid
      #response.write version
    <%=Resources.Resource1.Copyright%>

     #or server control
     <asp:Literal Id="ltlCopyright" Text='<$Resource: Resources1, Copyright >'
                                      Runat="server" />
    -->

SilverLight and Z-Index

July 7th, 2009

When implementing a new SilverLight custom control, it was blocking menu popups (html / javascript) on the page. I set the z-index of the div and object tags that contained SilverLight to no avail. After a lot of googling, I found the following solution.

Set the Windowless property to true. In the case of manually adding SilverLight to the page, that results in the following child tag of the object tag…

<param name="Windowless" value="true" />

Fun With the GAC

June 26th, 2009

The .Net GAC (Global Assembly Cache). It’s where all shared .Net components can live. However, if you have to step through the code of one of these assemblies things can get exciting…

Let’s say that I have a Business Object dll named business.dll and I have it in my GAC. And a project in which I’m referencing that dll is having problems, inside that component. I go to source control and check out the source. Add that project into my solution in Visual Studio. Unreference the GAC version, and reference the local project. I should be able to step through, right?

Wrong. The CLR resolves assemblies in the GAC before anywhere else.

Go into your GAC (C:\Windows\Assembly\GAC_MSIL) and rename the dll with an extension like “.bak”. Don’t forget to rename it after your done debugging :)

tags: , , | categories: Uncategorized | one comment »

Ceteris Paribus

June 3rd, 2009

From Wikipedia.org:

W. Ross Ashby wrote in his “Introduction to Cybernetics” (1956):
“Science stands today on something of a divide. For two centuries it has been exploring systems that are either intrinsically simple or that are capable of being analysed into simple components. The fact that such a dogma as >>vary the factors one at a time<< could be accepted for a century, shows that scientists were largely concerned in investigating such systems as allowed this method; for this method is often fundamentally impossible in the complex systems. Not until Sir Ronald Fisher’s work in the 20s, with experiments conducted on agricultural soils, did it become clearly recognised that there are complex systems that just do not allow the varying of only one factor at a time — they are so dynamic and interconnected that the alteration of one factor immediately acts as cause to evoke alterations in others, perhaps in a great many others. Until recently, science tended to evade the study of such systems, focusing its attention on those that were simple and, especially, reducible.”

Legs in Pain

May 21st, 2009


Legs in Pain, originally uploaded by thoolihan.

I completed the Cleveland Marathon on May 17th in 4:33. More pictures to come…

Dinner with Family

May 21st, 2009


Dinner with Family, originally uploaded by thoolihan.

Cathing up with relatives in Florida…