Chuck Lauer Vose's Thoughts

Testing rack middleware in a request spec

Introduction This may be a controversial thing, but I found it to be useful and difficult to research so I'm going to post about it. For the record, it's probably ill-advised to test the effects of a middleware since presumably the middleware itself has bountiful tests (or maybe you should send in a PR!), but we wanted to TDD this and make sure that the middleware was really getting applied the way we thought it was. Crux of the stor...

Read More

Rails attr_accessible gotcha

If you’re like me you inherit a lot of projects which have very different styles. Today I ran into a project that had never used attr_accessible and I found a total gotcha: If there are no attr_accessible attributes on a model it’s open, any attribute can be written with .update_attributes() or a similar mass-assignment function. If there is even one attr_accessible the model is closed except for those attributes defined to be a...

Read More

Playing Drupal the card game the Drupal way

Now that NodeOne is running out of Drupal the Card Game I feel like it’s time to introduce my version of the game rules which I believe are actually significantly more Drupaly than the main rules. If you don’t already know the rules check out this video: Now, in the main rules you compete to complete modules and sites, which is all well and good right, but we don’t develop modules in the dark at all, we all know what’s...

Read More

What's in a framework, experiences from Rails and Drupal

I’ve now been working professionally in Drupal for a year and have learned a lot about it; I have some patches into contrib but I’ve not really done much with core other than some simpletests I was too shy to commit at Drupalcon and some comments trying to help people out on d.o. Prior to my stint as Drupal programmer I was a hardcore Ruby on Rails developer for about 4 years. Over the last two years in particular I’ve learne...

Read More

Nesting Views like a Mecha-Eagle

As you have probably figured out, I love views. I love teasing out little features that are completely buried and obscure. Nesting Views is one of my favorite new travesties; not sure if it’s ready for Drupal for Evil, but it’s certainly not kosher. If birds can nest, why can’t I? image by Benjamin Verdonck, reported by apartmenttherapy.com Ah nesting season, time to buckle down, collect bits of straw, and raise little Views...

Read More

Making your clients love Drupal's menu system as much as I love candy

NOTE: Apologies for the gap, I said I would post on Monday but well, I decided to get married instead. So there. You might be saying to yourself, “So Chuck, D7UX is all well and good right, but I’m running D6 right now. How can your wisdom possibly enhance my life and vitality?” Well, you’re in luck friend, for my limited stints into D7 have left me craving more of that optimized UX goodness and blogging is a side-effec...

Read More

Do your clients send you presents? If not, maybe we can figure it out together, lets talk about D7UX.

Do your clients love you with such a furious passion that it borders on problematic? Do you find new customers calling you and saying things like, "I must have your services! My friend has been bugging me all week to call you. Seriously, I just want him to stop camping out on my lawn. It's scaring the children." I found this on my desk the other day and I found myself filled with a sense of joy and satisfaction. I have to admit ...

Read More

Drupal snippets #1 (Views exposed filters, F5 tweaks)

Cross-posted at the Metaltoad Blog While I’m certain that I could never work up to the standards of Peter Cooper his “Interesting Ruby Tidbits That Don’t Need Separate Posts” series was a great help to me when I was a ruby developer. You can see the original here: IRTTDNSP #1. I’ve not found similar for the Drupal community but I believe a lot of the things I do during the week are interesting but not at all worth...

Read More

Drupal benchmark results using AB and the simple things we did to get here

Cross posted at the Metal Toad Blog I was trolling around the Internet today looking for benchmarks and I actually had a little trouble finding something current. Dries has one comparing D6 on PHP4 vs D6 on PHP5 but that was clearly ages ago. I also realize that this is going to be out of style in about 12 minutes, will probably be fraught with contention, and generally mocked by everyone; but in the interest of those few souls out there that ...

Read More

Using git-svn to manage standard and non-standard branches

Cross posted at the Metal Toad Blog When Webchick announced that Drupal was moving to Git at Drupalcon 2010, our office erupted in pleasure at the news. Lots of great Drupalists are already using Git and there’s even an unofficial Github branch of Drupal for your branching and stashing pleasure Github mirror. However, Metal Toad Media has been an SVN shop for a long time we still have a lot of processes that use SVN, so we elected unanim...

Read More

How to reconnect a bluetooth mouse/keyboard in OS X or Windows 7

Cross-posted on the metaltoad blog Okay, as mundane as it sounds there are a lot of articles around the internet that are fundamentally misunderstanding the simplicity of this request: how do I reconnect my bluetooth device after it’s been disconnected from being in my laptop bag or whatever. There is no reconnect option in Windows 7 and the reconnect option in OS X is fairly buried. As long as your device is in the bluetooth devices men...

