Installing Holla

[Originally published 26 February 2012]

Holla is an open-source Campfire clone written in ruby. I had heard about Campfire but as a student, have no real ability to pay for it, so I decided to search for open source/free alternatives and stumbled upon Holla. Seemed worthwhile to throw in a vm and play with. It was quite the ride.

I started off with an Ubuntu 10.04 box trying to install Holla. That didn’t work too well, I ran into troubles getting the right version of everything installed. Despite my view that arch linux shouldn’t be used in a production environment, I was pretty sure it would have up-to-date packages, so I spun up a vm of arch on my HP MicroServer running ESXi and went to town.
The instructions on holla’s site to install holla are as follows:
  • bundle install
  • rake db:migrate
  • rails server thin
  • start the Juggernaut server – http://github.com/maccman/juggernaut
  • Now go to http://localhost:3000

Simple, right? Well it looks like we need juggernaut. Instructions to install juggernaut on juggernaut’s site:

  • Install Node.js
  • Install Redis
  • Install Juggernaut
  • Juggernaut is distributed by npm, you’ll need to install that first if you haven’t already.
    • npm install -g juggernaut
  • Install the Juggernaut client gem
    • gem install juggernaut
Sweet! I can do that. Time to spin up a vm and get cracking. After installing the base system, I need to install some basics:
# pacman -S git openssh curl base-devel sudo screen vim
At this point, I created a user for myself. This is important. If you run everything as root, you get some wonky problems later on. I added myself to wheel and to the ruby groups.
At this point, I learned the hard way. Snapshots are your friends. If you’re doing this on a vm, take a snapshot now. Do it.

Now, for some specifics to this project:

