vi bindings for irb on OS X
Eric Hodel | Tue, 11 Aug 2009 20:56:22 GMT
OS X uses editline(3) instead of readline(3) so ~/.inputrc doesn’t do anything for irb or other tools using readline via the editline wrapper.
Instead, use ~/.editrc:
bind -v
bind \\t rl_complete
Which gives you vi bindings in irb.
Update
Now with tab completion thanks to Curt Sampson from an ancient netbsd-users email!
imap_processor 1.3
Eric Hodel | Wed, 05 Aug 2009 02:38:30 GMT
IMAPProcessor is a client for processing messages on an IMAP server. It provides some basic mechanisms for connecting to an IMAP server, determining capabilities and handling messages.
IMAPProcessor ships with the executables imap_keywords which can query an IMAP server for keywords set on messages in mailboxes, imap_idle which can show new messages in a mailbox and imap_archive which will archive old messages to a new mailbox.
Changes
- IMAP IDLE support now matches ruby trunk’s support. See Net::IMAP#idle and Net::IMAP#idle_done
A gemspec is not a big truck
Eric Hodel | Fri, 31 Jul 2009 22:48:56 GMT
It’s not something that you just dump something on. (paraphrasing)
There’s some terrible code that generates a ruby version of a Gem::Specification object.
This code is that it’s a broken implementation of Gem::Specification#to_ruby, a method that was documented all the way back to RubyGems 0.8.11.
Using this code generates a broken Gem::Specification object which will corrupt RubyGems indexes.
There are some projects in the wild that use this code, so if you own one of those, you should remove this code right away!
Remember! A gemspec is not a big truck!
Bandwidth Limiting with pf and ALTQ
Eric Hodel | Tue, 28 Jul 2009 05:34:00 GMT
Every now and then my neighbors end up chewing up too much of my bandwidth. In order to give my computers a more-reliable connection and keep the number of access points in my neighborhood low, I started limiting their traffic using ALTQ in the pf packet filter.
My router runs FreeBSD with a connection to the internet on one side and an Airport Extreme on the other end. My router handles all the network configuration (DHCP, DNS, firewall) and the Extreme is just a bridge. I've classified my hosts on the wifi network into hosts I know about that get assigned fixed addresses via DHCP and everybody else that gets assigned an address out of a DHCP pool.
ALTQ allows you to create a hierarchy of queues each with a particular amount of bandwidth. If a queue fills up width bandwidth you can either throw out the extra packets or borrow from one of the other queues. You can get some ideas of how to set up a hierarchy of queues from the examples on the ALTQ page.
For my network I chose to start with two queues one for my hosts and one for everybody else:
altq on $wifi_if cbq bandwidth 100Mb queue { mine, other }
queue mine bandwidth 98Mb priority 1 cbq(borrow)
queue other bandwidth 2Mb priority 7 cbq(default ecn)
This is much simpler than the ALTQ examples which allow prioritization of ACK packets and interactive sessions like SSH or IM connections, but I really don't care about the service of everybody else.
Since the queues are hierarchical, you end up with a 100Mb queue for all traffic on my wifi interface split into a 98Mb queue for myself and a 2Mb queue for everybody else. My queue gets top priority and can borrow bandwidth from everybody else. The other queue picks up the rest of the traffic and uses Explicit Congestion Notification as it fills up (which includes dropping packets).
Now we have to assign packets to the queues:
my_hosts = "192.0.2.1/27"
pass out quick on $wifi_if from any to $my_hosts queue mine
pass out on $wifi_if from any to any queue other
After reloading pf and letting traffic go by for a while you can see the queue in action:
$ sudo pfctl -v -s queue
queue root_vr2 bandwidth 100Mb priority 0 cbq( wrr root ) {mine, other}
[ pkts: 134533 bytes: 151561160 dropped pkts: 0 bytes: 0 ]
[ qlength: 0/ 50 borrows: 0 suspends: 0 ]
queue mine bandwidth 98Mb cbq( borrow )
[ pkts: 40780 bytes: 56881335 dropped pkts: 0 bytes: 0 ]
[ qlength: 0/ 50 borrows: 0 suspends: 0 ]
queue other bandwidth 2Mb priority 7 cbq( red ecn default )
[ pkts: 93753 bytes: 94679825 dropped pkts: 1022 bytes: 1237280 ]
[ qlength: 0/ 50 borrows: 0 suspends: 6933 ]
You can get more information from the ALTQ page and from the QUEUING/ALTQ section of the pf.conf man page.
RubyGems 1.3.5
Eric Hodel | Wed, 22 Jul 2009 00:37:47 GMT
RubyGems is a package management framework for Ruby.
See Gem for information on RubyGems (or `ri Gem`)
To upgrade to the latest RubyGems, run:
$ gem update --system # you might need to be an administrator or root
NOTE: RubyGems 1.1 and 1.2 have problems upgrading when there is no rubygems-update installed. You will need to use the following instructions if you see “Nothing to update”.
If you have an older version of RubyGems installed, then you can still do it in two steps:
$ gem install rubygems-update # again, might need to be admin/root $ update_rubygems # ... here too
If you don’t have any RubyGems install, there is still the pre-gem approach to getting software, doing it manually:
- Download from: <a href=”http://rubyforge.org/frs/?group_id=126”>rubyforge.org/frs/?group_id=126
- Unpack into a directory and cd there
- Install with: ruby setup.rb # you may need admin/root privilege
For more details and other options, see:
ruby setup.rb --help
Changes
Bug fixes:
- Fix use of prerelease gems.
- Gem.bin_path no longer escapes path with spaces. Bug #25935 and #26458.
Deprecation Notices:
- Bulk index update is no longer supported (the code currently remains, but not the tests)
- Gem::manage_gems was removed in 1.3.3.
- Time::today was removed in 1.3.3.
rc-rest 3.0.0
Eric Hodel | Fri, 10 Jul 2009 21:31:00 GMT
Robot Co-op REST web services base class. This library makes it easy to implement REST-like web services APIs.
Changes
- Upgrade to Nokogiri from REXML. This is incompatible with 2.x and older. Thanks Aaron Patterson!
smtp_tls 1.0.3
Eric Hodel | Wed, 08 Jul 2009 23:18:00 GMT
Provides SMTP STARTTLS support for Ruby 1.8.6 (built-in for 1.8.7+). Simply require ‘smtp_tls’ and use the Net::SMTP#enable_starttls method to talk to servers that use STARTTLS.
require 'net/smtp'
begin
require 'smtp_tls'
rescue LoadError
end
smtp = Net::SMTP.new address, port
smtp.enable_starttls
smtp.start Socket.gethostname, user, password, authentication do |server|
server.send_message message, from, to
end
You can also test your SMTP connection settings using mail_smtp_tls:
$ date | mail_smtp_tls smtp.example.com submission \
"your username" "your password" plain \
from@example.com to@example.com
Using SMTP_TLS 1.0.3
-> "220 smtp.example.com ESMTP XXX\r\n"
<- "EHLO you.example.com\r\n"
-> "250-smtp.example.com at your service, [192.0.2.1]\r\n"
-> "250-SIZE 35651584\r\n"
-> "250-8BITMIME\r\n"
-> "250-STARTTLS\r\n"
-> "250-ENHANCEDSTATUSCODES\r\n"
-> "250 PIPELINING\r\n"
<- "STARTTLS\r\n"
-> "220 2.0.0 Ready to start TLS\r\n"
TLS connection started
<- "EHLO you.example.com\r\n"
-> "250-smtp.example.com at your service, [192.0.2.1]\r\n"
-> "250-SIZE 35651584\r\n"
-> "250-8BITMIME\r\n"
-> "250-AUTH LOGIN PLAIN\r\n"
-> "250-ENHANCEDSTATUSCODES\r\n"
-> "250 PIPELINING\r\n"
<- "AUTH PLAIN BASE64_STUFF_HERE\r\n"
-> "235 2.7.0 Accepted\r\n"
<- "MAIL FROM:<from@example.com>\r\n"
-> "250 2.1.0 OK XXX\r\n"
<- "RCPT TO:<to@example.com>\r\n"
-> "250 2.1.5 OK XXX\r\n"
<- "DATA\r\n"
-> "354 Go ahead XXX\r\n"
writing message from String
wrote 91 bytes
-> "250 2.0.0 OK 1247028988 XXX\r\n"
<- "QUIT\r\n"
-> "221 2.0.0 closing connection XXX\r\n"
This will connect to smtp.example.com using the submission port (port 587) with a username and password of “your username” and “your password” and authenticate using plain-text auth (the submission port always uses SSL) then send the current date to to@example.com from from@example.com.
Debug output from the connection will be printed on stderr.
Changes:
- 1 minor enhancement
- Added mail_smtp_tls executable to test SMTP connections
- 2 bug fixes
- Suppress default DH parameters warning
- Pass debug output down to child IOs
imap_processor 1.2
Eric Hodel | Wed, 08 Jul 2009 01:17:00 GMT
imap_processor version 1.2 has been released!
IMAPProcessor is a client for processing messages on an IMAP server. It provides some basic mechanisms for connecting to an IMAP server, determining capabilities and handling messages.
IMAPProcessor ships with the executables imap_keywords which can query an IMAP server for keywords set on messages in mailboxes, imap_idle which can show new messages in a mailbox and imap_archive which will archive old messages to a new mailbox.
Changes:
- 2 major enhancements
- imap_archive which archives old mail to dated mailboxes
- imap_idle which lists messages that were added or expunged from a mailbox
- 4 minor enhancements
- Added IMAPProcessor#create_mailbox
- Added IMAPProcessor#delete_messages
- Added IMAPProcessor#move_messages
- Disabled verification of SSL certs for 1.9
- 1 bug fix
- Fixed options file names, they should be Symbol keys
ar_mailer 1.4.0
Eric Hodel | Wed, 24 Jun 2009 22:53:06 GMT
ar_mailer is a two-phase delivery agent for ActionMailer. Even delivering email to the local machine may take too long when you have to send hundreds of messages. ar_mailer allows you to store messages into the database for later delivery by a separate process, ar_sendmail.
Changes:
- 1.8.7 and 1.9 STARTTLS compatibility, now uses smtp_tls gem for STARTTLS on 1.8.6
- Fix 1.9 warnings
production_log_analyzer 1.5.1
Eric Hodel | Wed, 24 Jun 2009 03:44:37 GMT
production_log_analyzer version 1.5.1 has been released!
- <a href=”http://seattlerb.rubyforge.org/production_log_analyzer”>Documentation
- <a href=”http://rubyforge.org/projects/seattlerb”>Project page
- <a href=”http://rubyforge.org/tracker/?func=add&group_id=1513&atid=5921”>Bug reports
production_log_analyzer lets you find out which actions on a Rails site are slowing you down.
Changes:
- 1.9 and 1.8.7 compatibility.

Articles