2008-02-11 @ 21:39

Autotest and BetaBrite

I’ve finally added USB betabrite support to my Betabrite library, and released version 1.0.0.

Version 1.0.0 also includes an autotest module so that you can see your autotest output on the sign. Here is what mine looks like:

Betabrite Autotest

The sign shows errors too, but it scrolls, so I couldn’t get it in one picture. Anyway, if you’ve got the USB sign, all you have to do to get it working with autotest is add this to your .autotest file:

1
2
3
4
require 'betabrite/autotest'
require 'usb'

Autotest::BetaBrite.hook(BetaBrite::USB)

The hook method takes a block, and you can modify your messages before they are sent to the sign. For example, I wanted my failures to be blue, so my .autotest file looks like this:

1
2
3
4
5
6
require 'betabrite/autotest'
require 'usb'

Autotest::BetaBrite.hook(BetaBrite::USB) do |failures, erorrs|
  failures.rgb('0000FF') if failures.green?
end
read more »

2008-02-11 @ 21:03

betabrite version 1.0.0 has been released!

Provides a Ruby interface to BetaBrite LED signs.

Changes:

1.0.0

read more »

2008-02-15 @ 19:32

betabrite version 1.0.1 has been released!

Provides a Ruby interface to BetaBrite LED signs.

Changes:

1.0.1

read more »

2008-02-15 @ 19:16

icanhasaudio version 0.1.0 has been released!

Hai! icanhasaudio? is an interface to lame for decoding ur MP3s. I iz in ur computer. Decodin ur mp3s. Whatevs! I also decodin ur OGGz! I kin also encodin’ ur WAV and AIFF to mp3z!

SYNOPSYS ROFLOL

  require 'icanhasaudio'

  reader = Audio::MPEG::Decoder.new
  File.open(ARGV[0], 'rb') { |input_lol|
    File.open(ARGV[1], 'wb') { |output_lol|
      reader.decode(input_lol, output_lol)
    }
  }

Changes:

0.1.0

read more »

2008-02-15 @ 15:25

I'm going to Japan.

Last week I bought my plane tickets to Japan! I’m leaving June 18th, and returning July 5th. I’ll be there in time for the Japanese Ruby Conference. I submitted a talk proposal on RKelly, and hopefully that will get accepted. I know I’m going to be staying in Tokyo for a while, but I’m not sure where else I’ll travel. I’d like to go to Kyoto because it looks very interesting. I’m most excited about getting to visit Daisuke, and speaking Japanese. I’m trying hard to hone my language skillz before I go so that I can communicate!

One thing I’ve noticed about the Japanese language that differs from English and kind of annoys me is the timing of words in sentences. In English when I quote someone, the listener knows much sooner that it is a quote than in Japanese. For example:

Pam said “blah blah”.

In Japanese:

Pam は blah blah と言っていました。

You don’t know until the end of the sentence that “blah blah” is what Pam said. If you died or something before the end of that sentence, the listener wouldn’t know it was a quote! There might be ways to get around that, but I don’t know them yet……

read more »

2008-02-18 @ 22:41

king of teh intarwebs

I made a new website for icanhasaudio. You can has website view here.

Feel free to get your encoding/decoding on.

read more »

2008-02-20 @ 17:07

Faster RubyGems (GEMS 早くになりました)

Last night at Nerd Club, Eric and I hacked a patch of mine in to RubyGems. We made gems use net/http rather than open-uri for downloading gem information. I configured net/http to use a persistent connection, and now those little dots should move a lot faster in the next release of RubyGems. Eric was also able to pull open-uri out of gems. Yay!

I hope that gets released soon. Those slow dots irritate me so much!

read more »

2008-02-22 @ 23:27

TwitterBrite

I signed up my BetaBrite for a twitter account. Now I’m getting twitter messages in my living room. Yay! Leave a comment, or follow me on twitter so I can get your messages on my sign. I think next I will try to wire up a webcam to automagically take pictures.

Anyway, here is the code:

twitter = Twitter::Base.new('betabrite', '%%%%%%%%')

seen = {}
DATA.each_line { |l| seen[l.chomp] = true }
twit = nil
twitter.timeline(:friends).each do |tweet|
  next if seen[tweet.id]
  twit = tweet
end

if twit
  File.open(__FILE__, 'a') { |db| db.puts(twit.id) }
  puts "#{twit.text} (#{twit.user.name})"
  bb = BetaBrite::USB.new { |sign|
    sign.stringfile('0') do
      print string("#{twit.text}")
    end
    sign.stringfile('1') do
      print string("(#{twit.user.name})").red
    end
  }.write!
end
__END__

My favorite part is that I use the script for its own database. It keeps appending twitter ids it has seen to the end of the file.

read more »

2008-02-26 @ 10:38

Automated Youtube Uploads

I thought I would share the part of my twitterbrite scripts that uploads videos to Youtube. Its about 30 lines long, and took me an hour or so to write. Most of my time was spent figuring out form fields to fill out rather than writing code though….

I’ve broken the script down to three parts: logging in, setting the video attributes, and uploading the video file.

Step 1: Logging In

The first step is pretty simple. Just instantiate a new mechanize object, fetch youtube.com, set your login credentials, and submit!

agent = WWW::Mechanize.new { |a|
  a.user_agent_alias = 'Mac Safari'
}
page = agent.get('http://youtube.com/')

# Login
page.form('loginForm') { |f|
  f.username = 'username'
  f.password = 'password'
}.submit

Step 2: Setting video attributes

This is probably the most difficult step. Now that the agent is logged in, we have to fetch the upload page and fill out the video attributes form. You have to set the title, description, category, and keywords for your video. The you have to tell the agent to click a special button.

# Set the video attributes
page = agent.get('http://youtube.com/my_videos_upload')
form = page.form('theForm')
form.field_myvideo_title = 'My video title'
form.field_myvideo_descr = "My video description"
form.field_myvideo_categories = 28
form.field_myvideo_keywords = 'my tag'
page = form.submit(form.buttons.name('action_upload').first)

The number “28” is just the value from the category drop down list. You can iterate over the select options using mechanize, but I leave that as an exercise to the reader.

Step 3: Upload the video file

My script expects that the video file name will be supplied on the command line, so ARGV[0] should point to the file you want to upload. In this step, you simply set the video file name, then submit the form.

# Upload the video
page = page.form('theForm') { |f|
  f.file_uploads.name('field_uploadfile').first.file_name = ARGV[0]
}.submit
page.body =~ /<textarea[^>]*>(.*)<\/textarea>/m
puts $1

The last two lines grab the html needed to display the video and prints it.

There you go. Upload lots of videos now! Yay!

read more »

2008-02-26 @ 00:12

Watch Your Twits

If this doesn’t win me the super nerd of the year award, I don’t know what will. In fact, this is so nerdy that I’m kind of ashamed to write about it!

Remeber my Twitterbrite post? Well I registered twitterbrite.com, and now if my client catches a twit from you, it records the message on the LED sign and uploads it to my youtube account. Go ahead, check out twitterbrite.com now!

Update: My scripts are too chatty, so now it will only post videos if the text of the twit contains ‘betabrite’.

read more »