Node.js and CoffeeScript on Windows, Redux

11 Comments


Remember back when we installed Node.js on a Virtual Machine just to get it working on Windows 7? Well there’s a better way.

1) Install Cygwin

Grab Cygwin from here and install that puppy. Make sure you install the following modules:

  • Devel -> gcc4-g++ [Builds v0.4.2 and earlier use gcc-g++]
  • Devel -> git
  • Devel -> make
  • Devel -> openssl-devel
  • Devel -> pkg-config
  • Devel -> zlib-devel
  • Editors -> nano
  • Libs -> openssl-devel
  • Python -> python

Ensure you allow Cygwin to install required packages as well, otherwise these things just won’t work.

2) Download and build Node.js

$ cd ~
$ git clone git://github.com/joyent/node.git
$ cd node
$ git fetch --all
# if the above fails complaining --all is not recognised, try: git fetch origin
$ git tag
$ git checkout [latest stable tag from previous command, e.g., v0.2.5]
$ ./configure
$ make
$ make install

If, during the “configure” step, you get the following error: “error: could not configure a cxx compiler!” Do the following:

  1. Close your Cygwin terminal.
  2. Start -> Run -> ash
  3. /bin/rebaseall
  4. Close ash, re-open your Cygwin shell, and try again.

3) Configure Node.js

Node.js tries to use /etc/resolv.conf for domain name resolution, all pretending like its on Linux. Simple enough to get around though, just “nano /etc/resolv.conf” to create it. Slap the following in there:

nameserver 8.8.8.8
nameserver 8.8.4.4

Hit Ctrl-O to save. Now Node.js will route DNS requests through Google’s free DNS service.

4) Install NPM

This one’s easy. Run this:

curl http://npmjs.org/install.sh | sh

5) Install CoffeeScript

This is easy because we installed npm:

npm install -g coffee-script

6) Configure your system’s PATH

Open up Control Panel and search for PATH. Click on “Edit the system environment variables”, then click the “Environment Variables” button. Scroll through the “System Variables” list until you find “Path”, then add this to the end:

c:\cygwin\usr\local\bin

If you installed Cygwin to a different spot, make that modification now.

Ta-daa!

Congratulations! Node.js and CoffeeScript are now installed in Cygwin under Windows 7. You can call node.js from a cmd.exe window now due to that PATH variable, and even calling CoffeeScript is super-easy:

node /usr/local/lib/node_modules/coffee-script/bin/coffee {arguments}

Thanks to the offical guide on how to install CoffeeScript on Windows, and to the authors and maintainers of Node.js and CoffeeScript as well.

Dear Capcom, Pull Your Head Out Of Your Ass

No Comments

It’s beginning to look like the PC version of Street Fighter IV: Arcade Edition is going to be a worse investment than setting your wallet on fire.

The original SFIV was cancelled on PC due to piracy concerns. I don’t even understand that – isn’t the draw for this game fighting other people? Developers have come up with reliable ways to prevent pirated versions of games from going multiplayer for decades now. But Capcom, determined to apply a solution in face of a problem they don’t even really have, has basically guaranteed that pirating SFIV:AE will get you a better game than buying it.

First, make the assumption that if you’re pirating SFIV, you don’t care much about getting online, this being a fairly common restriction on pirated games. So if you pirate SFIV and you have an internet problem or Capcom’s servers go down, you get the following features that paying customers don’t:

  • You can continue your game! Paying customers get kicked out without saving.
  • Your challenge mode works like always! Paying customers lose the ability to save progress in challenge mode.
  • You can change your settings! Paying customers can’t save their settings changes.
  • You can play dress-up! Paying customers lose access to cosmetic DLC while offline.
  • You can play with all 39 characters. Paying customers? Only fifteen.

That’s an impressively broken game. But here’s a good question. Why bother at all?

Recently, Lionhead has come out and said that second-hand game sales cost them more than piracy. I’ve long suspected this to be the case for a while, but it’s interesting to see a publisher come out and say it. Given this, wouldn’t it make more sense for Capcom to try to make money from second-hand sales instead of battling uphill against pirates? And come on, Street Fighter is the perfect game for this. Check it:

