Fugly @ BLogging – paper or plastic?

October 8, 2008

HTTP Push (AKA Comet) with Orbited and Rails

Filed under: comet, http, orbited, push, rails — MrBrandon @ 11:06 pm

If you’ve messed around with HTTP push/Comet solutions you’ve probably discovered are a fair amount of free and commercial choices, most solutions a lot to be desired.

For Ruby and Rails specific solutions I tried juggernaut and shooting_star. The client component in both projects frequently didn’t know when they were disconnected from the server and consequently never tried to reestablish the connection. Meh…..

After a few weeks of frustration I discovered Orbited, a really good push server. It’s built with Python, but that matters little. It’s an agnostic daemon that integrates with whatever you like. Orbited ships with support for many protocols out of the box, including IRC, XMPP, and STOMP.

My needs were simple for the time being, so I went with STOMP. So if you want replicate my setup you’ll need to have Orbited + dependencies, a STOMP server and the stomp gem.

Before you dive in, this example is not a guide to proper architecture. It’s purpose is to show you how all the moving parts fit together.

I’m on Ubuntu 8.04, so lets rock n’ roll!!!!!

Orbited + dependencies

sudo apt-get install python2.5-dev
sudo apt-get install python2.5-twisted

Now follow these instructions:


On the last step I went with simplejson

STOMP Server

ll morbid

You can use any STOMP server you like though

Orbited Config

# Example Orbited Configuration file

# reactor=kqueue
# reactor=epoll
proxy.enabled = 1
proxy.keepalive = 0
session.ping_interval = 40
session.ping_timeout = 30

# uncomment to enable ssl on port 8043 using given .key and .crt files


* -> localhost:61613
* -> your.public.ip.or.domain.com:61613
#localhost:8000 -> irc.freenode.net:6667


#Don't enable debug by default

# Turn debug on for the "Proxy" logger

Star ‘Em up!

sudo orbited –config=/path/to/your/orbited.cfg

sudo morbid

NOTE – you’ll have to find your own way to run these in the background in production. I use screen. There are better options and I plan to change that soon.

The Gem

sudo gem install stomp

Ok..that should be all the requirements…..I make no promises. This is all from memory

Rails Integration

This is quick and dirty. Take care in your integration.

In a controller….

require 'stomp'
class ChatController < ApplicationController
  def send_data 
    unless params[:chat_input].empty? 
      javascript = render_to_string :update do |page|
        page.insert_html :top, 'chat_data', "MESSAGE: #{h     params[:chat_input]}"
        s = Stomp::Client.new
    render :nothing => true

Global Rails App Settings (However you prefer to handle them)

APP_SETTINGS[:orbited_host] = ‘localhost’
APP_SETTINGS[:orbited_port] = ‘8500’
APP_SETTINGS[:site_address] = ‘localhost:3000’

In your app_helper.rb

def orbited_javascript
  "<script src=\"http://#{APP_SETTINGS[:orbited_host]}:#{APP_SETTINGS[:orbited_port]}/static/Orbited.js\"></script>",
  '  document.domain = document.domain;',
  "  Orbited.settings.port = #{APP_SETTINGS[:orbited_port]};",
  "  Orbited.settings.hostname = '#{APP_SETTINGS[:orbited_host]}';",
  '  TCPSocket = Orbited.TCPSocket;',
  "<script src=\"http://#{APP_SETTINGS[:orbited_host]}:#{APP_SETTINGS[:orbited_port]}/static/protocols/stomp/stomp.js\"></script>"

