Posted by labria
on September 15, 2009
I wrote my first working bit of Erlang code. Wasn't much code, actually. Here it is:
<erl>
out(A) ->
{ok, Challenge} = queryvar(A,"hub.challenge"),
{html,io_lib:format('~s', [Challenge])}.
</erl>
Wow... my highlighter doesn't even support Erlang! now it does
This a complete and finished piece of code, yes. If you heard of PubSubHubbub — that's the code to confirm all subscriptions in async mode.
The funny thing about it is the amount of code I would user to do the same in Rails/Sinatra/Whatever + erb:
<%= params["hub.challenge"]%>
Posted by labria
on September 10, 2009
This article is published as a reply to the last few articles on the thoughtbot blog.
Some time or another during the project development you may wonder: «What files does my project include?» or «Why am I a Star Wars fan anyway?». This article will focus on the first question, leaving the second to your own reflection.
Any shell you might be using comes with a lot of useful tools. The one of interest today is ls
Here's the most simple example of its usage in a Rails project
sample_project $ ls
README app db lib public test vendor
Rakefile config doc log script tmp
As a little more complex example, you might want to get the list of your model files:
sample_project $ ls app/models/
comment.rb post.rb
Or, it even can do crazy stuff, like list all your model files AND controller files AND helper files! Now thats some useful magic, isn't it?
sample_project $ ls app/*
app/controllers:
application_controller.rb comments_controller.rb posts_controller.rb
app/helpers:
application_helper.rb comments_helper.rb posts_helper.rb
app/models:
comment.rb post.rb
app/views:
comments layouts posts
ls can do much. much more. Go check out the manual page here, you'll be amazed.
Note to Windows users: you also have a similar command, named dir.