Read More

RequiredSequence v0.4

During my last mini flash project I created a project designed to help me with async calls in AS3. I hope that it helps you too. You can find the project on my github account. Intro Required Sequence is a tiny AS3 library that mandates that certain bits of code run before other bits of code. I’ve heard that Senocular has an excellent version of this but I could never quite grok his library. There’s also the apparently magical BulkL...

Read More

Getting started on displaying videos with the Brightcove iPhone SDK

Cross posted on the Metal Toad Blog There’s a lot of good to be said about the Brightcove iPhone SDK, it’s easy, it seems to work really well, but there’s also a ton of gotchas and the docs are a little conflicting and/or out of date. The OnePlanet app is also out of date. This post is my attempt to rectify some of these things. There are three things needed to get your app going: You must be using your Read with URL Acccess ...

Read More

Clearing the state of a actionscript 3 app (aka, globals are eeevil)

Cross posted on the Metal Toad Blog Imagination time: Imagine for a moment that you have an app, it has one button and one little window. When you click the button it changes the text within the window to something else. Now, when you get into flash development it seems like the easiest and clearest way to do this is to wipe out the contents in the window, but you would be wrong for thinking so. While it is the most obvious I intend to prove t...

Read More

The Value of 10% Time in Improving Your Life and Productivity

Cross posted on the Metal Toad Blog Convincing Yourself Convincing yourself of the value in 10% time is critical and is sometimes the most overlooked step in the process. Most people look at 10% time as nothing time; time you can’t bill for must surely be worth nothing financially right? And worse you might think, not only are you not billing but you’re robbing yourself of time that you could be actually developing so it feels like...

Read More

Facebook API Terminology

Cross posted on the Metal Toad Blog The toad just finished a small project involving the Facebook API and by far the most confusing aspect of the project was the terminology regarding the many, many different API’s and what each one actually does. I thought this merited a write-up and I hope you find it helpful. FBML, Frames and the Canvas “I’m interested in making a Facebook app that will live on Facebook.com but store data ...

Read More

Recursively load nodes from a rich data model

Cross posted on the "Metal Toad Blog":http://metaltoad.com/blog/recursively-load-nodes-rich-data-model If you've ever worked with a rich data model in drupal you know it can be a pain to load up all the children and parents of a node within the templating engine. One method that could save you a lot of time is to load the data recursively in node_load and save your poor front-end guy some wrist pain (or yourself if you're th...

Read More

Multiple Dynamic Tabs in Brightcove 3

Cross-posted at company blog: http://metaltoad.com/blog/multiple-dynamic-tabs-brightcove-3 This week I had the wonderful opportunity to work on an interesting problem that as far as I can tell hasn’t been documented. The call came out that we needed to generate a couple dynamic tabs on the top of our player for smart playlists. Now, we already have one dynamic playlist so I thought it was going to be a fairly simple logical step up to th...

Read More

An Unexpected Occurence With Git: How Git Saved The Day Today

Cross-posted from the Company Blog In my experiences in the past working with external contractors is often a pain, especially the final merge where you try to incorporate all their code. I’ve always been a huge proponent of Subversion for SCM but today I saw an example where Git knocked the socks off of Subversion. Time came and code needed to be merged into trunk. While discussing our options someone noticed that there was a .git file ...

Read More

Fun with stakeout.rb

Cross-posted to the company blog at: Fun with stakeout.rb Having only left Rubyville a couple weeks ago there are still a lot of Ruby-based utilities that I still find incredibly handy. One such utility that I’ve recently fallen hopelessly in love with is stakeout.rb from: http://pragmaticautomation.com/cgi-bin/pragauto.cgi/Monitor/StakingOutFi… Stakeout monitors your filestructure waiting for changes to happen and when they do it ...

Read More

Converting from Brightcove 2 and loading arbitrary videos

Cross-posted to: Company blog version Over the last two weeks I’ve been working on a project to convert one of our client’s websites to Brightcove 3 players. As I am quite new to drupal but not to PHP you can imagine that many of the problems I had were unrelated to brightcove itself but there were a few aspects that I thought were worth documenting for those who are in the (surprisingly) enviable position of doing this migration. ...

Read More

Integrating Rails and Rack