# pacman -S redis nodejs libxslt
n.b. libxslt is a dependency further on down the road for nokogiri, a bundle required by holla. (http://coding-journal.com/installing-gitorious-on-ubuntu-11-04/). The other packages are required by juggernaut.
Now, log in as your newly created user and it’s time to install ruby. To install ruby, I’m going to use rvm. Holla needs a specific version of ruby, and I ran into some troubles installing the base arch package:
$ bash -s stable < $ source ~/.bash_profile
$ rvm requirements
$ rvm install 1.9.2
set default ruby:

$ rvm alias create default ruby-1.9.2-p290

Now, to install rubygems. I installed from source:
$ wget http://rubyforge.org/frs/download.php/75856/rubygems-1.8.17.tgz
$ tar xvzf rubygems-1.8.17.tgz
$ cd rubygems-1.8.17
$ ruby setup.rb
Now we’re starting to get somewhere! We have ruby installed! Now we need to install juggernaut, so onto install npm to install juggernaut with. I had to install this as root, even with sudo it wouldn’t install for some reason.
# curl http://npmjs.org/install.sh | sh
These guys have some tricky installers. That’s the second time we’ve ran a script we got through curl in a one-liner.
So we have npm. Time to install juggernaut.
$ sudo npm install -g juggernaut
Now, to install its gem:
$ gem install juggernaut
Great! Now we can start installing holla (finally!). First we need to clone the repository, install Gem bundler then run ‘bundle install’. Note that you have to re-source your .bash_profile to be able to use bundler.
$ gem install bundler
$ source .bash_profile
$ git clone git://github.com/maccman/holla.git
$ cd holla
$ bundle install
[...]
An error occured while installing linecache19 (0.5.11), and Bundler cannot continue.
Make sure that `gem install linecache19 -v '0.5.11'` succeeds before bundling.
Well, that stinks. Fortunately, I found a fix.
$ gem install ruby-debug19 -- --with-ruby-include=\$rvm_path/src/ruby-1.9.2-p290
Great. That’s done. Back to bundle install.
$ bundle install
[...]
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
Whoo! It worked. Onto step 2 (ha ha ha…we’re just on step 2???). Using bundle exec didn’t fix rake for me, but the following did. I found the fix here.
$ rake db:migrate
You have already activated rake 0.9.2, but your Gemfile requires rake 0.8.7. Using bundle exec may solve this.
$ gem install rake
$ bundle update rake
$ rake db:migrate
Next, step 3:
$ rails server thin
Finally, starting juggernaut
$ redis-server
$ juggernaut
Head out to your server’s hostname or IP on port 3000 on a browser (make sure you use Chrome or Safari and you’ll have to log in with twitter)! Then, hopefully, it works like mine! Add a channel to get started, then test it!
And there you go!That’s it!  I was rather surprised it was working. This was the fourth try of the weekend and I was about ready to throw in the towel. Good luck to you if you try it! It was a super fun project and hopefully it will work for you!

VMware ESXi 5.0.0 on HP ProLiant MicroServer

[Originally posted 23 February 2012]

The other day, I became the proud owner one of these. The HP ProLiant MicroServer N36L. I had been wanting to build my own home/lab ESXi environment for some time now but haven’t had a box powerful enough. Then I came across this little “MicroServer” and took the plunge, so to speak.

There are a few main sites across the web that have helped me in my quest of installing ESXi on the N36L, namely:

Here are the current specs of my machine (affectionately called “enterprise”):

  • AMD Athlon II Neo Dual-Core Processor (VMware reports them as 2 x 1.297 GHz)
  • 8GB DDR3 RAM
  • 2 GB USB Thumb Drive (ESXi is actually installed onto this little guy)
  • 2 x 160GB SATA HDD
I plan to upgrade my storage to a 4x1TB configured in RAID10 but I have yet to purchase a RAID card for my MicroServer.

Right now, I’m running 6 VMs at about 1/3 CPU usage and 5/8 GB of RAM used. They aren’t doing a ton at the moment, but that’s slowly changing. Here’s what I’m doing (hostname - function - OS):

  • data – running @GetAnAmen, my twitterbot - Debian Squeeze
  • lore – test server, after things are working well on lore, they get moved to data – Debian Squeeze
  • transporter –  running an OpenVPN appliance – CentOS 5.7
  • worf – my “net manager” machine inside of my lab environment for me to interface with – Ubuntu 10.04
  • vCenterMobileAccess – this guy - VMware’s own creation, based on CentOS
  • riker – a test box for various things – Windows Server 2008 r2
  • lcars – samba and nfs sharing for all the machines in my network – Debian Squeeze
  • holodeck – minecraft server – MineOS+

That’s all for now! Big plans in the future for this little box for some fun stuff! If you have any questions, don’t hesitate to contact me, I’d be happy to help in whatever way I can!

Can I Get an Amen?

[this was originally published 18 January 2012]

Walking home from work one day, I thought it would be fun to write my very own twitter bot. For some reason, python seemed like an appropriate language to do this in, so I did a little research. My two main sources ended up being @the_shrinkbot and @grammer_man (warning, not safe for work language on grammer_man’s site).

I needed an idea. A twitter bot is great, but it has to do something. I decided that there must be people who need an amen, so, I made a new account: @getanamen, mostly to amuse myself and my roommate.

#!/usr/bin/env python

from twitter.api import Twitter, TwitterError
from twitter.oauth import OAuth, write_token_file, read_token_file
from twitter.oauth_dance import oauth_dance
from time import gmtime, strftime
from sys import stdout

import os
import time
import sys
import pickle
import random

# I honestly don't know whose keys these are
# I think they might be twitter for command line's?
CONSUMER_KEY='uS6hO2sV6tDKIOeVjhnFnQ'
CONSUMER_SECRET='MEYTOS97VvlHX7K1rwHPEqVpTSqZ71HtvoK4sVuYk'

# thanks to ventolin and his bot, grammer_man
# source: http://ventolin.org/2012/01/grammer_man-who-the-fuck-is-this-nigga-and-why-u-comin-at-me-like-that-hoeassnigga/
def check_if_done(id):
    '''
    Checks if a tweet has already been responded to
    '''
    if os.path.exists('done.pkl'):
        f = open('done.pkl', 'r')
        done = pickle.load(f)
        f.close()
        if id in done:
            return True
    return False

# also thanks to ventolin and grammer_man
def update_done(id):
    '''
    Updates a list of tweets that've been replied to
    '''
    if os.path.exists('done.pkl'):
        f = open('done.pkl', 'r')
        done = pickle.load(f)
        f.close()
    else:
        done = []

    done.append(id)

    f = open('done.pkl', 'w')
    pickle.dump(done, f)
    f.close()

# a lot of this code is thanks to Vivek Haldar and his bot
# doctor_eliza
# http://blog.vivekhaldar.com/post/2830035130/how-to-write-a-twitter-bot-in-python
if __name__ == '__main__':
    oauth_filename = os.environ.get('HOME', '') + os.sep + '.twitter_oauth'
    oauth_token, oauth_token_secret = read_token_file(oauth_filename)

    # vivek: We use two twitter clients, one to search, another to update. Just
    # easier that way...
    twitter = Twitter(domain='search.twitter.com')
    twitter.uriparts=()
    print '##### args = ', sys.argv
    # some setup....
    last_id_replied = ''
    counter  = 0
    if len(sys.argv) > 1:
        counter = int(sys.argv[1])

    # the so-called oauth dance
    poster = Twitter(
        auth=OAuth(oauth_token, oauth_token_secret, CONSUMER_KEY, CONSUMER_SECRET),
        secure=True,
        api_version='1',
        domain='api.twitter.com')

    # this is main loop of the program
    while True:
	# search for #amen
	print 'Searching...'
        results = twitter.search(q="#amen", since_id=last_id_replied)['results']

        if not results:
            print 'No results this time...'

        for result in results:
            # Remove my name from the question.
	    # this made more sense for doctor_eliza,
	    # but I'm keeping it in for the terminal
	    # output.
            request = result['text'].replace('@GetAnAmen', '')
            asker = result['from_user']
            id = str(result['id'])

            # this is my stuff -- formatting the termianl output
            # because I enjoy monitoring it...
	    myTime = strftime("%a %b %H:%M:%S", gmtime())
	    print myTime
            print "\t" + asker + ":"
	    print "\t  " + request

	    # my response
            response = "Amen!"

            # creating the reply message
            message = '@%s %s' % (asker, response)
            print '\t@GetAnAmen responds:'
	    print '\t  ' + message
            last_id_replied = id

	    # check if I've already replied to this message
            if not check_if_done(id):
                # post!
                poster.statuses.update(status=message)
                counter += 1
                # add who I tweeted at as a friend
		# poster.friendships.create(id=asker)
		# add to list of who I've replied to (pickle is pretty cool)
                update_done(last_id_replied)
                print '\tLast id replied = ', last_id_replied
                print '\t%s Done\n' % counter
            else:
                # output to the console
                print '                  !!!!! already done !!!!! '
                print '                  %s Done\n' % counter
            # don't want to flood the twitters too badly
            time.sleep(random.randint(1,2))

	    # Joel and I did the math, and we think tweeting 40 times then
            # sleeping for an hour is good. Maybe change it to 20 / 30 mins
            # or 10 / 15 mins in the future? vamos a ver...
            if counter > 39:
                print 'Done %s tweets, sleeping for 60 minutes'
                for i in range(0,60):
                    stdout.write("%d " % i)
                    stdout.flush()
                    time.sleep(60)
                counter = 0
                # break the for loop so I search for more results
                break

    print "This should never be outputted"

After many iterations and being banned from twitter a few times for posting too much (#oops), this is more or less “who” @getanamen is:

It’s fun to watch who retweets, mentions, and follows him. You can see what he’s saying here: @getanamen. I hope you enjoy @getanament.

He’s built using Python Twitter Tools (ptt) and right now, running on a virtual machine on my desktop.


Hello world!

…aaaaaaaaaand we’re back! Content will be back up shortly.