Introducing Multiping: An Easy Way to Ping Multiple Hosts

Yet another day with 8% packet loss from Comcast, it seems. In a fit of frustration, I spent half an hour and wrote a tool that can be used to ping multiple hosts at the same time, for the purpose of making sure that the problem isn't external to Comcast's network.

Here's how to install it:

git clone git@github.com:dmuth/unix-utils.git

Here's how to use it:

./multiping google.com xe-3-1-3-0-ar03.newcastle.de.panjde.comcast.net

xe-3-1-3-0-ar03.newcastle.de.panjde.comcast.net is a router on Comcast's network which is upstream of myself and one of my neighbors, whom is experiencing the same issue.

And here's what the output looks like:

google.com: icmp_seq=33 ttl=55 time=16.950 ms
xe-3-1-3-0-ar03.newcastle.de.panjde.comcast.net: icmp_seq=33 ttl=61 time=14.612 ms
xe-3-1-3-0-ar03.newcastle.de.panjde.comcast.net: icmp_seq=34 ttl=61 time=14.525 ms
google.com: Request timeout for icmp_seq 34
google.com: icmp_seq=35 ttl=55 time=17.031 ms
xe-3-1-3-0-ar03.newcastle.de.panjde.comcast.net: icmp_seq=35 ttl=61 time=13.550 ms
google.com: icmp_seq=36 ttl=55 time=14.822 ms
xe-3-1-3-0-ar03.newcastle.de.panjde.comcast.net: icmp_seq=36 ttl=61 time=13.404 ms
3.615385
Average: 3.6 (13 votes)
Your rating: None

I hate pennies. I *really* hate pennies. What to do with them all?

I really hate pennies. Let me count the reasons:

Here, look at my pile of spare change that I've collected from the last few years:

DSC_7280

Just look at it. Half of that pile is pennies! The pile of pennies is worth what, $5? $10? The pile of nickels and dimes on the other side is probably 7 or 8 times that. I seriously think that if I take that many pennies into a bank to deposit that the security guards will shoot me just on general principle. Can't say I'd blame them.

3.47059
Average: 3.5 (17 votes)
Your rating: None

Log4Go Updates: colored text, Printf(), and SetLevelString()

I recently rolled out some updates for my Log4Go package which I'd like to talk about here.

My first update is the most technically appealing one: Printf()-style functionality.

Instead of having to concatenate strings, percent mark placeholders can be used in the same style as fmt.Printf().

Here are some examples:

log4go.Errorf("Expected 4, got: %d", 72)
log4go.Warn("The temperature in %s is %d degrees and rising!", "Saigon", 112)

The second change I made was the most visually appealing: colored text!

The color of the text printed is now dependent on the severity of the message. Errors are red, Warnings are yellow, Info messages are green, Debug messages are cyan, and Trace messages are purple.

Here is a screenshot of how it looks in Mac OS/X:

Credit where credit is due: I used Meng Zhang's excellent Terminal package for the colored text.

3.615385
Average: 3.6 (13 votes)
Your rating: None

Introducing Log4Go: Logging for Google Go

When working on my last project, I wanted an easy way to perform logging. I had difficulty finding a logging framework that worked for me, and I figured it would be another good small project if I were to write a log4j-like logger for Google Go.

Here's how to install Log4go:

GOPATH=`pwd` go get # Beginners
go get # Nerds

The latter example assumes that you have the environment variable $GOPATH set. When $GOPATH is set, any packages that are installed will go into a directory hierarchy under that directory. I recommend $HOME/golibs/ as a value for testing and development.

Here's sample usage of Log4go:

import log "github.com/dmuth/google-go-log4go"
    
func main() {
    log.SetLevel(log.DebugLevel)
    log.SetDisplayTime(true)
    log.Info("foobar")
}

And the output might look something like this:

[301.119ms] INFO: foobar

I wrote some sample tests for Log4go. Here's how to run them:

go test ./src/github.com/dmuth/google-go-log4go/

And if the test passes, the output should look like this:

ok      github.com/dmuth/google-go-log4go       0.009s

