Skip to main content

This is a new website theme. Help me improve it and give your feedback (opens in a new tab).

Java

metrics-bot

On Thursday during the metrics team meeting we decided to rename AtlasBot to metrics-bot to better fit the naming scheme of the team’s other projects.

It would appear that there has been interest in the bot and that it’s something that people want.

The JavaDoc has now moved to a new location, a git repository has been created and there is a new Trac component to organise the metrics-bot todo list.

I’ve planning to be able to push the sources for metrics-bot to the git repository early next week. I just need to do one more pass to make sure there’s no Twitter credentials left in it, and then I’ll be able to close #23933 too.

List Comprehension

Still in the process or tidying up the bot behind the @TorAtlas Twitter account, which means I’m still writing Java. I’ve now been exploring “list comprehension"-like techniques using another new Java 8 feature, Streams. Essentially this involves creating lists from lists in an elegant way.

In Python, I would do something like:

runningRelays = [relay for relay in relays if relay['is_running']]

(I know something is happening because writing that example line I had an incredible urge to terminate the line with a semicolon.)

Duration and Period

I’m in the process or tidying up the bot behind TorAtlas and I’ve chosen to write it in Java. My undergraduate degree had a lot of Java in it, but that was while ago now, and there are some cool new features I’ve learnt about including Period and Duration.

Some of the tweets coming from the bot talk about how long a relay has been contributing to the Tor network. When fetching the details document I look at the first_seen field and get this as a ZonedDateTime to make sure I’m doing all my calculations in UTC. I then use the between() method on various ChronoUnits to work out how long between the first time the relay was seen and now, and then I produced something human readable from this: