-
Bacon.js on the Server
Using Bacon.js to escape from Butcher Bay callback hell has been quite a pleasant, if mind-bending, experience. However, there hasn’t been too much talk about real usage on the server-side. I’d like to remedy this situation with some examples and tips I learned while converting a simple hand-coded REST API to Bacon.js.
-
Gun-shot Wound by User-Friendly (in the Foot)
Ingredients
- One spoonful of OSX
- A sprinkling of Git
- Three pounds source code
Preparation
- Rename
user.coffee
toUser.coffee
, settingcore.ignorecase
just in case - Commit, push
- Edit
User.coffee
and watch asgit diff
s don’t make any sense,git reset
doesn’t reset,git stash
doesn’t stash,git commit -a
doesn’t commit. - Laugh with glee as your editor jumps between the current and an old-old-old version
- Go on holiday, give up, freak out
Serve for two
- Realize (probably with help from colleagues) that the OSX file-system is not case-sensitive
- Go to GitHub or clone the project on Linux
- Realize that both
user.coffee
andUser.coffee
exist - Delete
user.coffee
-
Enter: the Coding Dojo
After having fought my way through Clean Code, I’m now reading The Clean Coder. Both are great books you should read. Clean Code helped me crystallize and expand on the ideas I had about good code. The Clean Coder is more about the part of programming you spend away from your computer; estimation, testing strategies, communicating inside and outside the team, generally being a professional. The whole book is really about being professional. (Disclaimer: links are affiliate links to Amazon)
I already have two active to-do items. There’s a whole paragraph asking “do you know what X is”? And honestly, I have no idea about most of those X’s. Not even what they may be about. So it’s probably time to pick up some more theory. On the other hand, Uncle Bob emphasizes actively honing your programming skills. A good way to do that is code katas. The term, apparently started here, is taken from martial arts: a kata is a series of excercises you practice until you achieve perfect form (for an appropriately small threshold).
-
Yesod: Ignore Trailing URL Slashes
Just a note if you need / want to remove the redirects of yesod (a Haskell web framework) from
http://myhost.com/
tohttp://myhost.com
. You can find the below instance declaration inFoundation.hs
if you’re using the scaffold. If not, you’ll know where it is, because you put it there :)instance Yesod App where cleanPath _ pieces = Right $ filter (not . ((==) "")) piece
This ignores any trailing slashes (and duplicates as well), so that all the following URLs will be considered the same as
http://myhost/a/b
-
http://myhost/a/b/
-
http://myhost//a//b
-
http://myhost/a/b//
-
http://myhost/a/b
-
-
Managing Your Private Server with Chef
You’re a cool kid, right? All the cool kids have their blog and other stuff on a VPS (or on GitHub, but that’s a different story). Really cool kids have their stuff on Linode, by the way; yes, that’s a referral link. All the cool kids use Chef to manage their infrastructure at work consisting of N-hundred Heroku dynos and AWS instances. So why not manage your VPS with Chef? While you’re at it, why not upload the whole thing to GitHub? (Like this)
[4]: http://wiki.opscode.com/display/chef/Chef Solo