I mainly develop in Ruby, but I use other languages from time to time, especially for fun side projects. I've been trying out RubyMine, as I have a free license for it, and I like it well enough. When I started a Java project recently, I downloaded RubyMine's big brother, IntelliJ.
This thing is stupid nice. I will lose all my cool points as a Rubyist using a giant Java IDE to write Ruby, HTML, CSS, and JavaScript, but I don't care. I am in love.
I am not in love with the $250 I am going to have to pay for IntelliJ in about 10 more days. Still trying to figure out how to swing that. Donations accepted.
The most important thing I learned today wasn't about programming: it was about bottled water. Kind of terrifying from a waste level and a health level.
I needed to introspect on a Ruby method and find out the names of its arguments for a project I'm working on, and realized Ruby's own introspection wouldn't let me get this info. After some Googling, I found that Merb has this functionality. I didn't want to include all of Merb in my project, so I've extracted it.
I love emacsclient for opening files in Emacs from the command line, but closing those windows drives me nuts. I expect it just to work like killing any other buffer. With the help of some Googling, I put together this code today to close client buffers by using C-x k.
I've been away from this too long, so I've picked a project to give me something to learn each day. I'm building a web-based Roguelike game. I've never built a computer game before, and I've got a lot to learn about sprites, collision detection, map generation, and other stuff.
I am not sure what has gotten into me, but I decided to set up monit on my MacBook Pro. Monit's used for monitoring Unix systems, especially servers and the processes on those servers. I read a presentation on Monit (PDF) that showed me how to monitor files for changes and then execute commands based off that, like reloading Apache whenever you edit your Apache configuration file. And then I thought, "Why don't I do this on my laptop?"
There's only a few steps. The first is getting monit installed. It's not hard, and the tarball; ./configure; make; make install biz should work for you. If you like Homebrew like I like Homebrew, you can grab a recipe from this here commit.
Next, configure monit. I put my monit configuration file in /usr/local/etc/monitrc. I'll show it at the bottom of this post.
My major issue was with mail delivery. If you have a SMTP server you want to use, you're set. If you want to use your OS X box as a mail server, you've got to reconfigure Postfix. By default, it only runs when files are put in /var/spool/postfix/maildrop. Here's my configuration from /System/Library/LaunchDaemons/org.postfix.master.plist:
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"><plistversion="1.0"><dict><key>AbandonProcessGroup</key><true/><key>KeepAlive</key><true/><key>Label</key><string>org.postfix.master</string><key>OnDemand</key><false/><key>Program</key><string>/usr/libexec/postfix/master</string><key>ProgramArguments</key><array><string>master</string></array><key>QueueDirectories</key><array/><key>RunAtLoad</key><true/></dict></plist>
Once I got mail delivery going (you might need to edit /etc/aliases and then run sudo postalias /etc/aliases; sudo postfix reload) and mutt installed to check my mail, which I leave as an exercise to the reader, I was set. I dropped the following configuration in /usr/local/etc/monitrc:
set daemon 120
set logfile syslog facility log_daemon
set alert cnixon@localhost
set mail-format { from: monit@moro.local }
set mailserver localhost
set httpd port 2812 and use address localhost
allow localhost # Allow localhost to connect
check directory vhosts path /etc/apache2/passenger_pane_vhosts
if changed timestamp
then exec "/usr/sbin/apachectl graceful"
check directory apache_conf path /etc/apache2/other
if changed timestamp
then exec "/usr/sbin/apachectl graceful"
check file monitrc path /usr/local/etc/monitrc
if changed timestamp
then exec "/usr/local/bin/monit reload"
check device MacintoshHD with path /
if space usage > 90%
then exec "/usr/local/bin/growlnotify -m \
'Your harddrive is getting full' 'MONIT SAY'"
Check out the PDF presentation above, or the Monit documentation if a line doesn't make sense. The summary:
When I add or remove any files from /etc/apache2/passenger_pane_vhosts or /etc/apache2/other, Apache gets reloaded. I'd like it to do this whenever a file is changed in either one, but monit doesn't easily support file globs. Maybe I should write a script to write my monit conf.
When I change monitrc, monit reloads it.
If my hard drive starts to get full, Growl tells me about it.
I continued adding stuff to my thor bandolier today, including some sweet meta-tasks to help deal with thor. Check them out at my git repo for my thor tasks. One thing to especially look at is provision.thor. I had no idea until today that you can make a .thor directory with a main.thor file inside to drive it.
My zsh completion for thor quest continues. It is still breaking me - three hours already, and not satisfied - but I'm making progress. Here's the latest:
#compdef thor# List of commands built into thor.
_thor_commands(){
_values "Thor""list""install""uninstall""help""installed""update"}# Get list of all thor tasks added.
_thor_tasks(){
compadd `thor list | grep -vP '^[\#\-]|^\s*$' |
sed -e '1d' -e 's/[^a-zA-Z0-9_\-\:].*$//' | grep -v '^\n$'`}# Normally, show all of the above.if((CURRENT== 2 )); then_thor_commands
_thor_tasks
else# If we've typed 'thor install', let us look for a normal file.if[[$words[2]== install ]] ; then_files
# If we've typed 'thor help', just show us the built in thor commands.elif[[$words[2]==help]] ; then_thor_commands
fifi
I spent some time this afternoon thinking about automation with Ruby. Even though I used to use it a lot, I've fallen off on using Thor, mainly because of API changes in Thor, and my move to zsh. I ported my bash completion script for thor to zsh, and it was way easier than bash:
_thor(){
compadd `thor list | grep -vP '^[\#\-]|^\s*$' |
sed -e '1d' -e 's/[^a-zA-Z0-9_\-\:].*$//'`}
compdef _thor thor