In a view…

 <%= javascript_include_tag :defaults %>
 <%= orbited_javascript %>
 onload = function() {
 // set up shell.
 var output = $('chat_data');
 // set up stomp client.
 stomp = new STOMPClient();
 stomp.onopen = function() {
 //output.insert({"top" : "Transport openned"});
 stomp.onclose = function(code) {
 output.insert({"top" : "Transport closed (code: " + code + ")"});
 stomp.onerror = function(error) {
 alert("onerror: " + error);
 stomp.onerrorframe = function(frame) {
 alert("onerrorframe: " + frame.body);
 stomp.onconnectedframe = function() {
 output.insert({"top" : "Connected to chat room"});
 stomp.onmessageframe = function(frame) {
 //output.insert({"top" : frame.body});
 stomp.connect(document.domain, 61613, 'UNIQUE_ID_PER_CLIENT', '');
 setTimeout("stomp.subscribe('CHANNEL_1', {exchange:''})",5000);
 <%= form_remote_tag(
 :url => { :controller => 'chat', :action => :send_data } ) %>
 <%= hidden_field_tag('channel','CHANNEL_1')%>
 <%= text_field_tag( 'chat_input', '', { :size => 70, :id => 'chat_input'} ) %>
 <%= submit_tag("Say")  %>
 <%= ('<a href="/login">Login</a> to chat.')%>
 <div id="chat_data" style="height:300px;border:1px solid black;overflow:scroll;"></div>

Congrats and Good Luck!

Remember, this is quick and dirty, cut and pasted from my own app. There may be a few syntax errors, but this should get you on the right path.


July 30, 2008

SPAM…mmm mm good.

Filed under: Uncategorized — MrBrandon @ 8:44 pm

You wouldn’t believe it. I got the most awesome opportunity today….and to think I was going to take the offer from that prince in Africa instead.

Rose Household textiles ltd needs a book-keeper in the united states,
Our company produces various clothing materials,batiks,assorted fabrics
and traditional costumes.We have clients we supply weekly in the
states and my clients make payments for our supplies every week in form of
money orders or cashiers check which are not readily cash able outside
the US or Canada,so we need someone in the States/Canada to work as our
representative and assist us in processing the payments from our
clients and I will pay him/her a weekly wage, by percentage.
All you need to do is receive this payment from our clients in the
States or Canada and get it cashed in your bank or a cashing center
then deduct your 10% and forward the balance to the company down here via
money gram or western union money transfer.
Candidates for the job should possess proficient organizational skills
as well as the ability to efficiently multi-task.
Other responsibilities include, but are not limited to:
Incorporating effective priorities for the virtual office function
Receiving and managing payments to help administer
day-to-day financial responsibilities for clients
Communicating online daily
Preparing brief summary reports and weekly financial reports
part-time,1-3 hours per day, Monday-Friday plus 10%
commission. Submit resume to: miles1011@hotmail.com
Full Name……………………..

City ……………………………….
Zip code……………………..

June 26, 2008

Antenna0 – Well Endowed Online Radio

Filed under: antenna0, projects, startups — MrBrandon @ 2:00 am

I’ve been working all hush-hush on Antenna0, an online radio service, for a few months. With Antenna0 someone can create an online radio station with their own music. Each station gets a snazzy community, integration with cafe press and affiliate programs for concert tickets, music, and artist related merchandise. Hot damn!

Antenna0 will monetize like Live365 and LoudCity by selling premium services to advanced hobbyists, but will also offer a free option. I’m committed to a free option, but I haven’t narrowed down the specifics yet, because it’s a pretty expensive service to provide for free. I don’t have much dough to work with.

Without question Pandora and Last.fm get more eyes and ears than hobby and independent broadcasters, but the small fries have been making people happy for years before the big guns arrived. They continue to exists, because people are very much interested in running their own radio stations. People continue to seek them out despite all available choices because these guys still offer unique and valuable content.

I think Antenna0 is the next logical progression for hobby broadcasters. It abstracts all the broadcast specific mumbo-jumbo, so it’s easier for someone to start broadcasting. The built in community turns what is normally a passive experience into an engaging, informative and entertaining one.

Antenna0 is a macro-community of stations, and each station is a micro-community. I think it would to see local music channels from all metropolitan areas on it. It would be a great way for people that like the local punk scene in Boston to find out what it’s like New York City or Chicago, or something like that.

I plan on providing users with tools to promote channels across blogs, personal websites and social networks but I’ll probably launch without it. A fair amount of independent artists get played on Internet radio too. So among other things, I’ll eventually need to allow contributed bios, urls and purchase information for music and merch.

Antenna0 is the result of a few prototypes I slapped together between moments, going back to October 2007. I messed around with subscription systems, song requesters, queuing solutions, affiliates, batch transcoding and all kinds of stuff. The more I experimented, the more I saw a bigger picture.

For the web side I settled on a RoR (Ruby on Rails)/Mysql stack and will drop it on the Ubuntu operating system. The streaming platform has Icecast at it’s heart, plus some customized scripts to manage the Icecast nodes.

June 24, 2008

Social Media Breakfast – Boston

Filed under: meetups, startups — MrBrandon @ 3:52 pm

I went to the Social Media Breakfast today. While the information was good, most of it was not of interest to me. The focus and presentations of this meeting was online marketing strategies. I should learn to care more since I’m all about online radio…but I’m heads down coding antenna0.com right now.

Overlay.tv stood out to me. They also sponsored the meetup and presented. Anyone that feeds me is my friend. Overlay.tv is like YouTube.com, but you can overlay the video with click-able contextual information. Like the pants someone in a video is wearing? Click on them and get linked off to the place that sells them. Commissions from affiliate links are split 50/50 between the video creator and Overlay.tv, nice!

I spoke to the CEO, Rob Lane, and told him I’ve heard this concept tossed around a lot in the past, so what made them take action and do it? The wife of another co-founder was watching Sex and the City (hate the show) and wondered where she could get those really fab pocket books.

Anyway, I think it’s a great idea but I wonder if there will be enough affiliate sales to make this ship float. Though I think most products will be fairly high dollar items (clothes, electronics, so on), so that’s good. Still these guys are not stupid, and they are aware of the average conversion rates and have crunched the numbers. They are aware it’s not easy. I’ve always thought additional information relevant to the content would increase conversion rates, and that’s their plan.

They are also getting approached by companies with specific needs, and they’ll naturally charge a fee for that. For example, some record labels want a little more hands on help getting artist related videos in there with custom features, and hopefully sell more product and some custom features. This is another good way for Overlay.tv to make money.

I wish these guys well.

Breakfast June 19, 2008

Filed under: breakfast — MrBrandon @ 4:26 am

This is the first post of my ongoing breakfast series. Why? Because I’ve worked for myself from home for years, so I’ve got time on my hands. Plus you should learn how to eat breakfast.

I’m not going to teach you how to cook, I just wing it. I’m going to teach you how to eat.

No one cares what you had for lunch. No they wouldn’t. Lunch at my last employer was reheated frozen meals with Sysco condiments, served in a cafeteria with no windows. It bordered cult compound food.

I used to wake up, jump in the shower and drive to work for one hour then have a snack at the compound. Now I wake up, walk into the kitchen and spend 10 – 20 minutes to make something good, chill out and eat.

So up top you see….

  • Coffee with lots of milk and a dash of sugar
  • Yogurt with apples, blackberries, cereal and honey
  • Frittata with roasted asparagus, zucchini, leeks and grated cheese


Create a free website or blog at WordPress.com.