Fedora, you need some slimfast

Let me get this out of the way up front. I absolutely love Fedora to death.

It’s my favorite distribution of linux by far, and I’ve played with a lot of different distros. I love the way way it works, I love how it’s on the bleeding edge, I love how things are laid out and they just make sense. I love the massive repository of almost every piece of software I want to run right at my fingertips. I love being able to type

# yum install package

and it just works. Absolutely fantastic. I’ve been a user since Fedora Core 3, and the team just pushed out version 11. Good job, guys.

But there’s one thing nagging me about the distro. I almost never notice it, but I’ve been running a lot fresh installs of Fedora lately, so it’s become pretty obvious to me. If she asks me if she looks fat in her Leonidas dress, I’m going to be honest and say yes.

Now let’s give it a fair shake here, it is, after all, a distro designed for desktop use. It’s aimed to be usable to folks who might be trying linux for the first time, and it’s stellar for that. But that comes at an expense to us power users on occasion.

About half the time or more I use it as a GUI-less server, so I’ll be the first to admit I’m probably using the wrong tool for the job, but I just can’t give it up. She makes a great server distro too…

Except for the fat.

I just did a fresh install of Fedora 11, and I challenged myself to configure it with the absolutely minimal set of packages I needed. No desktops, no windowing system, no crazy text-based packages either. I unchecked all the unnecessary WiFi drivers (all of them, I don’t have wireless on this machine) and really slimmed it down to the bare, bare essentials.

Or so I thought… it still installed a whopping 600 packages and takes up almost 2 gigs worth of space. I realize 2 gigs might seem like a small number, but I’m provisioning an old box that uses a 20 GB hard drive. I’d like to see a ~500 MB install rather than have it take up 10% of the disk for the OS alone.

As the package installs were flying by, I tried to get a glimpse of what on earth was taking up so much space. One package that caught my attention was the Leonidas wallpaper pack. Really Fedora? I didn’t even install a desktop or windowing system and you’re installing wallpapers? What am I going to use those for?

My guess is that they’re just standard packages included with every installation, but that doesn’t make much since if it offers me the ability to install without a desktop or X Windows. Perhaps some more intelligent package sorting is in order.

Thankfully I’m not the only one that’s noticed.

One of the planned features for Fedora 11 was a new Minimal Platform, which would install the bare minimum package set to get up and running, allowing you to bring up exactly what you needed with yum. When I originally read about it, I was ecstatic.

But alas, after realizing how much package culling it would require, dispute over where the option should appear in Anaconda (the graphical installer), and a general feeling that it wasn’t critical, it was pushed to Fedora 12.

Crap.

I guess I’ll stick with her… for now. Maybe I’ll hit the gym and see if she gets the hint. It’s just not good for your health Fedora, you’ve gotta drop some of that heft.

Posted in Linux | 1 Comment

Using a file as input for iptables-restore

I deal with headless linux boxes a lot, and one of the first things you always want to do is configure your firewall. The general rule of thumb says to deny all traffic and only poke holes where you need them. It’s an awful pain to configure iptables one rule at a time from the command line. It’s also a pain if you need to open one more port before that deny-all at the end of a chain, because that involves running through the whole chain again.

Now there’s probably some clever “iptables ninja” way to do it, but I prefer simplicity, so I use the iptables-save and iptables-restore commands. The first will dump your current firewall rules to standard out. The second will read rules from standard in into the firewall table.

For reference, my distro of choice is Fedora, so these commands are Red-Hat-centric.

Using iptables-save to dump your rules to a file is simple enough. Just redirect standard out to a file. Don’t forget to run it as root.

# sudo iptables-save > ./firewall.rules

Open up that file in vim (or a less worthy text editor… take that emacs!) and you’ll see it’s just a list of iptables commands. Perfect. Just drop in the new rule where you wanted it.

Reloading the firewall table from this file is a little more tricky, though. Specifically, iptables-restore takes input from standard input, but mysteriously doesn’t work when you redirect standard in from a file with the < redirector.

The solution? Call the plumber! Using the piped output from cat works just fine. Don’t forget to flush the firewall rules before you read them in again, and run both the iptables commands as root.

# sudo iptables -F
# cat ./firewall.rules | sudo iptables-restore

Now double check to make sure that the firewall configuration is really what you think it is.

# sudo iptables -L

Lastly, save the firewall configuration so that it persists after a reboot. If you skip this step, your old configuration will come back when the iptables service starts next time.

