Nitobi
About Nitobi
Services
Products
Home -> Blogs -> Joe@Nitobi

Joe@Nitobi

Archive for the 'Uncategorized' Category

Be less stupid and ugly - Using git with vlad

March 11th, 2008

SVN Sucks! I’ve said it! It’s hard to count how many times that I have had to deal with subversion related headaches on a daily basis. It teaches bad habits, and when it breaks, all time stops and you have to spend eternity fixing the subversion database. That being said, it’s still better than Visual SourceSafe or CVS, but it’s still horrible.

If you don’t believe me, watch Linus talk about git!

OK, So git is awesome and svn sucks. So, we should switch to git. Unfortunately, I used all my invites to github, but it’s pretty awesome for getting your repository hosted. However, if you have any sort of local network, you could just host it on a share just as easily. I’m not going to go into a git tutorial, there are plenty at github and other places.

However, I did find a bug with git and vlad, and I had to modify a line in my vlad gem to get it to work. This is a git bug, not a vlad bug, btw. When you install git-core on Ubuntu, you may have a problem with git-archive where you have to specify an archive format, and the vlad migration fails. To fix this, you need to go into your vlad source and add this to the command:


[ “mkdir -p #{destination}”,
“#{git_cmd} archive -format=tar #{revision} | (cd #{destination} && tar xf -)”
].join(” && “)

In here, I added the -format flag. Since vlad expects this, this will get your system up and running. I don’t know if this issue is present in the Mac OS version of git, or in any of the other distro’s packaged gits. It’s not an issue in Windows, because vlad doesn’t work in Windows as of yet!

But yeah, other than this minor detail, I’m enjoying using git where I can. I haven’t tried Windows git yet, but I’m guessing that it should be almost as good as it is on Linux/Mac OS. It’s great being slightly smarter and less ugly.

Dog On Rails at Open Web Vancouver

February 26th, 2008

So, my talk submission made the cut. I will be presenting a talk about FreeTheNet at Open Web Vancouver. Basically this will be a talk that compares what is out there. Hopefully I can beef up DogOnRails and clean up the code significantly before I talk about it. Currently, there’s a lot of messy hacks here and there to get the app working, and I’m going to need to do a lot of cleanup before I can get the thing presentation worthy.

Unlike the talk at RubyCampVancouver, where I talked about where things went wrong with DogOnRails, I figured that I should use this as an opportunity to show real world industrial uses of web applications and dashboard visualization, which is exactly what DogOnRails is.

Whenever we think of Dashboard Apps, we usually think of things that show visualization of data on a Web Application. How many tracks were downloaded, how many hits, how many people have visited the site, etc, etc. However, this is really just the tip of the iceberg when it comes to dashboards and visualization. There are many more apps that need good centralized mangement and visualization, and a web management application can be exactly what you need. Currently most of these apps were done in the 90s and don’t work very well. Nobody really talks about how I can connect my toaster to the web, except for hobbyists, but I think that it’s going to happen again.

VLAD the DEPLOYER!

January 7th, 2008

I like simple things, and I’m not squemish when I see an error if I know why that error is true. When I needed to learn how to deploy a Rails app, I first looked at Capistrano. Capistrano looked nice enough, until I heard other people complain about how hard it was to use and how it was a pain the ass.

Then I found Vlad! Vlad the Deployer is a great alternative to the complex Capistrano. I’ve used vlad on every Rails project that I’ve deployed in the last year, and it’s hawt! This will probably sound the same as all the other vlad tutorials, and no I did not get it to not try and run apacheconf, but I will talk about options to turn this off.

First of all, when you install vlad, you need to add the following to your rakefile:


require ‘vlad’
Vlad.load

Then you setup a deploy.rb file with the following:


set :application, “dogonrails”
set :user, “bowserj”
set :domain, “#{ user }dogonrails.net”
set :deploy_to, “/var/www/dogonrails”
set :repository, “http://dogonrails.googlecode.com/svn/trunk/dogonrails”
set :web, “nginx”
set :ssh_flags, “-p 31323″

