Recently I have been making great use of the excellent ActiveScaffold for a Ruby on Rails project I have been hired to create.
ActiveScaffold (AS) makes it really easily to do a calculation on the columns, for example displaying the average of a column. In your controller you just need to do:
active_scaffold :sale do |config|
config.columns[:product_profit].calculate = :avg
end
However my client wanted both averages and totals at the bottom, so From reading the documentation and a quick web search it didn't look to be a pre-built way to do this, so I had to look at customising the ActiveScaffold.
I wanted to be able to set calculate the standard way with a single option, or have an array of options:
config.columns[:chassis_profit].calculate = :avg
-or-
config.columns[:chassis_profit].calculate = [:sum, :avg]
The answer was to be found in vendor/plugins/active_scaffold/frontends/default/views/_list_calculations.html.erb. This file was responsible for calling the caluation and displaying the result. The chosen calculation option was accessable via column.calculate. I needed a way to handle both single values and arrays. The following code allowed me to iterate over an array, but still works if column.calculate was a single value:
<% for calculation_type in [*column.calculate] -%>
column.calculate = calculation_type
<% end -%>
As I looped over the array I set column.calculate to each single value, so I did not affect the way AS worked.
23 Oct 2009
Things to look at
http://www.flickr.com/photos/timferriss/2919230853/in/set-72157607796715778/
http://www.dolectures.com/brainfood/
http://www.dolectures.com/brainfood/
Some thoughts to flesh out
- Adding win states and game-like mechanics into stuff to postively encourage peoples actions (for example: visible energy usage meters, displaying current MPG in cars, points & badges in software). This idea seems to have the potential to be very powerful.
- If you yourself want to make a positive impact and a meaningful footprint on the world, you need to recruit people that will also take action. You need to be offering those people a compelling goal, one that will also offer them the oppurtunity to be part of history. Your goal, your message needs to be clear.
- Retail anchor tenants (i.e. you have a new shopping centre and literally pay a big brand to move in). Again seems a powerful idea if transposed into other fields.
10 Oct 2009
More books
There seems to be a theme with many of the books I really enjoy. They give you some insight into things really are; just science and figures, no fluff.
26 Sept 2009
My recent TV viewing
The Love of Money
Three part documnetary about the recent financial crisis:
1/3. Why the collapse of Lehman Brothers had disastrous consequences for the world's economy.
2/3. Examining the boom years before the global crash, with testimony from key decision makers.
3/3. The story of how politicians reacted to the crash, and what has been learnt from it.
http://www.bbc.co.uk/programmes/b00mqmjs/episodes/player
Alone in the Wild
http://www.channel4.com/programmes/alone-in-the-wild/4od
Nigel Slater's Simple Suppers
http://www.bbc.co.uk/programmes/b00mm51f/episodes/player
Economy Gastronomy
http://www.bbc.co.uk/programmes/b00m1c34
Jamie's American Road Trip
Jamie Oliver tours parts of America not often seen on TV and enjoys some of the unique food
Jonathan Meades: Off Kilter
1/3. Architecture critic Jonathan Meades takes a quixotic tour of Scotland.
2/3. On the isle of Lewis and Harris, Meades discovers serenity, Calvinism and peat bog bodies.
3/3. Meades celebrates an oil refinery and takes potshots at overpaid footballers.
http://www.bbc.co.uk/programmes/b00mrbdt
Peep Show - Season 6
http://www.channel4.com/programmes/peep-show/4od
Three part documnetary about the recent financial crisis:
1/3. Why the collapse of Lehman Brothers had disastrous consequences for the world's economy.
2/3. Examining the boom years before the global crash, with testimony from key decision makers.
3/3. The story of how politicians reacted to the crash, and what has been learnt from it.
http://www.bbc.co.uk/programmes/b00mqmjs/episodes/player
Alone in the Wild
http://www.channel4.com/programmes/alone-in-the-wild/4od
Nigel Slater's Simple Suppers
http://www.bbc.co.uk/programmes/b00mm51f/episodes/player
Economy Gastronomy
http://www.bbc.co.uk/programmes/b00m1c34
Jamie's American Road Trip
Jamie Oliver tours parts of America not often seen on TV and enjoys some of the unique food
Jonathan Meades: Off Kilter
1/3. Architecture critic Jonathan Meades takes a quixotic tour of Scotland.
2/3. On the isle of Lewis and Harris, Meades discovers serenity, Calvinism and peat bog bodies.
3/3. Meades celebrates an oil refinery and takes potshots at overpaid footballers.
http://www.bbc.co.uk/programmes/b00mrbdt
Peep Show - Season 6
http://www.channel4.com/programmes/peep-show/4od
29 Aug 2009
7 Aug 2009
Book Recommendations
A few excellent books worth reading:
The Science of Cooking, by Peter Barham
If you watch a few TV cooking programmes you will hear often repeated rules without any explanantion, "sear your steak first", "always sieve flour". If this ever gives you the pestering thought of, "Why?", then this is the book for you.
The Unfolding of Language, by Guy Deutscher
Absolutely superb! Gives you a great insight into why language changes and how it develops; why irregularites come about, and shows how fundamental metaphor is to any language.
The Selfish Gene
The Science of Cooking, by Peter Barham
If you watch a few TV cooking programmes you will hear often repeated rules without any explanantion, "sear your steak first", "always sieve flour". If this ever gives you the pestering thought of, "Why?", then this is the book for you.
The Unfolding of Language, by Guy Deutscher
Absolutely superb! Gives you a great insight into why language changes and how it develops; why irregularites come about, and shows how fundamental metaphor is to any language.
The Selfish Gene
Subscribe to:
Posts (Atom)