Gems for Tick and Harvest APIs
April 15th, 2008
Simply Invoices now supports fetching your time data from Tick and Harvest. As previously mentioned I made a gem for Tick and now I’ve also made one for Harvest.
Installation
gem install tickspot-ruby
gem install harvest-ruby
The gems do not cover either of the APIs 100%. I implemented what I needed. If you need more, hack away!
Sources at github: Tick Ruby Gem and Harvest Ruby Gem.
Tickspot API Ruby Wrapper
April 12th, 2008
I’m investigating adding support for creating invoices from time logged in Tickspot to Simply Invoices. The first step of that is to write a ruby wrapper for their API. I’ve created a github project for that and am making it publicly available. You can find it at http://github.com/bricooke/tickspot-ruby. Hopefully someone finds it useful. Or even better, makes it more useful :)
To make it more accessible, it should probably be a gem :/ Baby steps.
Update 4/14/2008: It’s now a published gem. gem install tickspot-ruby
Rake task to remove all deleted files from git
April 9th, 2008
After shuffling some code around I found myself with a lot of files to remove from git. Instead of doing it by hand or trying to ensure a subdirectory is gone and use -r, I wrote this rake task:
desc "Remove removed files"
task :remove do
system("for i in $(git status | grep deleted | awk ‘{print $3}’); do git rm $i; done")
end
end
If you use sake, this task is available on pastie @ sake -T http://pastie.caboo.se/177861.txt
Aliasing http://localhost
January 11th, 2008
When working on multiple rails apps I’ve been annoyed that the URL field in the browser gets cluttered during autocomplete. My autocomplete for http://localhost:3000/ will have paths for each app I’ve worked on recently. Since the browser just sees them all as http://localhost:3000 it returs all the matches. Same problem for form auto-complete and 1password auto-complete.
There’s an easy way around this.
on a Mac or other *nix
Edit /etc/hosts and add one line per project. Here’s my /etc/hosts:
## # Host Database # # localhost is used to configure the loopback interface # when the system is booting. Do not change this entry. ## 127.0.0.1 localhost 127.0.0.1 cc 127.0.0.1 mlk 127.0.0.1 si 255.255.255.255 broadcasthost ::1 localhost fe80::1%lo0 localhost
cc, si and mlk are abbreviations for sites I’m currently working on. With this in place I continue to start rails as ./script/server and it listens on localhost port 3000. But now when I’m working on ‘cc’ I point my browser at http://cc:3000. This makes it such that all autocompletes are now only for the ‘cc’ app. I find it a great benefit for such little effort.
Windows
Updated 1/12/07
Andy Kim commented that the windows hosts file is at C:\WINDOWS\System32\Drivers\etc\hosts
Continually burnt by @reply_to
October 10th, 2007
This has bitten me a number of times. When sending mail through ActionMailer/rails, @reply_to is not a valid way to set the reply to address. You must
@headers["reply-to"] = reply_address
This just came up in a project where there was existing code that had @replyto = replyaddress. Until today, no one really cared that the reply-to field wasn’t being set since it was always just the sender. Then today I happily come along and changed it to something other than the sender. Took me too long to figure this out.
mybizexpenses Source Opened
June 27th, 2007
Earlier this week, someone asked if the source for mybizexpenses.com was available. At the time, it wasn’t. I’m now happy to say that it is.
Why?
I’m hopeful that this will make mybizexpenses more attractive to people who don’t want to host their expense info on the web. Those folks can now download the source and run it locally on their machine or on a private server of their choosing.
Where?
svn is at: svn://svn.roundhaus.com/roobasoft/mybizexpenses
You can browse the code at: https://roobasoft.roundhaus.com/projects/223-mybizexpenses
Is the hosted version going away?
Nope. That’s where my data is, so I have no plans to get rid of it.
Can I import the data I have stored from the hosted version?
Right now I have no export/import feature. If you want it, ask. Even better, write the code, submit a patch, and then ask me to deploy it ;)
What’s the license?
MIT. See the LICENSE file in the project dir.
Enjoy!
Note about hosting
I’m hosting the mybizexpenses sources on RoundHaus and am loving it. Jonathan Younger, the roundhaus developer, presented RoundHaus at a Boise Ruby Brigade meetup a couple months ago. At that time I got access to the beta and currently have five projects stored in RoundHaus, including the soon to be released Simply Invoices. Only the mybizexpenses project has annonymous access turned on.
RoundHaus is currently in a private beta. I’ll do a proper post on RoundHaus when it’s publicly available, but here are some things get out of it:
- continuous integration (works with rspec)
- nice visualization of code coverage (both at the whole project level and per file)
- ability to run tests against MySQL, SQLite3 or Postgres
- a gorgeous code browser
- equally gorgeous diffs
- super easy svn management (no more svnadmin command for me)
- Twitter notifications for my build status (add in twitterrific and you’ve got an awesome build notification system)
Most of the above features can be seen via the public website. Give it a look an be sure to sign up for the notification when RoundHaus is publicly available (I hear it’ll be soon).
mybizexpenses mentioned on The Rails Way
June 6th, 2007
mybizexpenses.com is mentioned in the latest entry of the always educational, “The Rails Way”. Jamis points out how I should be using named callbacks and a simple way to make a confusing function, well, not confusing.
The article is pretty short, but very handy. I didn’t know named callbacks existed.
I really love how much a lot of the high profile rails folks give back to the community via things like this.
If You Want It, It Probably Exists
May 2nd, 2007
I had the need to highlight some words in some text. I started digging for a plugin to do this and then just some ruby code. Then I finally typed ‘highlight’ into gotapi.com and found this function in ActionView::Helpers::TextHelper:
highlight(text, phrase, highlighter = '\1')
The lesson I learned (again) was to always check the docs first!
My First Plugin - uptime_generator
March 9th, 2007
After I posted my last entry I was chatting with Louie about it and he helped me realize it might be a good job for a generator. Having never created a plugin nor a generator before, I had some learnin’ to do. Well, that learnin’ happened. You can reap the benefits via
Then run:
Your app should now respond to /success.txt.
At this point you could deploy and point your favorite uptime svc at that URL, or you could open uptime_controller.rb and make the ‘success’ method more robust.
Enjoy!
Useful resources:
Explanation on creating a generator: http://wiki.rubyonrails.org/rails/pages/UnderstandingGenerators
Example generator: http://topfunky.net/svn/plugins/topfunky_power_tools/
I also peeked at the scaffold_resource generator from rails proper.