Merb Routes

Posted about 19 hours back at Robert Evans - Home

Here’s a quick rake task for you, if you want to see merb routes without having to do merb -i

desc "Show routes" 
task :show_routes => :merb_env do
  require 'merb-core/rack/adapter/irb'
  Merb::Rack::Console.new.show_routes
end

In terminal, just do rake show_routes. If you are looking for something specific, you can always do rake show_routes | grep user.

Merb Routes

Posted about 19 hours back at Robert Evans - Home

Here’s a quick rake task for you, if you want to see merb routes without having to do merb -i

desc "Show merb routes" 
task :merb_routes => :merb_env do
  require 'merb-core/rack/adapter/irb'
  Merb::Rack::Console.new.show_routes
end

In terminal, just do rake merb_routes. If you are looking for something specific, you can always do rake show_routes | grep user.

Add that to the Rakefile in your root dir, or better yet, use sake and do:

sake -i http://gist.github.com/raw/1406/bfec026a1e62b048288d9342e3fc0c2bd272fca7

Then you can do sake show_routes in any merb app dir! That’s served up straight from gist, github’s newest pastie based on git.

OpenMoko Freerunner after a few weeks

Posted about 23 hours back at Wolfmans Howlings

Well I have had this thing for a few weeks now, and I have burned a lot of hours playing with it :) (Wish I could bill someone for those hours it would have paid for the phone 4 times over!)

I started with 2007.2 the built in image, and upgraded it initially with dfu-util, then with opkg update && opkg upgrade.

I installed a bunch of things and tweaked it to death (literally).

I got Jalimo java installed and working, and wrote the simple SWT app which worked nicely. The only change to the instructions are you need to add -force-depends to the opkg command.

As reported in my other blog article I got WIFI/WPA2 working, and finally got GPRS working.

I have not tried to pair with a bluetooth headset yet, although got far enough to see that the device could be seen using the scan command.

I played with all the varieties of on screen keyboards available, but really couldn't use any of them as they are so small, and my eyes are not that good anymore. I have seen some promising mentions of works in progress for keyboards, but the ones in the Qtopia distribution are the best, plus they have handwriting recognition which is a little fussy but looks like it can be trained.

The GPS problems were fixed by an amazing community and OpenMoko effort, which I have never seen before. There is a S/W fix, and a H/W fix which I suspect most people will not be able to do, soldering surface mount components is not for the faint of heart!

I spent several hours trying to build the OpenEmbedded and the MokoMakefile development environments, so I could start to contribute, but have still not been able to get them to finish building the native toolchain needed to build any of the apps.

I get several errors, some of which I found workarounds to by googling but eventually hit dead ends in both cases which I could not solve and have not been reported or solved by the community. I am using a stock KUbuntu 8.08 Hardy Heron desktop, which should be pretty mainstream, so I don't know what is wrong. The pre built toolchain OpenMoko provides for building apps does work however, but you can't build soft keyboards, or system components that route (at least I couldn't find a way to do it). I'll continue to hammer away at MokoMakefile and see if I can eventually get it going, of course I'll post my findings to the Wiki or dev mailing list if I succeed.

If someone could provide a VMPlayer image of a working OE or Mokomakefile environment that would help a lot of us. (Trolltech/Qtopia do provide exactly that for their development tools).

So after several opkg upgrades and tweaks, I finally killed my highly customized rootfs, X would no longer boot, sound was dead etc etc.

I tried to backup the image using these instructions, but always got an error halfway through, I suspect my flash image of rootfs may have been corrupted. Anyway I lost all that work :(

I tried flashing ASU, but it seems too much a work in progress more so than 2007.8.

Then I tried Qtopia now this is much more to my liking. The interface is clean, intuitive and seems to work pretty well. There are still a few rough edges which Trolltech seem to be taking care of, but it mostly works pretty well. The on screen input methods (which there are several of) are very good, even the keyboard has a nice touch where it zooms into the keys you are touching. It also has the tiny tiny QWERTY keyboard if you prefer that style and your eyes still work.

The downside is of course you lose access to all the applications currently under development for the GTK based 2007.2, but Qtopia does have a growing number of applications, and of course you can write your own.

I am going to experiment a little with trying to run GTK based apps under Qtopia, I know I can do that on my KDE (aka QT) desktop, so why not under Qtopia? I'll update this if I get it to work.

The current show stoppers for me, which stops me being able to use this a phone are...

  • Nasty buzzing noise on both ends of the call
  • Bluetooth pairing with a headset not easily available.

I'm sure people are working on these issues, and I wait patiently for them to get fixed so I can dump my aging Motorola V600. I'd actually try to pitch in myself but I can't get the development environment to work!

Oh well guess I better get back to my paying job :)

iPhone in nearly every state. 147 out of 188 stores.

Posted about 23 hours back at OnRails.org

20080722_IphoneEveryWhere.png

From hasiphone.com July 22nd 2pm.

RedCloth 4.0 Released: 40x Faster Textile Rendering

Posted 1 day back at Ruby Inside

redcloth.png

RedCloth is a popular Ruby library for converting Textile-formatted text into HTML. Initially developed by WhyTheLuckyStiff, it's now under the guardianship of Jason Garber, who has just released version 4 (RubyForge or Github). This is a significant update, following on from 3.0.4 which was released almost three years ago, and features a handful of significant improvements and changes:

  • New SuperRedCloth (RedCloth 4.0) is a total rewrite using Ragel for the parsing.
  • Markdown support has been removed.
  • Single newlines become <br> tags, just as in traditional RedCloth and other Textile parsers.
  • HTML special characters are automatically escaped inside code signatures, like Textile 2. This means you can simply write @<br />@ and the symbols are escaped whereas in RedCloth 3 you had to write @&lt;br /&gt;@ to make the code fragment readable.
  • HTML embedded in the Textile input does not often need to be escaped from Textile parsing.
  • The parser will not wrap lines that begin with a space in paragraph tags.
  • Rudimentary support for LaTeX is built in.
  • RedCloth::VERSION on a line by itself inserts the version number into the output.
  • Output (less newlines and tabs) is identical to Textile 2 except a few cases where the RedCloth way was preferable.
  • Over 500 tests prevent regression
  • It's 40 times faster than the previous version.

Unless fiddling with the edge version on Github interests you, you can install or update with gem in the usual way - gem install redcloth, etc.

What's New in Edge Rails: Standard Internationalization Framework

Posted 1 day back at Ryan's Scraps

Internationalization (i18n) is a tough nut to crack and has long been handled in Rails by a variety of plugins. Thanks to a concerted effort by the Rails i18n team we now have a standardized framework for providing internationalization.

Rather than rehash what’s already out there, head over to Sven’s writeup of the new Rails Internationalization framework for the skinny.

It’s important to note that this does not provide actual language translations but merely a way for you to plug in other translations and internationalization implementations into your app.

tags: ruby, rubyonrails

FOSCON: Ruby Event in Portland, OR - July 23, 2008

Posted 1 day back at Ruby Inside

foscon.png

FOSCON is a "free, fun gathering" of Ruby developers held alongside the O'Reilly OSCON conference currently taking place in Portland, Oregon. It's tomorrow (Wednesday, July 23) at CubeSpace (near the Oregon Convention Center) from 6pm. The always proactive Portland Ruby Brigade have organized it, and a surprising number of interesting presentations are already planned, including one on IronRuby from John Lam of Microsoft. A live coding competition will also be taking place.

Unix Signals for Live Debugging

Posted 1 day back at igvita.com

It's unit tested, the integration and regressions tests are all green, you even added a set of performance benchmarks, and yet after a couple of hours of production use the process is falling over - we've all been there before. Good instrumentation in these situations is worth its weight in gold. If you're lucky, you may be able to use DTrace, if you're adventurous you may try to attach with GDB, but what if you build this instrumentation into your app right from the start?

System signals for easy debugging

Any UNIX process can respond to a collection of system signals, and what's even better: we can safely define a subset (USR1, and USR2) to invoke arbitrary logic within our process. For example, let's create a worker process which on receipt of a USR1 signal will toggle debug mode on demand:

> debug-mode.rb

require 'rubygems'
require 'log4r'
 
# initialize the logger
@log = Log4r::Logger.new 'log'
@log.outputters = Log4r::StdoutOutputter.new 'console'
@log.level = Log4r::INFO
 
worker = Thread.new do
  while (true) do
    @log.info 'Hello!'
    @log.debug 'Debug!'
    sleep(1)
  end
end
 
# put worker into debug mode via USR1 signal
trap("USR1") {
 @log.level = @log.level == Log4r::INFO ? Log4r::DEBUG : Log4r::INFO
}
 
# cleanly shutdown the thread on Ctrl-C / kill signal
trap("INT") { worker.terminate }
 
# run the worker
worker.join
 

In the example above Log4r provides us with a convenient logging hierarchy: DEBUG < INFO < WARN < ERROR < FATAL. By sending our process a USR1 signal (kill -s USR1 pid), we toggle between the INFO and DEBUG levels, allowing ourselves the luxury of performing live debugging without incurring the cost of redundantly logging debug information when we don't need it. Now you have the tools to perform that open-heart surgery.

INFO log: Hello! < process is started
INFO log: Hello!
INFO log: Hello! < process receives USR1
DEBUG log: Debug!
INFO log: Hello!
DEBUG log: Debug! < process receives USR1
INFO log: Hello!
INFO log: Hello!

For bonus points, check what signals your favorite UNIX processes respond to. For example, did you know that kill -s USR1 mongrel_pid will turn on debug mode on any Mongrel process? Make use of system signals, they're there for reason!

ActionScript: Literal XML

Posted 1 day back at Jay Fields Thoughts

One feature of ActionScript I really like is the ability to use XML within the language. In ActionScript there's no need to use strings to represent XML, you can use XML inline just as you would any other literal (numbers, strings, etc).

Recently I was working on some dynamic code that needed to update based on an XML response. We were just getting started on the card, so instead of worrying about the service, how it was triggered, etc, we added a button to the interface that called the response parsing method and passed in an XML literal as an argument. The code is similar to what's shown below.

parseResponse(<user><firstName>Jay</firstName></user>);

Sure, we had to change the code later and make a real service call, but this quick solution let us keep focusing on the task at hand instead of how to get the XML. In a language like Ruby we could have used a builder or just a string, and given such a small amount of XML it would have been fine. However, the actual XML we were working with was significantly larger than the example and would have been a decent mess of a multiline string or several builder calls. Being able to write XML natively was significantly easier.

The beauty of literal XML is the simplicity. I don't have to represent it in any way other than what it actually is -- XML.

If you aren't a fan of all the angle brackets, that's okay, ActionScript has you covered there also. You can add elements and attributes as you would expect to be able to if you prefer method calls.

var request:XML = <smart_list/>;
request.sort.order = "highest";
request.sort.field = "Average Position";
request.max_results = 10;
request.toXMLString(); // "<smart_list><sort><order>highest</order><field>Average Position</field></sort><max_results>10</max_results></smart_list>"

If you only ever use XML similar to the above syntax, then there may be little value in literal XML, but I don't think you're usage would be limited to the above syntax.

I write tests, a lot of them. I prefer to see the actual XML in my tests, instead of the builder versions of XML. I don't like angle brackets any more than the next programmer, but I strongly prefer testing with expected literals. I find my resulting tests to be more readable and reliable. If you've ever had a test fail because of whitespace issues in your XML, you should know what I mean by reliable.

Literal XML also ensures XML compliance at compile time and encourages IDEs to provide syntax highlighting. Two things that aren't essential, but are definitely nice to have.

ActionScript is the first language I've used with literal XML support, and I'm very happy with the experience. As programmers we spend a lot of time hiding other languages with object relational mappers (orm) and builders, but literal XML is a refreshing step in the other direction. The creators of ActionScript have embraced the fact that XML isn't going anywhere. They built first class support for XML in the language itself instead of hiding the problem with a framework, and that helps me significantly more than any orm or builder ever has.

You See the Invisible Block?

Posted 1 day back at Marc-André Cournoyer's blog



require "rubygems";require "thin";require"markaby"; class Invisible
HTTP_METHODS =[:get,:post,:head,:put,:delete];attr_reader :request,
:response, :params; def initialize(&block); @actions =[]; @with=[];
@layouts={};@views={};@helpers=Module.new;@app=self; instance_eval(
&block) if block end; def action(method, route, &block); @actions<<
[method.to_s, build_route(@with*"/"+route),block] end;HTTP_METHODS.
each{|m|class_eval "def #{m}(r='/',&b); action('#{m}', r, &b) end"}
def with(route); @with.push(route);yield;@with.pop end; def render(
*args,&block);options=args.last.is_a?(Hash)?args.pop: {};@response.
status=options.delete(:status)||200;layout=@layouts[options.delete(
:layout)||:default];assigns={:request=>request,:response=>response,
:params=>params,:session=>session};content=args.last.is_a?(String)?
args.last : Markaby::Builder.new(assigns,@helpers, &(block||@views[
args.last] )).to_s ; content = Markaby::Builder.new( assigns.merge(
:content => content), @helpers, &layout).to_s if layout; @response.
headers.merge!(options);@response.body=content end;def layout(name=
:default, &block); @layouts[name]=block end; def view(name,&block);
@views[name]=block end; def helpers(&block);@helpers.instance_eval(
&block ) ; instance_eval(&block)  end;  def session;  @request.env[
"rack.session"]end; def use(middleware, *args);@app=middleware.new(
@app,*args) end; def run(*args);Thin::Server.start(@app, *args) end
def call(env); @request = Rack::Request.new(env); @response =Rack::
Response.new; @params = @request.params; if action = recognize(env[
"PATH_INFO"], @params["_method"] ||env["REQUEST_METHOD"]); @params.
merge!(@path_params);action.last.call;@response.finish; else; [404,
{}, "Not found"]; end; end; def self.run(*args,&block);new(&block).
run(*args) end; def self.app;@app||=self.new end;def self.call(env)
@app.call(env) end; private; def build_route(route);pattern= route.
split("/").inject('\/*') { |r, s| r << (s[0] == ?: ? '(\w+)' : s) +
'\/*' } + '\/*';[/^#{pattern}$/i,route.scan(/\:(\w+)/).flatten] end
def recognize(url, method); method =method.to_s.downcase; @actions.
detect do |m,(pattern,keys),_| method==m&&@path_params=match_route(
pattern,keys,url)end;end;def match_route(pattern,keys,url);matches,
params=(url.match(pattern)||return)[1..-1],{};keys.each_with_index{
|key,i| params[key]=matches[i]};params;end;end; def method_missing(
method, *args,  &block);  ; if Invisible.app .respond_to?(method) ;
Invisible.app. send( method, *args, &block);  else; super; end; end

No!

beauty is fleeting (or why rails-doc isn’t the answer but something else might be)

Posted 1 day back at omg blog!! lol!!

So my last post, for whatever reason, spawned a flurry of posts pointing to rails-doc, a project by a team from Nodeta, claiming that it solved a number of Rails documentation problems. It’s a very nice looking project with a sexy theme (their blog design is especially attractive), but I’m sort of having a problem seeing how this solves any sort of problem that hasn’t been “solved” before.

sexy much?

For those of you too new to Rails to remember, there was (and apparently still is a project) named Rails Manual that does the exact same thing in a less attractive shell.  It’s based on a project named Rannotate, which creates a Rails app from your Ruby project’s documentation and enables adding notes to it.  It garnered a little attention when it first came out, but eventually went the way of the buffalo.

So now we have rails-doc.  Like I said, it looks good, but it strikes me as the exact same thing.  It’s basically the RDoc’s with notes, which solves a piece of the problem, but it’s not anywhere near a total fix for the poor documentation situation (even though I think some people are on the right track!).  If I’d known that all we needed was a good looking RDoc app, I could’ve fixed the problem a while ago.

That’s a screenshot of the design that my Google Summer of Code student (Ian Ownbey) and I are currently working on applying to his project Docbox and my derivative project Docdock (which will be on my Github very soon). 

Docbox is like Rannotate and friends (it lets you add notes, browse, search, etc.) except it also lets users actually edit the documentation in their browser.  It will then take their edits and generate a git commit on its own branch on the backend that the developers can cherry pick back into the mainline documentation.  You want to talk about user contribution?  There it is.  I’m waiting for my student to deploy to a slice and I’ll link that demo site here.  The plan is to let you edit the docs on a sample app and see your changes get pushed straight to a Github project so you can see it happen in near real-time. :)

My project is slightly less glamorous.  Docdock is essentially a client facing application based on Docbox.  Projects like Rails or a company with a closed source Ruby product could use Docdock to have an API site that users can visit, add notes to, and get involved with that looks good but without allowing everyone to edit it.  Larger or proprietary projects probably don’t want their official doc site to be totally editable. :)  The good thing about Docdock is that it can actually hook into the same database as Docbox, so you can have an instance of Docbox running on the backend for your team and an instance of Docdock running on the front end for your users.  This will probably just create a separate connection to keep everything separate except for the documentation objects, but I haven’t gotten quite that far yet.

