- Start a Sinatra server on port 4000
- GET / to that server triggers a
git pull
and mod_rails restart - Hit port 4000 locally after pushing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$("form input[name=_method][value=delete]").parents("form").submit(function (event){ | |
if(!confirm("Are you sure?")) { | |
event.preventDefault(); | |
} | |
}); | |
// Throw this into a rails-app with jquery present and it'll ask you before you delete something. | |
// I'd much rather implement a "delete, then offer undo" pattern, sometimes you have to go for the quick win though. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ϟ macruby demo.rb | |
undefined method `gem' for main:TopLevel (NoMethodError) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Run the given block +num+ times and then print out the mean, median, min, | |
# max, and stddev of the run. For example: | |
# | |
# irb> stats(10) { sleep(rand / 100) } | |
# mean: 5.99ms | |
# median: 6.76ms | |
# min: 1.49ms | |
# max: 9.28ms | |
# stddev: 2.54ms | |
def stats(num) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Run the given block +num+ times and then print out the mean, median, min, | |
# max, and stddev of the run. For example: | |
# | |
# irb> stats(10) { sleep(rand / 100) } | |
# mean: 5.99ms | |
# median: 6.76ms | |
# min: 1.49ms | |
# max: 9.28ms | |
# stddev: 2.54ms | |
def stats(num) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
A few things left to do: | |
* Ability to add default options for each PDF, rather than having to pass it to each generate_* method call | |
* Doesn't check if the pdf already exists. By default, which should it do? | |
- Overwrite the existing file. Let your users decide what they'd like to do here. | |
* Consider the inclusion of css, or even generated css templates using pre existing libraries (lesscss or yerk – sass.) | |
Anything else? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bash-3.2$ rvm 1.8.7%rbx ; gem install rake --trace | |
ERROR: While executing gem ... (OptionParser::InvalidOption) | |
invalid option: --trace | |
bash-3.2$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://ujihisa.blogspot.com/2009/06/rubygems-best-practice.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uninitialized constant Encoding (NameError) | |
/Users/ben/.gem/ruby/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:443:in `load_missing_constant' | |
/Users/ben/.gem/ruby/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:80:in `const_missing' | |
/Users/ben/.gem/ruby/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:92:in `const_missing' | |
/Users/ben/.gem/ruby/1.8/gems/sqlite3-0.0.3/lib/sqlite3/encoding.rb:9:in `find' | |
/Users/ben/.gem/ruby/1.8/gems/sqlite3-0.0.3/lib/sqlite3/database.rb:69:in `initialize' | |
/Users/ben/.gem/ruby/1.8/gems/activerecord-2.3.4/lib/active_record/connection_adapters/sqlite3_adapter.rb:13:in `new' | |
/Users/ben/.gem/ruby/1.8/gems/activerecord-2.3.4/lib/active_record/connection_adapters/sqlite3_adapter.rb:13:in `sqlite3_connection' | |
/Users/ben/.gem/ruby/1.8/gems/activerecord-2.3.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:223:in `send' | |
/Users/ben/.gem/ruby/1.8/gems/activerecord-2.3.4/lib/active_record/connection_adapter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Use on_change :property { # do stuff here } | |
# to make changes to models after a property has been changed | |
module OnChange | |
def on_change(attribute, &block) | |
after_save do | |
block.call if send("#{attribute}_changed?") | |
end | |
end | |
end |