The source can be downloaded from GitHub:

git clone git://github.com/dmuth/google-go-log4go.git

This project wasn't too terribly complicated, but it gave me some new techniques to try in Google Go. My next project promises to be much more complicated and interesting. Until then, feel free to like, comment, rate, flame or whatever. Smiling

3
Average: 3 (7 votes)
Your rating: None

Multi Core CPU Performance in GoLang

I've been playing around with Google's programming language known simply as Go lately, and have learned quite a bit about concurrency, parallelism, and writing code to effectively use multiple CPU cores in the process.

An Overview of Go

If you are used to programming at the systems level, Go is effectively a replacement for C, but also has higher level functionality.

  • It is strongly typed
  • It can be compiled
  • It has its own unit testing framwork
  • It has its own benchmarking framework
  • Doesn't support classes, but supports structures and attaching functions to variables instantiated from those structures
  • Doesn't expose threads, but instead uses a construct called "channels" for communication between different parts of a Go program. More on channels shortly.

Your First Go Program

First, let's start with this Go code, which I will walk you through:

    c := make(chan string, config.Buffer_size)

    num_cores := 1
    for i:=0; i<num_cores; i++ {
        go func(c chan string) {
                <-c
            }
        }(c)
    }

    message := "x"

    for i:=0; i<10000000; i++ {
        c <- message
    }

What this piece of code does is it creates a channel--a construct similar to named pipes in UNIX or SQS queues in Amazon Web Services. One part of code can write to a channel while another piece of the code can read from the same channel and performed a NOOP. It also defines a function inline and precedes it with the keyword "go". That function is then launched in the background as a "goroutine". Goroutines can be thought of as "lightweight threads". Thousands of them can be spawned over the lifetime of a Go program with little impact on performance. If the "num_cores" variable is tweaked in the above code, the run time of the program should decrease as there will be multiple cores reading messages off of the channel. Finally, the code writes the string "x" into the channel 10 million times. Assuming the goroutine is running, the loop to populate the channel should execute on one core while the goroutines which read from the channel should execute on the other cores.

3.75
Average: 3.8 (12 votes)
Your rating: None

Furry Connection North 2013 Report

First, the stats.

There were 1,259 total attendees at this year's Furry Connection North.

We raised $21,299.67 for our charity, Country Cat & City Kitty Cat/Kitten Rescue.

As usual, I got to see a lot of friends there, and meet some people I only knew online in person for the first time. Good times all around.

DSC_7143 DSC_7148 DSC_7149 DSC_7152 DSC_7154 DSC_7190


2.6
Average: 2.6 (5 votes)
Your rating: None

Notes from "Scaling on AWS for the First 10 Million Users"

Earlier tonight, I had the pleasure of attending a presentation from Chris Munns of Amazon at the offices of First Round Capital about scaling your software on AWS past the first 10 million users. I already had some experience with AWS, but I learned quite a few new things about how to leverage AWS, so I decided to write up my notes in a blog post for future reference, and as a service to other members of the Philadelphia tech community.

Without further preamble, here are my notes from the presentation:

  • "Auto scaling is a tool and a destination"
  • AWS regions are connected via the public Internet, but availability zones in the same region are connected via Amazon-owned fiber. So AZ to AZ communication is entirely across Amazon's infrastructure.
  • More capacity is added to AWS's infrastructure each day than powered all of amazon.com in 2003. That's a lot of servers.
  • DynamoDB is based on a whitepaper that Amazon wrote back in 2003 or so.
  • DynamoDB is multi-AZ.
  • SQL is a well established technology with clear patterns to scalability (explained further down), and no matter what you think--your data is not special.
  • "Everything fails all the time"
    • Build with that in mind
    • "You cannot have greater than 4 nines in a single data center"
  • Elastic Load Balancers are Availability Zone independent
    • "session stickiness" can route repeat requests from the same person to the same EC2 instance
  • S3 and CloudFront should be used for static assets from your website.
    • This falls under "outsource your infrastructure" -- use Amazon's CDN instead of implementing your own
  • ElasticCache is better than a database for caching (less load) or local files (less invalidation issues)
    • It is hosted Memcache
  • S3 has 11 9s of durability
  • DynamoDB scales really well. Individual customers have done 500,000+ reads/writes with no issue.
  • Auto scaling lets you match capacity to load
