May 20, 2008

fucking yes….

thyis works for onphile publishers:

require ‘rubygems’
require ‘scrubyt’

onphile_publisher_data = Scrubyt::Extractor.define do
fetch(“http://www.onphile.com/search/ajax_searchagain.asp?searchtype=publisher”)

onphile_data “/html/body/select[@id=’selectcpid’]/” do
publisher “//option” do
publisher_name “/”
onphile_id “value”, :type => :attribute
end
end
end

puts onphile_publisher_data.to_xml

Example:

# Controller
class BlogController

By default, auto_complete_for limits the results to 10 entries,
and sorts by the given field.

auto_complete_for takes a third parameter, an options hash to
the find method used to search for the records:

auto_complete_for :post, :title, :limit => 15, :order => ‘created_at DESC’

For more examples, see script.aculo.us:
* http://script.aculo.us/demos/ajax/autocompleter
* http://script.aculo.us/demos/ajax/autocompleter_customized

Copyright (c) 2007 David Heinemeier Hansson, released under the MIT license

from onstartups.com:

Insanity? Why A Bootstrap Entrepreneur Raised $17 Million in Venture Funding

If you’ve been following OnStartups.com for any period of time, you likely know that I’m not a big advocate of startup founders going out and trying to raise venture funding in the early stages.

My argument boils down to two things:

1) Most folks don’t need venture funding in the early stages

2) the odds of first-time entrepreneurs actually raising VC is pretty low.

Oh, and 3) it’s one of the least fun activities an entrepreneur can take. Raising funding is often harder than building a product/business — and much less fun!

So, given my general disposition, it will come as a surprise to many that know me that my startup, HubSpot, announced today that it has closed a Series B round of funding of $12 million. This is in addition to the $5 million Series A funding we raised less than a year ago. So, the total capital raised is now over $17 million. The news was big enough that TechCrunch wrote about HubSpot today.

So, back to the question. Why would a seemingly reasonable and modestly successful bootstrap entrepreneur raise venture funding of this magnitude?

Insanity? Maybe…

How A Bootstrap Entrepreneur Winds Up Raising $17 Million In Venture Funding

1. I seed funded HubSpot with $500,000. To do this, I used some of the proceeds from the sale of my prior startup (which I had bootstrapped with $10,000). The seed funding was an easy decision, because I mostly had to convince myself, and I’m pretty convincing when I talk to myself.

2. The seed funding was enough to build our SaaS product for internet marketing and get it out into the market (i.e. start charging real companies real money to use to it). People bought it. Sure, the product was “pre-alpha” and crappy, but it was useful. We also improved it every day (literally) so it got less and less crappy over time. More and more people bought. This gave us some evidence that there was actually some sort of market demand out there. Interesting.

3. The fact that things were headed in the right direction led us to raise another $1 million in angel funding. For us, that was a fair amount of money (we’re capital efficient). Raising the angel funding was reasonably efficient because we had the inside track. The fact we had paying customers was helpful. So, no we’re up to $1.5 million in capital raised. Cash in the bank. Life is good.

4. Then, the VC community starts to get interested in HubSpot (this is weeks after we have our angel funding finalized). “Not really interested,” we say. We’ve got a $1 million of fresh cash in the bank. We don’t need VC money. As it turns out, one of the best times to raise venture funding is when you don’t need the money.

5. My co-founder, Brian Halligan and I have lots of interesting discussion and debate. We’d both debated the whole VC thing while grad students at MIT (where we met). For HubSpot, we had confidence that the market opportunity was big enough to warrant venture-funding, we just didn’t think we needed it quite yet. (This is June-ish of 2007). But, we knew we were on to a potentially really big idea. We’d both made some money and weren’t really looking for a “modest outcome”. We wanted a big, significaint, immodest outcome. So, on the VC front, we figured with the right set of terms and the right partner, we’d consider raising it sooner rather than later. We got the right set of terms and the right partner. So, we raised another $4 million in VC bringing our “Series A” to $5 million. We’re off to the races.

