What we're listening to:
Jared

The Hold Steady:
Heaven Is Whenever
Jeff

Paper Route:
Absence

all day events in event calendar

December 10th, 2009

Some events don’t start and stop at specific times, but instead last all day. We’ve had this option when creating events in our application(s), but until now it wasn’t visually apparent when shown in EventCalendar, a rails plugin.

Now we have a new use_all_day option!

When set to true, the plugin checks if the event is all day and/or multiple days. If it is, then it will display with the usual background color bar. Otherwise it just shows the event text using its color. (Similar to many popular calendar programs.)

For more info check out: the screenshot, homepage, and github (commit).

The Event Calendar rails plugin (see: post & github) we created a few months back has been working great and, thanks to all the feedback, the bugs have pretty much been worked out. There was one annoying limitation, however:

The width couldn’t be set arbitrarily.

Well, no longer. I completely re-wrote the HTML and CSS styling that the helper generates. Events are now table columns which span the calendar days. The calendar grid is also a table, not a background image which needed to be created whenever setting a non-default width.

This means you can give the calendar any width, or don’t set it at all and let it resize to it’s containing element. Awesome!

I also took the opportunity to remove some old code, comments, and options that were hanging around from the plugin’s previous lives. In some ways there is now more flexibility to customize, in a few ways less. One consequence is that some of the options from before the rewrite no longer exist, so update with care.

Overall I’m very happy with how it turned out. Enjoy!

Event Calendar Rails Plugin

July 23rd, 2009

For a recent project we needed to show events on a calendar. The existing Rails plugins we tried didn’t allow us to satisfactorily show multiple, overlapping events across calendar days and rows.

I found the same complaint here and began to adapt it to our needs.

I’ve extracted the result and put it on github in the hopes that others might find it useful and/or add improvements.

http://github.com/elevation/event_calendar

The above link has more details, as well as how to install and use the plugin.

Here’s the 1000 word screenshot:

Event Calendar Screenshot

Using the use_all_day option:

Event Calendar using all day option

PLEASE:

Thanks and enjoy!

amend git commit

February 4th, 2009

Thanks to the beauty of local git repositories, I no longer worry about committing. So what if things aren’t pretty, its just a snapshot of my work in progress.

When I push to remote, however, its a good idea to clean up these commits. Up till now I’ve been using git rebase -i which, while very handy, can be a bit of overkill for my normal workflow.

Instead I can use

git commit --amend

to squash my new changes into the latest commit. This is what I’ve usually been doing with rebase -i anyways.

And making a new git alias removes the extra typing.

Git ‘R done

I’m liking paperclip, in a recent project I chose it specifically because it buffers writes on uploads, which should help keep memory usage down.

I needed to validate that an uploaded image was at least a certian size, and it was a little tricky, but here’s what I came up with:

 has_attached_file :image,
                   :styles => { :original => ["1000x600>", :jpg]},
                   :whiny_thumbnails => true

 def validate
    dimensions = Paperclip::Geometry.from_file(self.image.queued_for_write[:original])
    self.errors.add(:image, "Please upload a file at least 700 pixels wide") if dimensions.width < 700
    self.errors.add(:image, "Please upload a file at least 200 pixels tall") if dimensions.height < 200
  end

like it? hate it? have something better?

redmine and git

January 15th, 2009

Over the last few months, I’ve become a big fan of Redmine. It’s just what I was looking for when I was tired of setting up a TRAC for each project but missed the source code integration when we were using Basecamp. Redmine doesn’t look very pretty at first, but there’s some good themes (we use the basecamp inspired theme) that make it much better.

When we started using git, it brought some new issues up with our workflow and redmine, and we’re not the only ones . Some people are just changing and making the repository on their redmine server their “central” repository, but our redmine is hosted locally, and our repositories for each project are hosted on the deployment machine. This causes some problems because the redmine repo doesn’t receive updates.

There’s a plugin aimed at solving this, but it’s not functional yet. We solved it with a quick hack to run a git pull before redmine brings in new information from the repository:

Index: app/models/repository/git.rb
===================================================================
--- app/models/repository/git.rb (revision 2251)
+++ app/models/repository/git.rb (working copy)
@@ -36,6 +36,7 @@
end

def fetch_changesets
+ scm.fetch
scm_info = scm.info
if scm_info
# latest revision found in database
Index: lib/redmine/scm/adapters/git_adapter.rb

===================================================================
--- lib/redmine/scm/adapters/git_adapter.rb (revision 2251)
+++ lib/redmine/scm/adapters/git_adapter.rb (working copy)
@@ -24,6 +24,11 @@

