heroku sinatra

install http://code.google.com/p/msysgit/

tortoisgit does not work for heroku

application error!

heroku logs
application error `require’: no such file to load — sinatra

create .gems file

source ‘http://rubygems.org’
gem ‘sinatra’

—–> Installing gem gem from http://rubygems.org
ERROR: Could not find a valid gem ‘gem’ (> 0) in any repository
! Heroku push rejected, failed to install gem

update .gems file

source ‘http://rubygems.org’

—–> Installing gem sinatra from http://rubygems.org
Successfully installed tilt-1.3.3
Successfully installed sinatra-1.2.6
2 gems installed

hello world!

signal to noise ratio in code

Finding the Signal-to-Noise Ratio in the Never-Ending Language Debate

不知是在哪儿看到的八signal to noise的说法用在code里面



其实现在天天搞的东西就是提高信号里的signal to noise ratio


word automation table

#vb_ref: Function Add(Range As Range, NumRows As Long, NumColumns As Long, [DefaultTableBehavior], [AutoFitBehavior]) As Table

def add_table(doc, range, rows, cols)

doc.Tables.Add({‘Range’ => range, ‘NumRows’ => rows, ‘NumColumns’ => cols})

# doc.Tables.Add(range, rows, cols)



#vb_ref: Function Cell(Row As Long, Column As Long) As Cell

def set_table_cell(table, i, j, text)

table.Cell(i, j).Range.Text = text



word automation range

The Range object represents a contiguous area in a document, and is defined by a starting character position and an ending character position.

Ranges can be obtained in many ways. Many Word objects, like Sentence and Paragraph, have a Range property that contains an object reference to a Range object for the original object.

sel_range = word.Selection.Range

p_range = doc.Paragraphs(3).Range


word object model overview

Automating word with ruby: the range object

Automating Microsoft Word


.Linux Journal: Opinions on Opinionated Software

DH: Ruby is, more than anything else, a language for writing beautiful code that make programmers happy.

Rails, then, is an attempt to mold the beauty and productiveness of Ruby into a solution for Web applications. We’ve sought to adhere to the same core principle that guided the development of Ruby: make the programmer happy!

This might all sound mighty fluffy, but only until you recognize that the single-most important factor in programmer productivity is motivation. And, happy programmers are certainly motivated programmers. Thus, if you optimize for happiness, you’re optimizing for motivation, which ultimately leads to an optimization for productivity.

LJ: What is Rails? Why was it developed?

DH: Rails is an extraction from a solution to a real problem. It’s not a science project. It’s not something clever men sat down and designed in the highest of ivory towers. It’s simply the generic pieces that were left after I tried to use Ruby to create Basecamp– the Web-based project management system from 37singals.

That means it’s a very pragmatic, very targeted framework with a strong sense of direction. You might not share its vision, but it undeniably has one. I like to call that opinionated software. And Rails sure has a lot of opinions.

From one point of view, it could be said to be the collection of opinions I have about how Web applications should be constructed. Surely you can use Ruby on Rails without sharing all my opinions on how to create Web applications, but the more opinions you share, the less work is put upon you.

And, these opinions are surprisingly simple. Thay aim to give most people most of what they want, most of the time. It’s a strong disagreement with the conventional wisdom that everything should be configurable, that the framework should be impartial and objective. In my mind, that’s the same as saying that everything should be equally hard.