6. We did what I think is the best possible thing a startup can do with lots of cash: Not spend it too quickly. No advertising, no marketing, no high-flying salaries for high-flying executives. We hired the smartest, most passionate people we could find. People we knew and respected immensely. People fanatically focused on building a real business and who were constitutionally incapable of spending money willy-nilly. We behaved a lot like we were spending our own money. Because, we were. [Note to self: Write a future article about why VC money is as much yours, once you’ve given up the equity to get it].

7. Life is good. Sales are ramping steadily. Every month is a record month. Not in terms of visitors, eyeballs or some other proxy for future revenues, but in terms of actual revenues. The business is growing fast. By the time we officially launch the product in November, 2007, we have 100+ paying customers.

8. As it turns out, success attracts more capital. We started getting some “pre-emptive” interest in the company from VCs. “We don’t need more money right now,” we say. We hadn’t even spent half of the last round and lots of cash in the bank. But, we’re practical guys and willing to listen. As it turns out, one of the best times to raise venture funding is when you don’t need the cash… (see point #4 above).

Fast-forward to today: We’ve closed a $12 million Series B round.

But, seriously, why did I raise VC funding? Did I change my mind?

The simple answer is no, I have not changed my mind on VC. I still don’t think most early-stage entrepreneurs should go out on the venture fund-raising circuit. They should maintain the option of a modest exit. Focus on solving the customer’s problem (not the VC’s problem). My situation with HubSpot was special. I had already done the bootstrap thing (multiple times) and made money. I had above average odds of raising money for HubSpot.

So, why did I raise funding? Because, this time around I wanted to take a shot at the big leagues. Sure, any success (even a modest one) is nice. But a modest success is not going to change my life much at this point. I want to swing hard. It’s not about the money. It’s about the fun and excitement of pursuing a really big idea, working with really smart people and doing what I love. [And, of course, the money won’t hurt either]

And that, my friends, is why I raised $17 million in venture funding.

If you have questions, feel free to ask them. I’ll do my best (within reason) to answer them. Otherwise, I’ll keep you posted with future articles as things progress.

Starting Out in Life

Didn’t read yet, but most definitely something to read. I love this guy’s blog and his writing and perspective is seriously top quality..

http://zenhabits.net/2008/05/a-letter-to-my-son-on-starting-out-in-life/

require ‘rubygems’
require ‘scrubyt’

Scrubyt.logger = Scrubyt::Logger.new
sony_data = Scrubyt::Extractor.define do
fetch ‘http://www.stashmycomics.com/html/searchpreresults.asp?p=54&st=&t=&i=%&r=%&w=%&a=%&pr=0&f=0&view=500’

comic_titles “#/html/body/div[@id=’body’]/form[@id=’categoryDisplay’]/fieldset/table[@id=’catResults1’]/tbody/tr” do
publisher “//td[1]”
title “//td[2]”
issues “//td[3]”
end
end

sony_data.to_xml.write($stdout, 1)

May 19, 2008

make_resourceful
Take back control of your Controllers. Make them awesome. Make them sleek. Make them resourceful.

REST is a fine pattern for designing controllers, but it can be pretty repetitive. Who wants to write out the same actions and copy the same model lookup logic all over their application?

make_resourceful handles all that for you. It sets up all your RESTful actions and responses with next to no code. Everything has full, sensible default functionality.

Of course, no controller only uses the defaults. So make_resourceful can be massively customized, while still keeping your controllers trim and readable.
Get it!

Rails

$ ruby script/plugin install http://svn.hamptoncatlin.com/make_resourceful/trunk
$ mv vendor/plugins/trunk vendor/plugins/make_resourceful

Subversion

$ svn co http://svn.hamptoncatlin.com/make_resourceful/trunk make_resourceful

Use it!

The easiest way to start with make_resourceful is to run the resource_scaffold generator. It uses the same syntax as the Rails scaffold_resource generator:

$ script/generate resource_scaffold post title:string body:text

It does, however, require Haml. You are using Haml, right? No? I’ll wait here while you go fall in love with it.

If you want to try make_resourceful on one of your current controllers, just replace the mess of repetition with this:

class FooController “created_at DESC”, :page => {:current => params[:page], :size => 10 } )
end