In this case, there are two things that I did differently in my vlad file that aren’t normally done. DogOnRails is hosted on a vm which also hosts many other community sites. This means that I have to specify the port by using the ssh flags. I also changed the server to nginx. However, without an nginx.rb in the lib/vlad/ directory, this is going to run the apache command. A quick and dirty way to get around this as well is to set the web_command


set :web_command, ‘/dev/null < '

Now the message is supressed. We really don’t need to keep restarting nginx when we deploy. It’s not leaking memory or breaking the proxy like what Apache does in the scenario that I just described above. (Note: If your vlad or apache process IS doing this, you should probably get that fixed before dealing with deployment woes!) Of course, you’ll probably want to create your own tasks in the namespace, and this is exactly like rake:

namespace :vlad do
desc ‘Does turnkey stuff’

task :deploy => [’vlad:update’, ‘vlad:symlink’, ‘vlad:start’]
task :deploy_with_migrations => [’vlad:update’, ‘vlad:migrate’, ‘vlad:symlink’, ‘vlad:start’]

desc ‘Symlink custom directories’
remote_task :symlink, :roles => :app do
# Do Stuff
end

end

In this case, This task will create and destroy symlinks. I use ugly absolute paths because I don’t trust my Rails environment. In hindsight, I really should use the current_directory and shared_directory variables because they can be changed. This is probably a judgement call that you can make.

Anyway, at the end of it all, you’ll have to type in your password a bunch of times. You could put your password on the key and send it to the server, but given that most projects have multiple administrators, I think that idea is as good as trying to nail warm jello. This is the downside of vlad, but I like learning complex passwords!

The other big plus is that it can use git! I think that I am becoming stupider and more ugly by using svn! (mostly because Linus says so) not to mention the fact that Google Code has problems with hosting DogOnRails as of late, I will be switching to git soon! Once I have a functioning public git repository, I’ll post the results here! I will also try to update this blog more often as well.

Announcing FreeTheNet Hack Night at FreeGeek Vancouver

November 21st, 2007

From the email:

Come one, come all to the DIY Homebrew Event of the Year:

FreeTheNet and FreeGeek Vancouver present…

Wireless Router Hack Night
Time: 6:30 PM until 9:30 PM
Date: December 1, 2007
Location:
FREE GEEK VANCOUVER
117 East 2nd Avenue
Vancouver, BC

This is for people who want to learn more about how to hack Embedded Linux hardware. They’ve heard about all the WRT54G hacking for years, but either have bricked their routers, or have just not bothered to try to get them going. This is also being used by FreeTheNet to do some recruiting for Hardware Hackers for many of the plans that we have coming up.

So, if you have an item that is on the Table of Hardware with the status of Supported, Untested, WiP or Kamikaze, please take it down and we’ll take a look at it. We’re also looking for 3.3V TTL to RS232 or 3.3V TTL to USB converters so we can get Serial Ports on certain devices (such as Fon Routers), so if you have some you wish to lend, or know of a good source for them, please let me know ASAP.

Recommended Hardware are as Follows:

  • Meraki Mini (if you have any spares)
  • FON (Units that haven’t been on the Internet yet are preferred)
  • Netgear WGT634U
  • Linksys WRT54G (v1-v4), WRT54GL
  • WRAP/Sokeris Boards

So, back to what’s going on. Yes, I am going to host a hack night for various routers at FreeGeek. I have no idea if anyone is going to come to the hack night, but since Vancouver goes through cycles of activity when it comes to embedded stuff, I think it’s time for another big hack thing. The cool thing about this is that the embedded stuff can run WifiDog and then we can demo DogOnRails. I’m hoping that once I get the firmware done and released, with a modified version of the WifiDog Client, and with DogOnRails, that we will be able to replace the Meraki Stock firmware in the new year and have an almost Free Software based system from Management Server to Access Point.

Next, I’m going to see about getting a screencast of Vlad when we deploy DogOnRails on the live server. I’m going to use that instead of the “Anonymous Rails App” that I’ve been working on as of late.

