2 files: finding lines that are in only 1 of those files

Today, I learned a trick at work.

I had a list of phone numbers in a file, and wanted to obtain a second list of phone numbers: the ones that were in a table in our database, but not in the given file.

Of course, you can solve this in SQL, for example with a “NOT IN” clause. However, with tens of thousands of phone numbers involved, this would probably be rather slow. Besides, I’m not very good at SQL, and I don’t like reading the PostgreSQL documentation.

A colleague mentioned a trick with cat, sort and uniq. If you do cat filename | sort | uniq -u, only lines that appear once in filename will be printed. So, if you have 2 files, file1 and file2, neither of them having duplicate lines, and you want to know which lines are in file2 but not in file1, you do this:

cat file1 file1 file2 | sort | uniq -u

Lines that appear only in file1 are filtered out by uniq’s -u option, as are lines that appear both in file1 and file2. So you end up with the lines that appear only in file2.

I made file containing a list of all phone numbers in our database, and used the above trick to get the phone numbers that were in that file, but not in the file with the limited list of phone numbers. Fast, and easy.

Posted in linux, unix | 1 Comment

A journey into poker

A couple of weeks ago, a friend of mine said to me: “Hey Joost, I think you would be really good at playing poker online!” At that time, the only exposure to poker I had were a couple of home games with my family, where my brother would usually win. I quickly discarded the idea, thinking that the game is based on luck too much.

A bidding box as used in most bridge games

A bidding box as used in most bridge games

You see, I played bridge when I was younger. High-level tournament bridge, with bidding boxes and table screens, is a game (sport? but that’s a different discussion) where luck has been reduced to a minimum. Each team plays the same hands as their opposing team, from both “sides”, so it’s very easy to see who played better. So, the luck factor is very low, probably below 10%. You still have some luck, like which hands you play against which opponents – since your system might be able to cope with certain hands better than with others – but that’s about it. So, when I thought about poker, I had this vision of a game where luck plays a very large role (at least 50%), and dismissed that.

A week later or so, I ran into an episode of the American TV show High Stakes Poker. I watched it, and quickly realised that there is much more to poker than I originally thought. In typical Joost-manner, I decided to dive into poker and find out as much as possible about playing online poker to earn money.

I found many episodes of poker related series, including the World Series of Poker. I read Phil Hellmuth‘s Play Poker like the Pros: a very good read for the beginner. I read Small Stakes No-Limit Hold’em, which purely focuses on winning money online. I contacted friends of friends, who have experience with this kind of thing, and asked lots of questions.

Then, I decided to start playing a bit. I made an account on PokerStars and played a couple of $1 Double or Nothing tournaments. These are 10-player tournaments, where every player pays $1 to participate, and the top 5 players earn $2 each. Then, I learned what rakeback is, and a friend helped me get a rakeback-enabled account on Full Tilt Poker.

Additionally, a friend mentioned a very interesting piece of software: Poker Tracker. You run this application while you also run your online poker software, and then Poker Tracker keeps track of everything that happens on the table and stores that in a database. Poker Tracker can then show you, roughly, what the playing style of each player is, making it much easier for you to make the right decisions.

Playing online at Full Tilt Poker

Lots of preparation, as you can see. I also played several hours on “fake money” tables, but that was just… stupid. Since you can reload your fake money when you run out of it, those tables are filled with people who bet their entire stack on basically every hand. That’s completely not representative of poker for money.

So, playing for real money then. Fortunately it’s possible to play for very little amounts of money: $0.01 / $0.02 blinds, with a maximum stack of $2. Last Monday, I decided to find out how it is to play on a 6-person table for an hour or 2.

I logged in, and looked for a table with 5 people seated. I took a seat, and took it easy for about 12 hands, so Poker Tracker could get some decent stats on the other players. I noticed that all other players at my table were playing at least 4 tables at the same time. That usually means that they only played good hands, which in turn means two things: you can easily bluff them out of hands, and if they stay in the hand, they really have a good hand, so you can easily fold.

This is an ideal scenario to steal the blinds. So, that’s what I did. I bluffed. I stole blinds from the button. I stole blinds from the cutoff. I failed to get out of some big hands. In the end, this is what my stack did during the session:

As you can see, my money goes up really slowly, and it takes me about 50 hands to win $1 (50 big blinds). Relatively speaking, that’s very large (with $1/$2 blinds, that would translate into about $150/hour), but I doubt that the play at the $1/$2 tables is similar to this. That’s one thing I need to figure out.

At hand 82, I lose a big pot, and about 1.5 hours of work. In a single hand. That’s rather suboptimal. My stack slowly climbs back to its starting position, but in the end, I lose another big hand.

So, what have I learned from this?

First of all, playing like this was extremely boring. Most of the hands were decided pre-flop, with one player raising, and all the other players folding. Hands that did get to the flop were usually decided on the flop or the turn, with 1 player betting once or twice, and the other player folding. Of the 145 hands I played, only 20 were decided by showdown. I don’t know if it’s the same if you play for higher stakes.

Second, I need to learn much more about post-flop play, and how to play the big hands.

At this point, I’m not sure if I should continue this experiment. Playing on a micro-limit cash table really felt like a rather boring job. I’ll give it some time, and see how I feel about it next week.

Posted in A Journey Into Poker | Tagged , , , , | 2 Comments

A blog? Why?

There. It’s finally happening – I’m starting a blog.

Several times in the past years, I’ve pondered whether I should start a blog, and if so, why. Some years ago, I started a journal, but after writing in it for a couple of months, I realised that the things I wanted to write were more personal than I wanted to share with the audience – the entire world. So I stopped that experiment.

In the past year and a half, much has changed in my life – mainly in my head. Yesterday, I realised two things:

  1. Many times when I was looking for some answer, for example how do to X in django, or how to fix problem Y in Ubuntu, I would end up on a blog. Someone else had encountered the same situation, and had written about it – usually including a way to solve the problem.
  2. I have experienced things in my life that are interesting to read about. Maybe someone else will, one day, google for a certain problem or situation, end up on my blog, and find something useful there.

The question “but why would you write something, of which you have no idea if anyone will ever read it?” remains, and I’m not sure about that. Hopefully, some people will read it, post feedback, and trigger an urge to continue writing here.

>So, that’s how this blog got started. I asked some friends on my home IRC channel #carnique which blog software they would use in my situation, and they mentioned WordPress. Apparently version 3.x is significantly better than 2.9.x, so instead of apt-get installing wordpress, I ended up downloading the tarball and following the 5 minute install page. It was indeed very easy and fast to install WordPress.

Now to configure it to my liking, and tame apache’s redirects so I can use decent URIs for permalinks instead of the default blah.php?id=1273 format.

And then the writing can start!

Posted in Uncategorized | 4 Comments