Ruby + SDL + OpenGL 2
I started playing around with Ruby, rubysdl and ruby-opengl tonight. I’m not really sure where the last 6 hours went…
In six hours I went from knowing almost no OpenGL, a basic understanding of Ruby, and absolutely nothing about SDL to having a full screen OpenGL app written in Ruby that shows the JPGs in the current directory in a coverlow-esque manner that you can flip through with the left and right arrow keys. I’m amazed. The whole thing is only like 200ish lines long, and I’ll attach it so if anyone finds it while looking up how to do OpenGL stuff in Ruby you can maybe benefit from my hours of digging through random documentation and websites. It’s really strange, but the only actual OpenGL/GLU documentation I could find was in PDF form…that’s nuts.
Sometime after I get some sleep I’ll try to write up some tutorials.
Edit: So, I can’t figure out how to attach things right now, I’ll get it up later.
Edit: Here’s a link to download: Source
Edit: Here’s a link to look at it online: Online Source
First project idea
I have a linux computer hooked up to my TV that serves dual purposes. First it’s a general file server/web server. Secondly it’s supposed to be a home theater PC. In the past I’ve used MythTV for a long time, but since I don’t use it for actually watching/recording TV at all I think it’s kind of bloated for me. My basic uses (or what I would want to use it for) are for watching video files and listening to music.
I’ve been looking around lately for good software to do this, something along the lines of Windows Media Center, but haven’t had any luck with anything. Most lately I’ve tried Elisa, and that project is so new that it was hard to get set up. It looks promising, but it doesn’t have good documentation yet.
So, I would ideally like to write something myself that focuses on watching videos and listening to music, runs fullscreen and is meant to be controlled with a remote. And I’d really like to write it in Ruby, but that’s turning out to be pretty difficult: I can’t find any good GUI libraries for Ruby, at least ones that are actively maintained. QtRuby/Korundum seems like it hasn’t been updated in years, and even Ruby-Gnome2 seems like it’s not maintained anymore (that and the Ruby/Gstreamer bindings aren’t even available in their regular distribution).
So I guess I’ll keep looking, or maybe even fall back to C++/Qt/KDE which I haven’t even looked at in like 4 years…and now with KDE4 out I think that learning curve is going to be kind of steep.
Getting additional mouse buttons to be useful in linux
Quick follow up to the previous post. I have a Microsoft Laser Mouse 6000, which happens to have two side buttons, which in Windows correspond to the Back and Forward actions in things like web browsers and Explorer. In linux, these buttons don’t do anything by default, but I finally got them working.
All I had to do was install xbindkeys, which for OpenSuSE 10.3 can be found via the OpenSuSE Build Service. After that is installed, you create the file $HOME/.xbindkeysrc and put something like the following into it:
"xvkbd -text "\[Alt]\[Left]""
m:0x0 + b:8
"xvkbd -text "\[Alt]\[Right]""
m:0x0 + b:9
The b:8 and b:9 parts are the mouse buttons you want to listen for, which can be found by using xev.
After that file is set up, you just need to make sure that xbindkeys is started when you start X, which can be done in a script in $HOME/.kde/Autostart, maybe just added to the script I mentioned in the previous post about how to get multimedia keys working in linux. For the time being, you can just run xbindkeys from a commandline in your current session.
Once all this is done, xbindkeys will listen for the mouse buttons you set up and send the specified keyboard commands, in this case Alt+Left and Alt+Right, which should get you Back and Forward actions in your browsers.
Configuring the Logitech diNovo Edge in Linux 9
I love my Logitech diNovo Edge keyboard, and I only recently got some of it’s special keys mapped and working in Linux. Doing this required using xev to gather the keycodes for the various special keys and functions on they keyboard and then setting up an Xmodmap file mapping these keycodes to various XF86 actions.
The keys that I couldn’t get codes for are:
- “Phone” Key (Fn + F1)
- Magnifying glass keys (along the left edge)
- A B C D keys (Fn + F9-F12)
Otherwise, here’s the contents of my $HOME/.Xmodmap file:
keycode 160 = XF86AudioMute
keycode 176 = XF86AudioRaiseVolume
keycode 174 = XF86AudioLowerVolume
keycode 122 = XF86Search
keycode 144 = XF86AudioPrev
keycode 164 = XF86AudioStop
keycode 162 = XF86AudioPlay
keycode 153 = XF86AudioNext
keycode 236 = XF86Mail
keycode 130 = XF86HomePage
keycode 129 = XF86MenuPB
keycode 115 = XF86MenuKB
Then, if you’re using KDE, you can the KDE Control Center -> Regional & Accessibility menu’s Keyboard Shortcuts or the Input Actions sections to map these new keys to events.
One important part is to make sure your .Xmodmap file is loaded when you log in, you can do this via a bash script in $HOME/.kde/Autostart that looks something like this:
#!/bin/bash
xmodmap ~/.Xmodmap
Also, I followed some instructions found here for general XModmap usage and help: Multimediakeys with .Xmodmap HOWTO
I need to write software
I used to be really involved in open source software, it was easier back in college when I had more time to focus on that kind of stuff. Not that I don’t have much free time now, I just find myself spending it in other ways that really aren’t productive at all. It’s not even that I’m burned out on programming from my day job, it’s just that when you’re not getting paid to write the software it has to have some intrinsic value to motivate you to work on it.
Every once in a while I get what I think is a great idea and do about two days or work on it. Then one of a couple things starts happening:
- I find out that someone, somewhere, has already written my idea and that, even if it’s not better than my idea, they’re way ahead of me in terms of development
- I quickly realize that my goals were big and after a few days of free time working on it I’m not really seeing anything useful shaping up
For the first item, I’m not really sure what to do to combat that, except to realize that it’s very rare to come up with an idea that someone else hasn’t already come up with. I think that maybe unique overall ideas may be hard to come up with, but that it’s easier to come up with small changes to an idea that lots of people have done already.
For number two the solution is really simple: start out with implementing smaller projects. I think I need to sit down and brainstorm for a little while and just come up with a long list of really small projects, ones that I know won’t take more than 1-2 days of a couple of hours at a time to implement. Anything much longer than that and I face the chance of burning myself out.
So, to summarize: I need to come up with small, quickly implementable projects and then just ignore stories on Lifehacker about the “great new project X” that does exactly what I thought of (those stories always seem to come out a day after I start implementing something…)
Server monitoring with Munin and Monit
I was looking for a good way to find out about my server stats, which are kind of low with slicehost’s most basic offering, and finally came across two pieces of software, Munin and Monit.
Munin generates tons of graphs of system statistics from CPU and Memory usage to load averages, open files and lots more and generates web content that lets you quickly see the health/performance of your system.
Monit is for more automated monitoring and runs as a daemon on your server. You can configure it to watch lots of different things including CPU and Memory usage and whether or not various services are running. It then alerts you when your specified conditions are tripped, such as if memory usage goes over a certain percentage, or if CPU utilization stays high for a given amount of time. It can also watch processes and if they die it will restart them.
The best guide (it also has helpful links to more details) I could find is called Server Monitoring With munin And monit found on a site I’m going to have to check out more, HowToForge.
Finally up
Wow, finally got a Rails app up and running with minimal pain. It’s amazing how much of a difference dedicated hosting can make on things. Previously I was using shared hosting and having no luck with getting rails apps running reliably. Switched to Slicehost and I’m pretty impressed.