3.333335
Average: 3.3 (6 votes)
Your rating: None

An American's Visit to Sweden and Denmark

I found myself between jobs a short awhile ago, and suddenly had a few weeks of downtime. Since I had an open invitation to visit Sweden and Denmark from friends living there, I figured I would take the opportunity and head over. I took a few pictures, and noted some observations about those countries.

First, Know Some Locals

If you want to take a package tour and see the parts of the country that are tourist attractions, feel free. But you'll get much more out of the experience if you know locals who can show you things that they think are interesting. I was fortunate to know both Pinky Fennec and Joel Fox, who were more than happy to host me while I visited.

Public Transit is Amazing

DSC_6975
A subway station on the Hågsatra line

The train system in Stockholm is pretty extensive. Trains and busses run pretty much everywhere you'd want to go. Both systems used a wireless card that you could buy with a week's worth of fare, and just swipe it at the turn style or at the front of the bus. Subway stations had displays above the tracks stating how much time until the next train would arrive. When bus schedules said that busses arrived on the quarter of every hour, they meant it.

It was also pretty much the same in Copenhagen, except I spent more time on busses. The bus service there was simply phenomenal. They had busses that would arrive every 8 minutes, and they meant it. I regularly commuted from a friend's place on the outskirts of Copenhagen to the central part of the city every single day.

Getting from city to city was also fun. I rode on what amounted to the Swedish version of Amtrak from Stockholm to Copenhagen. It was a single train ride, about 400 miles in 5 hours. That's an average of 80 mph, but with the stops we made I'd say we did somewhere between 90 and 100 mph most of the time. The train ride was exceptionally smooth, and several times when we started moving I thought that the train next to us was moving. Naturally, these trains were also on time.

Danish Cheetah
This Danish cheetah tried to sell me a scarf!

Public transit here in the US could learn a few things from how they do it in these two cities.

Be Prepared to Walk Everywhere

What comes with taking lots of public transit? Lots of walking. Be ready to walk everywhere. This is actually a good thing, because of the benefits of the exercise it provides. One thing I noticed in both countries was pretty much a total lack of obesity in the native populations. This was especially noteworthy given the amount of drinking I saw in both countries.

Denmark Has Amazing Pastries

My first morning in Denmark, Pinky said "BRB" and ran a half-block down the street to the local bakery. She returned with a bundle of amazing pastries that were no more than a few hours old. They made for an amazing breakfast.

I wish I could remember what these delicious pastries were called, but I do know that the Danish just can't get enough of them!

3.333335
Average: 3.3 (6 votes)
Your rating: None

So I got invited to try out Google Glass


"Whoa. This is heavy."

So I got invited to try out Google Glass the other day. I'm looking forward to this, since this something that really hasn't been done before, at least not in the "voice-activated computer glasses with an Internet connection" sense.

A few ideas that I'm thinking of using the glasses for:

  • Using facial recognition on my friends, possibly with GPS
  • Hitting SEPTA's website to see what the next train to leave is.
  • Finding my way around new parts of Philadelphia. (the nicer parts, that is Eye-wink )
  • Streaming portions of Anthrocon
  • Taking some "behind the scenes" video of the setup in the days before Anthrocon, or during setup at the convention itself.

Have your own suggestions for how I should use the glasses? Let me know in the comments!

2.42857
Average: 2.4 (7 votes)
Your rating: None

The Cira Centre on a Cloudy Day

I took some pictures of the Cira Centre while walking around Philadelphia today:

The Cira Centre The Cira Centre
The Cira Centre The Cira Centre


The Regional Rail section of 30th Street Station can be seen in the foreground.

Anyway, like... favorite... let me know what you think in the comments!

3.42857
Average: 3.4 (7 votes)
Your rating: None