So, there you go.  Two documentation tools geared towards user contribution.  Oh, and did I mention they’re both totally open source and applicable to any Ruby project, not just Rails?  I didn’t bring them up before because I didn’t know how interested people would be, but if people get excited about a resurrected Rannotate with dcov and search thrown in, then surely people will find these tools useful.

RubyFringe == Awesome

Posted 1 day back at Marc-André Cournoyer's blog


RubyFringeNick Sieger though us about Jazz, Giles Bowkett got a standing ovation, Zed Shaw sang “Matz can’t patch” and “Don’t fuck Chad’s community”, Geoffrey Grosenbach was wearing a kilt, Hampton Catlin presented Haml for Javascript, Damien Katz made me cry and Tom Preston-Werner is my new hero.

Better reviews

Starling: A Ruby Persistent Queue Server That Speaks Memcached

Posted 1 day back at Ruby Inside

starling.png

It's been around for a while now, but Starling is a "light-weight persistent queue server that speaks the MemCache protocol." Starling makes it ridiculously easy to set up a network-accessible queue (or many queues) for, say, asynchronous job processing between multiple processes and machines. It was developed by Twitter to handle the heavy amount of queueing necessary to keep their service ticking over. Starling is proven in production, with not only Twitter using it in anger, but FiveRuns too. FiveRuns have even created their own fork that, they say, is significantly faster.