You buy SFIV:AE for $10. That’s right. Ten dollars. Cheap, simple, easy. (Knock on: So cheap that it may tempt some pirates to buy it.) However, this is only the single-player version of the game. Most people are buying this game for the multiplayer anyway, which you sell a key for direct from your website for $30. The benefits are enormous:

  • From customers who would have paid you anyway, you make the same $40 you would have charged at retail.
  • From pirates who only want to play single player, you make the same $0. But you can’t stop that anyway.
  • From pirates who want to play multiplayer, you make $30 instead of $0!
  • From second-hand buyers who want to play multiplayer, you make another $30 instead of $0!

You’ve now converted some pirates to paying customers, and recovered most of the money you lose on second-hand sales. What do you think Capcom?

Capcom?

Wait, what are you doing? Why are you selling the retail version for less than the digital version?

Didn’t you listen to a thing I just said?

Best Error Message Ever

No Comments

Time Vortex Malfunction.

YES.

Let’s talk about Anonymous

2 Comments

So there’s been some hullaballoo recently about how Anonymous might turn out to actually be responsible for the PSN hack, but I think that honestly goes to show how poorly understood Anonymous actually is. Let’s break it down.

History

So there’s this website, eBaum’s World, where members can – and usually do – post anonymously. When you don’t provide a handle to go with your posting over there, you show up as “Anonymous”. On any other website, when someone would provide an answer to a question you posed, you’d say something like “Thanks, JimmyJim255!”. On eBaum’s World, you’d instead say “Thanks, Anon!” And so it grew to be A Thing.

It was funny, to pretend that Anonymous wasn’t some anonymous person, but a giant Hive-Mind of people. You send a question out, and it gets Answered. You request the source for a particular image, and it is provided to you not by a single person, but by the Great Anonymous Itself. The Hive-Mind has spoken.

What Anonymous Isn’t

Anonymous isn’t a tightly-controlled net of hackers. There’s no “Boss Anon”. No “Anon Bin Laden”. There’s no single member of Anonymous that you can arrest that will cause a “crippling blow” to “the network”. Because let’s be honest here, “the network” is generally a bunch of bored dudes, killing some time by browsing eBaum’s World and taking part in whatever looks fun.

Sure, some members are incredibly more talented in the whole Black Hat stuff. Sure, some are better at persuading the herd, through use of clever rhetoric, reverse psychology, and hilarious memes. But they don’t make up the bulk of Anonymous, and if they left and never returned, it would remain the same.

What Anonymous Is

Anonymous remains the same even through the loss of its members, largely because Anonymous is ever-changing. From one moment to the next, the “member list” is different. Some bored college student in California hits up a well-crafted webpage to join in on a DDOS attack on Friday night, and leaves on Saturday morning, bored. A talented hacker joins in the fight against Scientology because she has a friend she lost to the group, but leaves when they start attacking Sony, because she’s a hyuuuuge fan. Any “leaders” are at best temporary and individually-motivated. Participants are even more amorphous and random. Pinning down “Anonymous” is pretty much impossible.

It’s made even worse by statements from “inside” the group as well. From the linked article, a “veteren member of Anonymous” says:

“If you say you are Anonymous, and do something as Anonymous, then Anonymous did it,” said Kayla. “Just because the rest of Anonymous might not agree with it, doesn’t mean Anonymous didn’t do it.”

While technically correct, going back to the old-school definition of Anonymous as the Hive-Mind, it doesn’t help clear things up to the media. This point of view correctly places Kayla as a veteran member of Anonymous, at least, given the fact that she still thinks of Anonymous as the Hive-Mind across the internet, where thanking or blaming one member thanks or blames the Hive-Mind. But as far as news organizations are concerned, it really muddies the waters.

Kayla is not confirming that there is a well-controlled and organized cyberterrorist group called Anonymous. She’s not confirming that Anonymous is behind the PSN network attacks. There’s no confusion inside the Anonymous community about this.

She’s just saying, with the same playful, let’s pretend attitude as members of Anonymous have always regarded themselves, that if you thank Anonymous for giving you sauce, then you can curse Anonymous for taking down PSN.

