-
Notifications
You must be signed in to change notification settings - Fork 0
/
notes
105 lines (81 loc) · 6.65 KB
/
notes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
http://www.slideshare.net/cowboyd/the-ruby-racer-under-the-hood
cxt = V8::Context.new
cxt.eval('7 * 6') # => 42
cxt.eval('Object') # => function Object() { [native code] }
call javascript from ruby
eval() call js code directly
Square = cxt.eval(<<-JS)
(function Square(lenght) {
this.length = length
this.area = function() {
return this.length * this.length
}
})
JS
square = Square.new(10)
square.area() # => 100
call rubycode from javascript
class Dog
def bark(times = 1)
"woof!" * times
end
end
cxt['rover'] = Dog.new
cxt.eval('rover.bark(2)') # => woof!woof!
call ruby embed classes
cxt['Dog'] = Dog
cxt.eval(<<-JS)
dog = new Dog()
dog.bark(2) // => "woof!woof!"
JS
pg is required for heroku
bundle install --without production
heroku logs
git push heroku master
heroku open
[uli@zero butter_pecan]$ rails console
Loading development environment (Rails 3.2.5)
irb(main):001:0> ComicStrip.find(2).content
ComicStrip Load (2.3ms) SELECT "comic_strips".* FROM "comic_strips" WHERE "comic_strips"."id" = ? LIMIT 1 [["id", 2]]
=> "{\"title\":\"test #5 title\",\"scenes\":[{\"image\":\"http://data.whicdn.com/images/28004661/28314-my-little-pony-ponies-cartoon-cartoons_thumb.jpg\",\"lines\":[{\"text\":\"scene1: this is a sentence.\"}]},{\"image\":\"http://data.whicdn.com/images/22406409/1307359906084_0_large.gif\",\"lines\":[{\"text\":\"scene2: this is the first sentence.\"},{\"text\":\"scene2: this is the second sentence\"}]},{\"image\":\"http://static.fjcdn.com/pictures/MLP_71e96f_2216427.jpg\",\"lines\":[{\"text\":\"scene3: this is the first sentence.\"},{\"text\":\"scene3: this is the second sentence.\"},{\"text\":\"scene3: this is the third sentence.\"}]}]}"
1.9.2p323 :003 > strip = ComicStrip.find(1)
ComicStrip Load (0.3ms) SELECT "comic_strips".* FROM "comic_strips" WHERE "comic_strips"."id" = ? LIMIT 1 [["id", 1]]
=> #<ComicStrip id: 1, title: "test", content: "{\"title\":\"test #5 title\",\"scenes\":[{\"image\":\"http:/...", created_at: "2012-06-14 19:52:46", updated_at: "2012-06-14 20:19:31">
1.9.2p323 :004 > strip.content
=> "{\"title\":\"test #5 title\",\"scenes\":[{\"image\":\"http://data.whicdn.com/images/28004661/28314-my-little-pony-ponies-cartoon-cartoons_thumb.jpg\",\"lines\":[{\"text\":\"scene1: this is a sentence.\"}]},{\"image\":\"http://data.whicdn.com/images/22406409/1307359906084_0_large.gif\",\"lines\":[{\"text\":\"scene2: this is the first sentence.\"},{\"text\":\"scene2: this is the second sentence\"}]},{\"image\":\"http://fc08.deviantart.net/fs71/f/2012/143/f/d/mmm_delicioso_by_racul-d50v0u4.jpg\",\"lines\":[{\"text\":\"scene3: this is the first sentence.\"},{\"text\":\"scene3: this is the second sentence.\"},{\"text\":\"scene3: this is the third sentence.\"}]}]}"
>> [uli@zero butter_pecan]$ heroku rake db:version
WARNING: `heroku rake` has been deprecated. Please use `heroku run rake` instead.
Running `rake db:version` attached to terminal... up, run.1
DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/Rakefile:7)
DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/Rakefile:7)
DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/Rakefile:7)
Connecting to database specified by DATABASE_URL
Current version: 0
[uli@zero butter_pecan]$ rake db:version
Current version: 20120609040206
[uli@zero butter_pecan]$ heroku rake --trace db:migrate
WARNING: `heroku rake` has been deprecated. Please use `heroku run rake` instead.
Running `rake --trace db:migrate` attached to terminal... up, run.1
DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/Rakefile:7)
DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/Rakefile:7)
DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/Rakefile:7)
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Invoke rails_env (first_time)
** Execute rails_env
** Execute db:load_config
Connecting to database specified by DATABASE_URL
** Execute db:migrate
Migrating to CreateComicStrips (20120609040206)
== CreateComicStrips: migrating ==============================================
-- create_table(:comic_strips)
-> 0.0965s
== CreateComicStrips: migrated (0.0967s) =====================================
** Invoke db:_dump (first_time)
** Execute db:_dump
** Invoke db:schema:dump (first_time)
** Invoke environment
** Invoke db:load_config
** Execute db:schema:dump