Why the sudden interest in Starling? Well, Glenn Gillen has written an excellent introductory guide to setting up Starling over at RubyPond.com. He walks through the process of using Starling (and Workling, a Rails plugin to make using Starling easier) from installation, through to actually adding things to the queue and processing them.

An interesting alternative to Starling is also presented within the comments on Glenn's post - RudeQ. RudeQ uses the same API as Starling but is ActiveRecord / database based, meaning there's no extra process to monitor. I suspect it's nowhere near as fast, but if you'd rather avoid the headache of monitoring another persistent process or don't have the option of having a persistent process at all (shared hosting, perhaps) it's worth checking out.

Post supported by Brightbox: Brightbox is a specialist European Rails hosting company. Each Brightbox server includes an optimised Ruby on Rails stack, SAN storage and access to a managed MySQL database cluster. They also manage dedicated clusters for large scale Rails deployments. Click here to learn more...

Google Introduces Binary Encoding Format: Protocol Buffers

Posted 1 day back at InfoQ Personalized Feed for unregistered user - Register to upgrade!

Google caused a stir by releasing Protocol Buffers, a binary serialization format. We take a look at what exactly Protocol Buffers are and what alternatives are available in ASN.1 or Facebook's Thrift. By Werner Schuster

Databases Roundup: Data Sharding for ActiveRecord and Faster Postgres IO

Posted 1 day back at InfoQ Personalized Feed for unregistered user - Register to upgrade!

In this databases roundup we take a look at DataFabric, FiveRun's recently open sourced data sharding plug-in for ActiveRecord. Also: a look at speeding up Postgres data access using the asynchronous client API and Ruby 1.9's Fibers. By Mirko Stocker


1 2 3 4 ... 472