Welcome to the Hive-Mind.

An open letter to voters in Kingston and the Islands

No Comments

I’ve been following this election pretty closely, and honestly, it’s pretty scary. The Conservatives are within spitting distance of a majority, and with that comes massive change for Canada. Change I’m not comfortable with.

A few quick examples of things Harper’s Conservatives have done while they’ve held a minority position:

  • He created an Agency for Crime Victims that was only used to support a “tough-on-crime” position to get superprisons funded, doing nothing for victims at all. Canada’s crime rate is falling, why do we need more prisons? http://bit.ly/iqP47m
  • In 2007, Harper cut $1.2 Billion in spending for the establishment of quality national childcare. However, he never kept his promise to cut the $1.4 billion in tax breaks he gives to oil companies (the wealthiest corporations in history). http://bit.ly/mdj61J
  • At the 2010 G20 summit in Toronto – a summit to discuss what to do about the terrible economic hardships befalling the world – Harper spent $1.9 million building a fake lake and nearly $1 Billion on security for the 3 day event. 1,105 arrests were made – the largest mass arrest in Canadian history. Only 99 criminal charges were laid. http://bit.ly/mPxqBo
  • And let’s not forget the fact that he prorogued parliament early to prevent threats to his government. http://bit.ly/jZp251

With that happening while he only holds a minority government, I honestly fear what might happen if he got the majority mandate he’s seeking.

What does this have to do with you though? Well, for the first time that I can remember, a whole hell of a lot might be resting on the shoulders of Kingston and the Islands.

Peter Milliken stepped down this election, deciding not to run again after a long and successful career in Federal politics. The Liberal who replaced him is not faring as well this election. In 2008, Milliken won by 7% of the vote. In 2011, Ted Hsu is projected to be ahead by 0.1%.

0.1% is an INCREDIBLY small number. There’s only 97,000 registered electors in Kingston and the Islands, which means 0.1% is only 97 people. But it’s smaller than that. In 2008, only 58,000 electors turned out, which means 0.1% is only 58 people. But it’s smaller than that. Voter turnout has been falling year-over-year.

Which means that Kingston and the Islands hinges on maybe 50 people. Maybe less.

With Harper within spitting distance of a majority government, that could mean that the fate of Canada hinges on maybe 50 people.

Or less.

So if you haven’t voted yet, please, PLEASE get out there on May 2 and cast your vote. If you’re considering voting NDP or Green, please consider Liberal candidate Ted Hsu. If you’re considering voting Conservative, please consider anybody else.

There’s a website set up to educate people about everything the Harper government has done during its term. All the slimy, inconsiderate, nasty things done in our name. It’s called “ShitHarperDid.com“. Reading it is informative, so please go give it a look before you head out to the polls. Hopefully it will only be an historical record going forward, not a breaking news source.

If you’re still not convinced, please humour me by reading this incredibly poignant article, published in The Star in 2010: “Changing Canada, One Backward Step At A Time“. This was written back when there was no immediate election on the horizon, and nobody had an axe to grind, except to point out the terrible things being done to Canada.

Thanks for listening.

Localization Sin #1

2 Comments

Never, ever, ever assume you can pluralize something by adding an “s” to the end of it.

Not only does this not remain true in every language, but you will grow lax and start doing silly things like:

    var text = "You have " + swordQuantity + " sword" +
        (1 === swordQuantity ? "" : "s") + ".";

And when you do that once, you’re likely to do it all over the place. Then, instead of simple text replacement during localization, you have to rewrite whole swaths of code to handle how different languages pluralize.

Just a friendly tip.

More Komodo Love

7 Comments

So a while ago, I requested syntax highlighting for CoffeeScript in Komodo. A bug was opened. A dude was put on the case. Not much happened.

I thought.

Not long ago, I updated the bug to reflect the fact that CoffeeScript is going to be baked-in to Rails 3.1.

Four hours later, the bug is resolved. Apparently, they’d built CoffeeScript highlighting into Komodo 7.0, and back-ported it into 6.1 because of my comment on this bug.