Posted for those confused about Rack. Rails doesn’t need Rack right now to integrate with the current webservers so you don’t need to learn about Rack right now. Rack is for frameworks that aren’t Rails but still want to take advantage of the excellent web servers that have come into being lately (read: Phusion Passenger) I hope you don’t have to troll around the Internet as long as I did just to find this answer :)

Read More

Pagination, Sets, Checkboxes

When I was at RailsConf2008 I learned a lot about life and Rails but there were some nagging problems that lingered after me for a long time. At one point in the talks there was a discussion of how to make listing pages have checkboxes and how to handle this data. The problem is complicated by pagination and filtering so it’s actually a really good problem to talk about. The proposed solution was to send back a structure that looked some...

Read More

RBridge 0.2

RBridge has undergone a lot of bug fixes and I think it’s worthy of a 0.2 release at long last. 1 major enhancement Actually runs headless via the rulang command. 3 minor enhancements Uses optparse for clearer command-line options. Option to specify port, compile directory, mnesia directory, sname, and location of server file. Some error checking, and debug output added. Checks to see if server is already running on specified port...

Read More

RBridge-0.1.2 Announcement

Just wanted to poke my head in and let people know that a new version of rbridge has been released. New to this revision is a few little tweaks and bug fixes but the main point is that you can install the gem and just type ‘rulang’ from anywhere to start the erlang server. This enabled us to build a little test suite which should improve quality. Also, the end of quarter summary has been posted per our class requirements: Review

Read More

Concurrent code in Ruby 1.8.6 through inlining

Slight typo in the code fixed: 2008-01-08 Toshiyuki and I have released a new gem called rbridge which allows us to execute functional, side-effect free, concurrent code directly in Ruby regardless of the version by using Erlang as a processor. This includes using the Mnesia distributed database and ETS/DETS. To try it out please follow these steps: 1. Download Erlang for your os. Windows has binaries and OS X can be configured with `./configu...

Read More

rbridge 0.1 Released

<by Chuck Vose (adapted from Toshi Hirooka’s RulangBridge)> <ruby-mnesia.rubyforge.org (originally http://code.google.com/p/rulangbridge/)> FEATURES: Allows use of Erlang code within Ruby Changes: v0.1 / 2008-01-04 (vosechu) 1 major enhancement Allows many-lined Erlang commands when using the Erlang class for direct access. 3 minor enhancements Revised error checking to allow custom resolution stop_server/0 now shut...

Read More

Complex commands with Rulang

Rulang was giving me a lot of trouble with regards to multi-line commands and complex commands in general. After hacking on it for a while I’ve developed a patch that will allow ruby code such as the following: require 'rulang' @mnesia = RulangBridge::Erlang.new("localhost", 9900) def find @mnesia.eval(<<-EOF QH = qlc:q([X || X <- mnesia:table(shop)]), F = fun() -> qlc:eval(QH) end, {atomic, ...

Read More

Mnesia to ruby bridge evaluation

Owing to the complexities of building a Rails adapter for Mnesia I’ve been looking into using a Ruby to Erlang bridge and have looked at the various projects that seem to be available and want to share my comments on how each is stacking up so far. Rebar Rebar was announced on 2007-04-20 and has since never surfaced to the public as far as his blog and Google are concerned. The code looked to be among the easiest to understand but is tha...

Read More

Mnesia + Ruby Announcement

My goal this year is to release a Ruby port of the Mnesia distributed database and hopefully start the process of moving to a true slice architecture. The port is an interesting project but I think the importance of the slice architecture is paramount. For the last couple of years we’ve been working on the n-tier model with ruby. It’s well established and it has been working nicely for us. But the web server industry is starting to...

Read More

find_or_create by params (extension to dynamic attribute based finders)

Rails has a dynamic method where you can do find_or_create_by_attr_name(attr) but it the method names get incredibly long very quickly. So SJS wrote this article in which he tries to remedy the situation. His solution was pretty elegant but it still only worked for fields that were already defined in the database; if you often redefine setter methods it doesn’t work at all. Here’s my attempt to remedy the situation. module ActiveRe...

Read More

Long Bets

Sam Ruby occasionally does an article about his long bets and I really respect his ability to predict the future. This time I feel that he was focusing too close and forgot the long part of the ‘long bet’. REST is already important, and there are further developments in edge rails that make it even more important (active resource). MySQL is already a pain for scaling and the plugins are starting to come out but haven’t really...

Read More

Inheritance without STI: method_missing routing

Every once in a while I find myself in the situation where I need to override a model or create an inheritance without using single table inheritance (STI). The method_missing call can help us to create an intelligent router that will route calls to the parent class or the child while maintaining an extremely small code footprint. Here’s an example of what I’m talking about. We needed a landing page that would be dynamic for each u...

Read More

Nginx http_perl_module

Errors you might get at this step: Can't locate nginx.pm in @INC Can't locate loadable object for module nginx in @INC This is how I installed the http_perl_module for Nginx. I'm not sure why these things are the way they are, I'm following a mailing list that was written in russian. :) Installing from ~/src/nginx-0.6.5 Installing to /opt/local/nginx (if this isn't owned by you use append sudo to the last step) cd ~/src/nginx-0.6.5 ...

Read More

Rendering partials with a 302 breaks ie6

If you can spot what’s wrong with this code you get a cookie. Apparently rendering with a 302 breaks ie6 entirely. Just deleting the 302 makes it okay. render :partial => 'admin/restricted', :layout => 'admin', :status => "302" and return falseWhether it makes sense or not is not the question. I’m pretty confident that it doesn’t make sense after thinking about it for a while. But why would ...

Read More

Arrow keys in vi and iTerm

Arrow keys doing funny things when you use vi in iTerm 0.9.5? It’s because we’re too used to messing with things. Set your Default bookmark’s keyboard type back to Global. “When the terminal type of your sessions is set to one of those “xterm” types, iTerm handles the arrow keys, the home key, and the end key in a special way." says the FAQ while not actually addressing the solution. But who can complai...

Read More

Testing rails without fixtures

At On & On Creative we have a lot of sites on a common rails backend. It’s incredibly flexible so we can offer a lot of support to customers but because there are so many customers with different needs testing has become a huge pain. Not only does it let us run tests custom to each client, it provides a way to import the data to the test db really easily and it’s way faster than loading the fixtures each time you start a test. ...

Read More

RailsMachine / Slingshot image loader slowdown

Background / Analysis Recently a fellow asked me to help him diagnose a slowdown in his rails stack at the Ruby Brigade meeting in Seattle. After going through the normal procedures of checking mysql indexes, talking about caching, and checking the code for bizarreness I still couldn’t find anything really out of the ordinary. Finally we turned to Firebug and found that the images were taking an eternity to download. This had happened to...

Read More

Rmagick OS X Verdana

If you’re getting errors about Verdana not being found, specifically: “unable to read font `/Library/Fonts/Verdana’ (Magick::ImageMagickError)” try: sudo apt-get install applesystemfonts cp /sw/lib/X11/fonts/applettf/Verdana.ttf /Library/Fonts/ sudo gem install rmagick