# sudo service iptables save

For good measure, I always like to restart the iptables service to verify that it will come back up using the config that I expect.

# sudo service iptables restart
# sudo iptables -L

All done! Not to painful, right? This is also a great way to backup your firewall config. If anything bad happens, you need to reinstall iptables, or you’re provisioning a duplicate server, just run the back half of this process with iptables-restore and your backed up firewall.rules file.

Posted in Linux | 1 Comment

Simulating Monopoly

Last summer I spent a good deal of time playing Monopoly. It was my final summer of marching drum corps and we were taking Amtrak out to the midwest for the last leg of our summer tour. There isn’t really much to do on a train for 3 days except eat, sleep, and sit in the observation car playing Monopoly.

One of the other corps members was absolutely destroying us. He clearly knew what he was doing when it came to fictional property management. He let me in on a little secret, though. Not all properties are created equal.

What he meant was that certain properties are statisically more likely to be landed on than others. It made sense when he explained it, but I wasn’t sure just how much of an actual difference it made. When I got home from the summer tour, I sat down and wrote some code to find out.

Thankfully in the game of Monopoly, a player’s movement around the board is very much decoupled from their financial transactions. What I mean by that is that they continue to move around the board in the same way, regardless of which properties they chose to buy, how much they have to pay to other players, or which properties they trade. The only exception is when a player goes bankrupt, and ceases to circle the board.

What this allowed me to do is write a very simple simulation in a few hours without having to worry about realistic AI. The players didn’t have to make financial transactions at all. They merely had to roll the dice and move according to the rules of Monopoly. I did need to account for the actions of the Chance and Community chest cards, but only when it impacted their position on the board or their future turns.

Certain spaces on the board can also affect the player’s position and future, so that had to be accounted for as well. For example, landing on Go to Jail will send a player directly to the jail square, and a player in jail has to go through a series of dice rolls or use a Get of Jail Free card to move again.

The game board used in a game of monopoly.

The game board used in a game of monopoly.

As I was finishing up writing the simulation, I began to suspect that the advice I had received on the train was correct. The claim was that the orange properties (St. James Place, Tennessee Avenue, and New York Avenue) were the most lucrative on the board because players were more likely to land on them. This indeed makes sense, because several Chance cards send you directly to jail and so does the Go to Jail square. Thus, the most common starting point for a dice roll is Jail. Since the most common dice roll for 2 six-sided dice will be in the 6-8 range, it only makes sense that those are the most commonly landed-on properties.

Indeed, this is exactly how it plays out. My simulation played 2000 games with 6 players and 1000 turns per game, and dumps the “landed-on” percentages out for each space along with a heat map overlayed onto the above Monopoly board. Let’s take a look at the results.

Raw results from the Monopoly simulation.

Raw results from the Monopoly simulation.

Squares landed on more often are "hotter" (tinted red) and squares landed on less often are "cooler" (tinted blue).

Squares landed on more often are "hotter" (tinted red) and squares landed on less often are "cooler" (tinted blue).

The orange property tract is certainly the most lucrative. But when you look at the raw percentages, it’s a little disappointing. The most landed-on property on the board (Community Chest #2, exactly 7 spaces away from Jail) is less than 1% more trafficked than the least landed-on property (Mediterranean Avenue).

Keep in mind though, that’s when it’s averaged out over 1000 turns, which is a massively long game of Monopoly. On top of that, those results are averaged over 2000 games. This smooths out the heat map quite a bit.

In a single game of Monopoly, the percentage swings will be much higher. The Orange properties could be red hot. They could also be colder than Mediterranean. However, given that in the long run they are hotter than the other spaces, it doesn’t hurt to try to score the orange properties. More often than not, they will see more action than any other tract on the board.

Posted in Code, Simulations | 1 Comment

Hello, world!

It’s been a long time, but I’ve finally got a blog up again. Personally I’m not a huge fan of WordPress’s default theme, but until I can figure out how to get something else rolling this is what it will be.

I’ve got lots of stuff that’s been backed up that I’ve wanted to post for months now. Hopefully over the next week or so I can get that all on here. I’m also starting an internship at Cisco next week, so we’ll see how that goes as well.

UPDATE: Found the Thematic theme, which gives me a nice minimalist base to work from. I just changed some of the link styling and it’s good enough for me.

Posted in Blogging | Leave a comment