# Git executable name
GIT_BIN = "git"
+
+ def fetch
+ cmd="#{GIT_BIN} --git-dir #{target('')} --bare fetch"
+ shellout(cmd)
+ end

# Get the revision of a particuliar file
def get_rev (rev,path)

Simple, but functional. Give us a shout if this helps you or if you have a better solution.

rspec+rcov = segfault death

November 14th, 2008

I was pounding my head against the keyboard. Rspec with rcov was crashing whenever it felt like it. I was getting all kinds of errors like:

/opt/local/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/matchers/be.rb:92: [BUG] rb_gc_mark(): unknown data type 0×0(0×489ffc8) non object
ruby 1.8.6 (2007-09-24) [i686-darwin9.3.0]

opt/local/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/example/example_group_methods.rb:344: [BUG] Segmentation fault
ruby 1.8.6 (2007-09-24) [i686-darwin9.3.0]

not to mention a bus error or two as well.

Then I found this article with this solution:

$ gem sources -a http://gems.github.com (you only have to do this once)
$ sudo gem install mergulhao-rcov

from this guy.

Then the world was right again.

giving back

October 17th, 2008

Recently I had a need to implement an on-demand payment model with a payment processor (Cybersource). I use the Active Merchant plugin for transaction operations almost exclusively, and nobody had added support for Cybersource subscriptions or on demand payments. So I implemented it myself over the last couple days, and published the code on github .

Currently it supports creating subscriptions, updating subscriptions (which is also how you cancel), and preforming a purchase (auth+capture) via subscription. I’m willing to implement other things like credits, straight auths and captures if there’s a community need. There’s not much in the way of docs yet (like most of Active Merchant), but it’s working for me. I’d also be willing to write a post on using the features I added, just drop a not in the comments if you would like to see that.

I’ll be submitting a patch soon, and hopefully this will get pulled into the official ActiveMerchant repository. This is the first real open source contribution we’ve made at ELEVATION (most things we need we find are already done), and it feels good to give back. You should try it.

getting git

October 15th, 2008

I’ve been hesitant to explore git since subversion was (I thought) really handling all my needs just fine. Why waste time learning another version control workflow?

Over time, I started to realize there were things about git that would be really nice, like nice branching and merging in particular, but I thought, that’s for some day when I have time to learn it, or my pain becomes too great with branches (which I don’t use that often in svn).

Just a couple days ago I needed to extend some code that was hosted on github, so I forked it, cloned it, and just started to work. In that process I’m discovering things that are just making git start to click. Whoops, didn’t mean to commit that yet: git-reset. I need to pull in some other changes, but can’t yet because I have uncommitted changes: git-stash.

Combined with the git bundle for textmate, I’m actually having fun learning git.

Moral: Try new stuff (in a real-life scenario), it’s fun and can make your life better.

OpenSource Court Ruling

August 15th, 2008

The U.S. Court of Appeals for the Federal Circuit ruled that licenses used for OpenSource projects can be enforceable under copyright law.

Here are some excerpts from the summary document published by the Court:

… Open Source software projects invite computer programmers from around the world
to view software code and make changes and improvements to it. Through such
collaboration, software programs can often be written and debugged faster and at lower
cost than if the copyright holder were required to do all of the work independently. In
exchange and in consideration for this collaborative work, the copyright holder permits
users to copy, modify and distribute the software code subject to conditions that serve to
protect downstream users and to keep the code accessible …

… Traditionally, copyright owners sold their copyrighted material in exchange for
money. The lack of money changing hands in open source licensing should not be
presumed to mean that there is no economic consideration, however. There are
substantial benefits, including economic benefits, to the creation and distribution of
copyrighted works under public licenses that range far beyond traditional license royalties.
For example, program creators may generate market share for their programs by providing
certain components free of charge. Similarly, a programmer or company may increase its
national or international reputation by incubating open source projects. Improvement to a
product can come rapidly and free of charge from an expert not even known to the
copyright holder …

… Generally, a copyright owner who grants a nonexclusive license to use his copyrighted material waives his right to sue the licensee for copyright infringement and can sue only for breach of contract. If, however, a license is limited in scope and the licensee acts outside the scope, the licensor can bring an action for copyright infringement …

Source: Jacobsen v. Katzer Appeals Summary

Copyright holders who engage in open source licensing have the right to control the
modification and distribution of copyrighted material. A copyright holder can grant the right to make certain modifications, yet retain his right to prevent other modifications.

This decision is important because it reduces the legal uncertainty regarding OpenSource rights and will make it a more attractive option for software development and OpenSource distribution models.

Elevation continues to support the OpenSource ideology. Litigation about OpenSource is rare
so it’s good to have this legal precedent on the books. August 2008 will likely be looked back on as the start of the next wave of OpenSource collaboration.