Keep on bein’ awesome, Komodo.

EDIT: For those who were curious, the Bug ID is 89419.

Public Service Announcement

No Comments

How to revive a cherished childhood show

How NOT to revive a cherised childhood show

That is all.

Setting up a Virtual Machine for Node.js development on Windows 7

13 Comments

If you run Windows 7 and you want to develop for the latest version of Node.js, you’re in for a bumpy ride. You can compile it under Cygwin, but the process is complex and doesn’t work for all versions. So what if:

  • You fear a later version of Node.js breaking on Windows again? (It was broken for two full minor versions, really quite a while.)
  • You don’t want to install Cygwin? (You madman, you really should.)
  • You are paranoid and want to be running your programs on the same environment you will be deploying them on?
  • You just can’t get the dang instructions to work?

Well, the solution isn’t to reformat and install Linux (though that could very easily help your productivity – fewer games being played, I’m sure). The solution is to install Node.js on a Virtual Machine with a shared drive. And honestly? It’s pretty easy. Three steps!

Step One: Install VirtualBox

Download VirtualBox here, then follow the instructions.

Step Two: Install Ubuntu Server

Download Ubuntu Server here, then create a new Virtual Machine. Name it what you will.

Under the “Network” tab in settings, change the adapter to a “Bridged Adapter”. This will force the machine to get a locally-addressable IP address.

Under the “Shared Folders” tab in settings, click the “Add” button, set the folder path to some new folder on your Windows 7 system. Set the folder name to something simple like “nodejs”.

Under the “Storage” tab, click on the “IDE Controller”, then click the little CD button. Navigate to where you downloaded the Ubuntu Server ISO and select it.

Now boot your new Virtual Machine and follow the Ubuntu Server setup options. Install whatever your little heart desires, but I recommend an SSH server so you don’t have to install it later.

Once it’s installed, run the following commands to install VirtualBox Guest Additions:

sudo apt-get update
sudo apt-get install build-essential linux-headers-$(uname -r)
sudo apt-get install virtualbox-ose-guest-x11

Next, create a “nodejs” folder in your home directory, and add the following to your rc.local file (use the command “sudo nano /etc/init.d/rc.local”):

mount -t vboxsf nodejs /home/[YOUR_USER_NAME_GOES_HERE]/nodejs

Restart and your Windows folder should be hooked up to the nodejs folder on your Ubuntu VM.

Step Three: Install Node.js

This part’s super-simple. Run the following commands:

sudo apt-get update
sudo apt-get install git-core curl build-essential openssl libssl-dev
git clone https://github.com/joyent/node.git && cd node
./configure
make
sudo make install
node -v
cd
curl http://npmjs.org/install.sh | sudo sh

That’s it! You’re set up with Node.js and Node’s package manager, NPM. If you want to test it, go to your nodejs folder (in either Windows or Ubuntu, both should be working now) and make a file called “hello.js”, and put the following in it:

var sys = require('sys');
sys.puts('Hello!');

Then go to your Ubuntu system and run:

node hello.js

References

Thanks to Sysprobs and Giant Flying Saucer. It took a while to dig them up, but these two guides are what allowed me to figure out this neat little setup.

New Kohana module: Kohana-CoffeeScript

No Comments

So I sort of fell in love with the elegance of CoffeeScript the other day, but the issues surrounding actually using it were preventing me from really giving it a go. Primarily, I was having problems with the whole “you have to compile it into javascript before you can use it, meaning every time you make a CoffeeScript change, you have to manually run a compilation on it” issue.

However, I’ve already written a module for Kohana to minify and combine Javascript files – this is an area I already have experience in!

A short while later, and blammo! A CoffeeScript compiler module for Kohana was born. (Yep, module births make the “blammo” noise. I’ve heard human births sound different, but let’s not go there.)

There’s instructions on how to use it at the link above, but basically, you just install it, enable the module, and pass your CoffeeScript files to the module’s compile() function in an array. It’ll either spit back a script tag or the script URL, whichever you need.

Hopefully this makes it a little easier for Kohana folk to get into CoffeeScript.

Older Entries Newer Entries