Read More

RMagick on RHEL4

Holy shit, an easy thing in RHEL4. Assuming you already have rubygems and ruby: sudo up2date ImageMagick ImageMagick-devel sudo gem install rmagick

Read More

Recursive children

One of the things sorely missing from Rails (and with good reason) is a function to find all the children in a tree. Below is my attempt at it, you can drop it in any model that acts_as_tree and call all_children to get a flattened list of all children, grandchildren, etc. def all_children all_children = [] all_children << list_children(self) return all_children.flatten end private def list_children(branch) all_ch...

Read More

Sending messages to all users

One of the biggest fears of all system admins and developers is publishing work to a live server and having it break everything. Naturally we all go to great lengths to make sure this doesn’t happen but even the most well-tested code in the simplest environment still breaks sometimes. In addition to these fatalities is the less intrusive but equally damning maintenance that sometimes just has to happen in the middle of the day whether th...

Read More

Cascading page attributes

Intro and Concept One of the first things I tried to do in Rails was to figure out how to make a nice, generic website that anyone could update. After about sixteen iterations I’ve finally stumbled on one that I think will finally work. As of now it’s only partially complete. I’m really only using this method to generate the titles and meta information but each time I have to make a change to the website I find more and more ...

Read More

Using Rails to Create a Static Site

Overview A customer of ours has a splendidly restrictive environment which I have the pleasure to work within. Not only is there no Rails, there’s no PHP and presumably no database to hook into even if there were dynamic languages. This is probably complete crap but it led to an interesting problem solving situation regardless. What do you do with a client that wants hundreds of pages to be redesigned when you don’t have access to ...

Read More

Hiring developers

Background After a lot of thought and an enlightening article by Joel Spolsky , I’ve come to the following conclusion: Hiring new developers is almost never the answer to the problem of having too many programming projects. We have that problem right now. Demand is very high and Tynan no longer has much time to code due to business requirements. So we have at least four pending projects, two of them very large, and three on-going project...

Read More