Whenever you are doing any kind of file shenanigans, you should always explicitly set the expected encoding of the file you are reading from. Most programming languages’ standard file handling libraries use encoding settings by default which do not lead to the desired behaviour.
A little while ago, I released an extension that adds a nifty feature to Twitch (Twitch is the video streaming platform for games that was acquired by Amazon last year for $970 million): ReChat for Twitch.
Twitch does not only allow users to see live video streams but also records them so that users can watch them later. The one thing you miss out on when you watch a recorded stream is the chat. This is where ReChat comes into play: ReChat allows you to see the recorded chat messages as if it was a live stream.
Did you ever ask yourself, how you should “design” your exceptions? Ever wondered if you understood the idea behind exceptions? Do you know, what you should use exceptions for? This article aims to clarify how and when (not) to use exceptions.
Back in 2012 we were looking for a solution to replace our company-wide SSO with something more robust and future proof. After comparing various SSO technologies and standards, we decided to go with a CAS-based solution. CAS is an open standard and there are libraries for a wide range of client platforms (e.g. Ruby, Java, PHP, .NET, Apache).
We didn’t have any knowledge in running a big Java web application, so we decided to use the RubyCAS-Server. Running and maintaining Ruby web applications was (and still is) our daily business.
After some weeks and months of usage, we encountered several bugs and shortcomings in RubyCAS-Server. What’s worse: RubyCAS-Server does not fully adhere the CAS standard. “No problem, it’s open source!”, you’re probably saying. That’s what we thought too… After looking through the source code, we almost cried: it’s a mess and not well tested. But we didn’t give up here and began to hack our changes in. We then opened issues and pull requests but did not get any feedback. Very frustrating! The project seemed dead to us.
It took us just a few weeks to implement basic CAS support. We had a clean code base, a responsive user interface and 100% compatibility with the CAS standard.
If you are (like me) developing Ruby on Rails applications under Mac OS X, you are probably already familiar with Pow. Pow is doubtless the easiest way to run multiple Rack applications on your development machine.
The only thing not that intuitive to me was the whole linking progress as it was easy to lose track of what you already “deployed” to your local Pow installation.
Not anymore, Anvil to the rescue!
It adds a little menubar icon that gives you access to your Pow apps, allows adding new ones and lets you easily execute various Pow commands (start, stop, …). Finally a nice GUI for Pow! :)
In a project I’m working on in my spare time, I wanted to hide / obfuscate the databases IDs of my ActiveRecord model. I didn’t want the users to find records by simply incrementing a number in the URL.
I ended up writing my own Gem, which manipulates ActiveRecord::Base to hide the actual ID. Rails’s path functions still work as expected. The only thing I had to add to the actual project was the following line:
1 2 3
The second bot doesn’t know any strategies to win tic-tac-toe. This bot will simply try things out and give each move a score once the game ended. If the bot wins, all moves that lead to this situation will get score+1, if he loses, all moves will get score-1. The default score is 0.
So when it is this bots turn, it will decide based on the scores:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
We then have to save the performed moves, so that we later can set the score accordingly:
1 2 3 4 5 6 7 8 9 10 11 12
That’s it! So the learning AI is even simpler than the Minimax bot.
A nice Java 7 feature is the new try-with-resources statement.
When you did some SQL things back in the Java 6 days, you often ended up with something like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
Now with Java 7, this got a lot easier and shorter:
1 2 3 4 5 6 7 8 9
If you want to write a class that supports this syntax, you may take a look a the AutoClosable interface.