The point is to write a Fnordmetric helper. Fnordmetric is a "statsd-like" metric collector without the Carbon hassle.
- I would like to be able to do things like :
push_timer :hell_yeah
| # Sequel Basic Scafolding Model Generator for MySQL | |
| # This routine takes all the table of a database, en generates all Sequel models for Ramaze | |
| # For each table model we put : | |
| # - A header that reminds you the table structure | |
| # - the plugin list you wrote in 'plugin_to_add' array | |
| # - The Sequel referential inegrity : one_to_many, many_to_one | |
| # - A "Validate" method that checks not nullable columnns and unique columns | |
| # - Generates init.rb to be include in the project | |
| # | |
| # Note : db_connect.rb should already exists. Create it using Rake |
| $ ../hacking/test-module ./service name=httpd state=started | |
| Traceback (most recent call last): | |
| File "../hacking/test-module", line 53, in <module> | |
| argsfile = open(argspath, 'w') | |
| IOError: [Errno 13] Permission denied: '/.ansible_test_module_arguments' |
| Vidar Hokstad | |
| Home Blog Ruby Compiler Sliding Stats | |
| 2008-03-22 16:02 UTC Rack middleware: Adding cache headers | |
| Posted in: ruby, rack, programming | |
| I'm playing with a small web based RSS reader, and one of the things it does is cache a lot of data to reduce the impact on the sites I follow feeds from. However I realized this a couple of days ago I'd completely forgotten to set cache headers, and I kept hammering my own site. | |
| That wouldn't do, and since my app is using Rack to interface to the webserver, there's a simple solution: Write a tiny Rack middleware class, just like I described in "Rewriting content types with Rack". | |
| The great thing is that because of Rack this class can be used to add cache headers for anything from pure Rack based apps to apps using Rails, Merb, or any number of other Ruby frameworks that has Rack adapters. If you haven't looked into Rack already, do. |
| # FNordmetric helper | |
| # | |
| # Define :fnord_redis_url trait in class where helper is used | |
| # e.g. : trait :fnord_redis_url => "redis://redis.example.com:6332" | |
| # | |
| require 'fnordmetric' | |
| module Ramaze | |
| module Helper | |
| module FnordmetricHelper |
| require 'ramaze' | |
| class MyController < Ramaze::Controller | |
| map '/' | |
| helper :blue_form | |
| def index | |
| # BlueForm requires the passed object to respond_to? key names | |
| @result = OpenStruct.new(request.subset(:textname, :textanother)) | |
| require 'ramaze' | |
| # Put a jpeg in the same directory as this file named 'image.jpg" | |
| # calling index.jpg will yell at user | |
| # calling send_image.jpg will send back image.jpg | |
| class MyController < Ramaze::Controller | |
| map '/' | |
| provide(:jpg, :type => 'image/jpeg') do |action, value| |
| #!/usr/bin/perl | |
| use strict; | |
| use threads; | |
| use Thread::Queue::Any; | |
| use Net::OpenSSH; | |
| use Parse::DMIDecode::Constants qw(@TYPES); | |
| use Parse::DMIDecode qw(); |
| class SomeStuff < Ramaze::Controller | |
| helper :versionner | |
| def index | |
| "Hello world" | |
| end | |
| end |