Gutsy Gibbon, Toronto, Wireless and Ajax!

November 9th, 2007

I realized that I haven’t actually blogged on my Nitobi blog in quite a while, and it’s not because I don’t have a lot to blog about. Here’s everything that’s gone down in the last few weeks:

  • DogOnRails got voted the best hack at Nitobi Hack Day! It takes two of my favourite things, embedded gadgets (especially those that run Linux) and RIA and smashes them together.
  • I’m now down to one laptop at work! I’m going to blog more about Ubuntu Gutsy Gibbon on the Dell Latitude D630, but I have top give props to URandR, it saved me a lot of time getting dual monitor mode setup, as well as using VMWare Server for IE Browser testing
  • I’m going to Toronto to attend the CWIRP conference on behalf of FreeTheNet! It’ll be interesting to see what other people are doing.
  • I’m now a fan of Vlad the Deployer! Vlad really is the way to get deployments done. Once I get it to ignore apache altogether for nginx deployments, I’ll post my experiences on here!

Perhaps when things slow down more, I can get into more detail, but for now that’s a sample of what’s going on! It’s craziness!

S3

October 5th, 2007

In the life of a web application, there comes a point where that shared hosting account just isn’t good enough (and you found out because your provider kicked you off), or your server just isn’t able to pull the queries from the database fast enough. Then one day, you finally get the filesystem error EMLINK, which you have a VERY hard time googling.

This is simple, you just created the maximum number of subdirectories that you can have in a directory. This is suprisingly not a common issue with file_column, acts_as_attachhment or attachment_fu, although I’m shocked as why it’s not. So, what do you do when you’re faced with scalability issues, and you’re image handling plugin is broken!

THROW IT ALL AWAY!

That’s what I had to do. Recently we worked on a site and we decided that because it was getting too hammered, that we would put the images on S3. Then we found the ultimate weakness of S3, which is that it’s not able to easily handle batch processing. We used the AWS:S3 library for most of the movement of the files, but we found that if we made a mistake, it would cost us hours to get these back.

Eventually, the day was saved with jetS3t, and Cockpit. Using jetS3t, we were finally able to actually get through all the S3 issues, and it saved the day at the end. (Actually, Dave saved the day at the end, my computer kept running out of memory). But we managed to get S3 support into it, and all we had to do was sacrifice File Column and replace it with this:


def user_image=( blob )
# establish S3 connection
AWS::S3::Base.establish_connection!(:access_key_id => AWS_ACCESS_KEY_ID, :secret_access_key => AWS_SECRET_ACCESS_KEY)
datestamp = Time.now.strftime(’%d%m%Y’)
identifier = UUID.random_create.to_s
object_path = “images/” + datestamp + ‘/’ + identifier + ‘/’
object_key = object_path + blob.original_filename
self.image = blob.original_filename
self.image_dir = ‘http://s3.amazonaws.com/bucket/images/’ + datestamp + ‘/’ + identifier + ‘/’
image_data = blob.read

#Send the file to S3
AWS::S3::S3Object.store(object_key, image_data , ‘bucket’, :access => :public_read)

# resize to thumnail here
img = Magick::Image.from_blob( image_data ).first
thumbnail = img.resize_to_fit! 96, 96

# Set the thumbnail directory path
thumb_key = object_path + ‘thumb/’ + self.image

AWS::S3::S3Object.store(thumb_key, thumbnail.to_blob , ‘bucket’, :access => :public_read)
end

However, if you have to do S3, I would highly recommend using a long key so that you can sort your re.sults better based on this key! However, the biggest gotcha I found when adding S3 integration to my rails app was including AWS/S3. If you include and require it, it will break your routing, this is something that can cause hours of headaches, especially if you are doing something else. At the end, we learned that S3 is a misnomer. For a large number of files, it’s far from simple.


Search Posts

You are currently browsing the archives for the Uncategorized category.

Pages

Archives

Categories

All contents are (c) Copyright 2006, Nitobi Software Inc. All rights Reserved
Joe@Nitobi Entries (RSS) and Comments (RSS).