What if I want to do something in the middle of an action?

before :show, :index do
@page_title = “Awesome!”
end

after :create_fails do
@page_title = “Not So Awesome!”
end

What about all of my awesome respond_to blocks for my XML APIs and RJS responses?

response_for :show do |format|
format.html
format.js
format.xml
end

response_for :update_fails do |format|
format.html { render :action => ‘edit’ }
format.json { render :json => false.to_json, :status => 422 }
end

So I guess I have to write responses for all my actions?

Nope! make_resourceful makes them do the right thing by default. You only need to customize them if you want to do something special.
Seriously?!

Yes!
Grok it!
make_resourceful the Method

The make_resourceful block is where most of the action happens. Here you specify which actions you want to auto-generate, what code you want to run for given callbacks, and so forth.

You also use the block to declare various bits of information about your controller. For instance, if the controller is nested, you’d call belongs_to. If you wanted to expose your models as some sort of text format, you’d call publish.

Check out the documentation of Resourceful::Builder for more information on the methods you can call here.
Helper Methods

make_resourceful provides lots of useful methods that can be used in your callbacks and in your views. They range from accessing the records you’re looking up to easily generating URLs for a record to getting information about the action itself.

Two of the most useful methods are current_object and current_objects (note the subtle plurality difference). current_objects only works for index, and returns all the records in the current model. current_object works for all actions other than index, and returns the record that’s currently being dealt with.

The full documentation of the helper methods is in Resourceful::Default::Accessors and Resourceful::Default::URLs.
Overriding Methods

Not only are helper methods useful to the developer to use, they’re used internally by the actions created by make_resourceful. Thus one of the main ways make_resourceful can be customized is by overriding accessors.

For instance, if you want to only look up the 10 most recent records for index, you’re override current_objects. If you wanted to use a different model than that suggested by the name of the controller, you’d override current_model.

When you’re overriding methods that do SQL lookups, though, be a little cautious. By default, these methods cache their values in instance variables so that multiple SQL queries aren’t run on multiple calls. When overriding them, it’s wise for you to do the same. For instance,

def current_object
@current_object ||= current_model.find_by_name(params[:name])
end

For More Information…

Haven‘t found all the information you need in the RDoc? Still a little confused about something? Don‘t despair, there are still more resources available!

* Nathan Weizenbaum periodically makes blog posts about new features and versions of make_resourceful. They may be a little outdated, but they should still be useful and explanatory.
o On Resourceful::Builder#publish and Resourceful::Serialize: here and here.
o An overview of make_resourceful 0.1.0: here.
* There’s an excellent, active Google Group (link) where people will be happy to answer your questions.
* Read the source code! It’s very straightforward, and make_resourceful is built to encourage overriding methods and hacking the source.

Copyright 2007 Hampton Catlin, Nathan Weizenbaum, and Jeff Hardy.

Contributions by:

* Cristi Balan
* Mike Ferrier
* James Golick
* Don Petersen
* Alex Ross
* Tom Stuart

RAILS MAKE_RESOURCEFUL PLUGIN LOOKS INTERESTING FOR SCAFFOLDING CONTROLLER FUNCTIONALITY DYNAMICALLY (i think, probably based on model data too, right?)….

anyway this link is to the rdoc:
http://mr.hamptoncatlin.com/

script/generate migration AddCollectionListsAndInventoryItems

add to assocations to user model:

has_many :user_roles
has_many :roles, :through => :user_roles

Clicky Web Analytics