|
|
|
Sunday, 23 May 2010 11:53 |
If you need to inspect the contents of an array from an IRB session use PP.
require 'pp'
# a = some complex array
PP.pp(a, $>, 40)
e.g.
require 'line-tree'
lines =<http://about:blank hello
http://ready:blank morning
http://ready2:blank morning2
http://ready3:blank morning3
travel
hotel lobby
supermarket
museum
http://about:blank hello2
http://ready:blank afternoon
http://ready2:blank afternoon2
http://ready3:blank afternoon3
LINES
a = LineTree.new(lines).to_a
PP.pp(a, $>, 40)
output:
[[["http://about:blank hello"],
[["http://ready:blank morning"]],
[["http://ready2:blank morning2"]],
[["http://ready3:blank morning3"]],
[["travel"],
[["hotel lobby"]],
[["supermarket"]],
[["museum"]]]],
[["http://about:blank hello2"],
[["http://ready:blank afternoon"]],
[["http://ready2:blank afternoon2"]],
[["http://ready3:blank afternoon3"]]]]
# or without PP
def format_line!(a, i=0)
a.each do |x|
puts "%+2s %s " % [i, x.shift]
format_line(x, i+1) unless x.empty?
end
end
format_line!(a)
output:
0 ["http://about:blank hello"]
1 ["http://ready:blank morning"]
1 ["http://ready2:blank morning2"]
1 ["http://ready3:blank morning3"]
1 ["travel"]
2 ["hotel lobby"]
2 ["supermarket"]
2 ["museum"]
0 ["http://about:blank hello2"]
1 ["http://ready:blank afternoon"]
1 ["http://ready2:blank afternoon2"]
1 ["http://ready3:blank afternoon3"]
I vaguely remember stumbling across Pretty Print from a post on RubyInside [rubyinside.com].
Resources:
- Formatting Ruby's prettyprint [stackoverflow.com] Read more: |
|
|
Thursday, 08 April 2010 11:04 |
How to instantiate a logger with commons-logging (though now I'd rather use SLF4j).
Notice that some prefer to have it static, some not, and somebody prefers the name "logger" to "LOG".
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
...
public class MyClass {
private static final Log LOG = LogFactory.getLog(MyClass.class);
...
 Read more: |
|
Thursday, 18 March 2010 21:27 |
//Find files containing "Some Text" and removed them. Change "Some Text" to whatever you need to look for.
# find . -name '*' -exec grep -l "Some Text" {} \; -exec rm {} \; Read more: |
|
|
Saturday, 27 February 2010 22:27 |
|
Last October the Joomla! Community in Italy put on an incredible Joomla! Day. Over 500 people attended and another 7000 watched on the live stream. I watched some of it live, and (even though I don't speak Italian) it was amazing. Not only that, they ran it as a free event and still made enough money to contribute 750 Euros to the Joomla! Project.

This was the second time the Italian community did a hugely successful event, with some of the largest crowds ever at Joomla! Days.
You can see more photos, video and slides. Some are in English and some in Italian, but they are definitely worth looking over. Hagen Graf's Joomla! Template From Scratch is definitely worth viewing if you have ever really wanted to understand how to get going with your own templating. Others are great too.
Thanks go to all the volunteers who helped to organize such a great event as well as the sponsors, JoomlaHost, IIT, GiBiLogic and Prismanet who made the event and this contribution possible. Also a special thanks to AxelRed for his non stop commitment to making this and other great things happen for Joomla! in italy and elsewhere.
This is really a great contribution which will, among other things, help fund more Joomla! Days around the world this year. At last count, there are 18 already scheduled! Wow. And it's only February. Read more: |
|
Tuesday, 09 February 2010 12:00 |
|

I wish this moment could last forever...But the ticking clock is a constant reminder. Let's have some fun while we're still here...while we still have time! Read more: |
|
|
|
|
|
|
Page 8 of 8 |