Technology Musings

August 27, 2008

General / Stuff you can do with Google Earth


August 26, 2008

Project Management / How to Do Well


This slashdot discussion starts out as a specific question, but then digresses into a much more general (and very interesting) conversation about how to handle problems in companies.  The summation is:

  • it's not a problem with someone else's company that someone else needs to fix - it's a problem with our company that we need to fix.  The difference in language is essential.
  • don't just point out problems, also come up with solutions
  • make a plan for implementing the solution, and offer to lead the team yourself
  • attach a cost to what you are doing now, and a cost for implementing the solution, so that management will know why it is important
  • if you are given the tasks, report regularly on the status and how close you are to the budget and the schedule
  • possibly look for other ways to use the solution to profit the company - i.e. move the solution from a cost saver to an income generator
Another option presented - just do it yourself without getting approval.  Send someone a memo when you're done.
This was an interesting tidbit:

I also work for a biotech but we're lucky enough to have a CEO who's a computer scientist so he knew the importance of IT. As such we have a rather larger IT dept which includes a software development team.

In order to show the bossesses that proper software maintenance/creation/validation procedures are important just explain what would the FDA or some other regulatory agency do to your collective bung holes if they were to probe deeper into your practices.

Mission critical data being handled by non-validated/non-documented software is just like having untrained people working with samples in the lab, it's a big no-no.

You need paperwork that supports your claim, start with all the areas where un-validated software is used, then add to that a second section explaining the cost of poorly planned development iterations. We work using monthly iterations and when we told the people responsible for the software in the field that an iteration cost about 30 000$ just in labor costs they started paying attention and making the lists of demands count, i.e. removing the superflueous demands (ex: "it would look nicer in blue" was replaced with "The standard deviation calculation should be done with X+1, not just X.")

August 25, 2008

Amusing / How Not to Advertise Websites at Baseball Stadiums


See here.

August 25, 2008

Snippets / Rails Sorting


I always have trouble formulating exactly how sorts should work on Rails controllers that are called from sortable_element.  Therefore, I created the following method for ApplicationController which helps out a lot:

  def sort_assoc_members(assoc, ary, position_method = :position)
ary.each_index do |ary_idx|
assoc.find(ary[ary_idx]).update_attributes(position_method => (ary_idx + 1))

Then, to use it, just create a sort action like this:

def reorder
sort_assoc_members(WhateverItem, params[:whatever_list])

This makes life much easier.

August 21, 2008

Amusing / Nerd Shopping


From xkcd:


August 20, 2008

Platforms / Go Gobo!


GoboLinux is trying new things in the filesystem hierarchy department (details here)  i think this is fantastic!  Linux definitely needs to do this, plus it needs to adopt OSX's bundle concept.

It looks like there is already some work in this area, but it surely needs to be extended and accepted by the Linux community.

August 13, 2008

Snippets / TinyMCE + Prototype AJAX + RAILS


NOTE - I have no idea why the formatting here is all messed up. It should be usable anyway since the snippets are fairly small

Using TinyMCE from Ruby on Rails is sometimes a bit tricky.  We tend to assume that all HTML components work the same - they can be added and removed at will.  However, TinyMCE components have to be explicitly added and removed - and as such they can be really painful.

In addition, TinyMCE components have to be saved back to the form in order to be serialized by Prototype (which is used by Rails for remote forms - remote_form_for, link_to_remote, etc.).

Therefore, I came up with the following, which doesn't completely remove the pain, but it at least eases it somewhat.  First of all, it modifies the Prototype library slightly to trigger a tinyMCE.triggerSave(true, true) every time a form is serialized (i.e. for remote forms and links).  Now you don't have to remember to do that anymore! Next, it provides a simple RJS helper to unregister/reregister TinyMCE editors when doing Ajax page manipulation in Rails.

Anyway, here are the steps:

Step 1

Put the following code into application.js:

//Register all TinyMCE instances on the page
function register_all_tiny_mce_editors() {
mode : "textareas",
theme : "advanced",
editor_selector : "editor"
//NOTE - if you have other registration functions, put them here, too.
//Unregister all TinyMCE instances on the page
function unregister_all_tiny_mce_editors() {
tinyMCE.triggerSave(true, true);
for(editor_id in tinyMCE.editors) {
editor_elem = $(editor_id);
if(editor_elem) {
editor = tinyMCE.editors[editor_id];
//Convince Prototype to do a TriggerSave anytime it is doing form serialization
var original_form_serialize_elements = Form.serializeElements;
Form.serializeElements = function(elements, gethash) {
try {
//Copy TinyMCE values back onto the regular form elements
tinyMCE.triggerSave(true, true);                
} catch(err) {
//Don't do anything - just means TinyMCE isn't loaded
return original_form_serialize_elements(elements, gethash);

Step 2

Put the following code into your layout:

<%# Modify this to wherever you put TinyMCE %>
<%= javascript_include_tag "tiny_mce/tiny_mce.js" %>
<script type="text/javascript">
mode : "textareas",
theme : "advanced",
editor_selector : "editor"
<%# Add/modify the init statement to include any other options you want  %>
<%# Be sure to use the same code as you used above in the register_all_tiny_mce_editors() function %>

Step 3

Now, put the following in application_helper.rb:

  def tmce_update(page, &block)
page << "unregister_all_tiny_mce_editors();"
page << "register_all_tiny_mce_editors();"

Step 4

Now, in all RJS files which could cause TinyMCE textareas to appear/disappear, you can do the following:

tmce_update(page) do
#Perform RJS operations which affect TinyMCE areas here 

And now all TinyMCE areas will start behaving for you!  Note that this ONLY works with RJS-based Ajax calls - it doesn't work if you use the :update parameter, but you shouldn't be using that anyway.  Always do Ajax updates with RJS!