Folk Programming
    with Ruby
    ( Web Application )




        mootoh
Folk ?
Fork




×      by tetzl
Fork Ball




×           by capn madd matt
Forksuke




×  http://foxkeh.jp/downloads/materials/
Folk Programming !

•Like Folk Song
• Programming
 Casually

                      by Rich Moffitt
Importance


• Introduced at
• see DK
 •   http://blog.livedoor.jp/dankogai/archives/51052844.html
More
Folks !
Folkish Trends
  BASIC              CGI
                                       Web
                                     Ap...
But...
Yet Another Fun
       in
none Web App !
Why
 none
Web App ?
Everyone playing in
    Web App




            by cobalt123
Diversity
Explore
     Rich
User Experience
Fun for Me !




           by allfr3d
My
Recommendation
Plug-in


     by Darren Hester
Why Plug-in ?




          by imjustincognito
Easier than
 creating
Great App
Like Remora
Lower
Hurdle
But...
Seems difficult...




          by an untrained eye
No!
Use Ruby !
4 Examples
Safari
       +
Hatena Bookmark

              RubyCocoa++
def addEntry(entry)
    bmk = OSX::NSEntityDescription.objc_send(
      :insertNewObjectForEntityForName, 'Bookmark',
    ...
QuickSilver
    +
 Twitter

              RubyCocoa+++
class TwitterPluginAction < OSX::QSActionProvider
  # reload itself
  def reload
    Shared.logger.info('reloading ' + __F...
Aren’t they Web App ?
Quartz Composer
       +
     Gainer

              RubyCocoa++++
def execute_atTime_withArguments(context, time, args)
  unless @initialized
    4.times do |i|
      @gio.ain(i).on Funnel...
Vim + Refe
function! s:RubyRefe2(args)
  ruby << EOR
  bitclust_path = VIM::evaluate("s:bitclust_path")
  db_path       = bitclust_pa...
Why Ruby ?
Nice Glue.


    Between
Different Worlds.




                        by St. Murse
Debuggability

• Dynamic !
 • reload from plugin itself   def reload
                                 load ‘./itself.rb’

...
Conclusion
Create Something
Useful for You !
and Us !
out of Browser !
with Ruby !
Thank you.
                                                           mootoh@gmail.com
                                   ...
Upcoming SlideShare
Loading in …5
×

Ruby Kaigi 2008 LT

5,100 views

Published on

Folk Programming with Ruby

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
5,100
On SlideShare
0
From Embeds
0
Number of Embeds
8
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • Ruby&amp;#x3067;&amp;#x697D;&amp;#x3057;&amp;#x3080;&amp;#x30D5;&amp;#x30A9;&amp;#x30FC;&amp;#x30AF;&amp;#x30D7;&amp;#x30ED;&amp;#x30B0;&amp;#x30E9;&amp;#x30DF;&amp;#x30F3;&amp;#x30B0;
    Web&amp;#x30A2;&amp;#x30D7;&amp;#x30EA;&amp;#x3058;&amp;#x3083;&amp;#x306A;&amp;#x3044;&amp;#x3088;&amp;#x7DE8;
  • &amp;#x305D;&amp;#x3082;&amp;#x305D;&amp;#x3082;Folk&amp;#x3063;&amp;#x3066;&amp;#x306A;&amp;#x3093;&amp;#x3067;&amp;#x3057;&amp;#x3087;&amp;#x3046;&amp;#x3002;
  • &amp;#x30D5;&amp;#x30A9;&amp;#x30FC;&amp;#x30AF;&amp;#x3058;&amp;#x3083;&amp;#x3042;&amp;#x308A;&amp;#x307E;&amp;#x305B;&amp;#x3093;&amp;#x306D;&amp;#x3002;
  • &amp;#x30D5;&amp;#x30A9;&amp;#x30FC;&amp;#x30AF;&amp;#x30DC;&amp;#x30FC;&amp;#x30EB;&amp;#x3067;&amp;#x3082;&amp;#x306A;&amp;#x3044;&amp;#x3067;&amp;#x3059;&amp;#x3002;
  • &amp;#x3082;&amp;#x3061;&amp;#x308D;&amp;#x3093;&amp;#x30D5;&amp;#x30A9;&amp;#x30FC;&amp;#x30AF;&amp;#x30B9;&amp;#x30B1;&amp;#x3067;&amp;#x3082;&amp;#x3042;&amp;#x308A;&amp;#x307E;&amp;#x305B;&amp;#x3093;&amp;#x3002;
  • &amp;#x30D5;&amp;#x30A9;&amp;#x30FC;&amp;#x30AF;&amp;#x30BD;&amp;#x30F3;&amp;#x30B0;&amp;#x307F;&amp;#x305F;&amp;#x3044;&amp;#x306B;&amp;#x3001;&amp;#x8DA3;&amp;#x5473;&amp;#x3067;&amp;#x6C17;&amp;#x8EFD;&amp;#x306B;&amp;#x30D7;&amp;#x30ED;&amp;#x30B0;&amp;#x30E9;&amp;#x30DF;&amp;#x30F3;&amp;#x30B0;&amp;#x3092;&amp;#x697D;&amp;#x3057;&amp;#x3080;&amp;#x3053;&amp;#x3068;&amp;#x3067;&amp;#x3059;&amp;#x3002;
  • &amp;#x3053;&amp;#x306E;&amp;#x524D;&amp;#x306E;YAPC::ASIA&amp;#x306E;&amp;#x3068;&amp;#x304D;&amp;#x306B;&amp;#x3001;&amp;#x3053;&amp;#x306E;&amp;#x305F;&amp;#x3044;&amp;#x305B;&amp;#x3064;&amp;#x3055;&amp;#x304C;&amp;#x8A71;&amp;#x984C;&amp;#x306B;&amp;#x306A;&amp;#x308A;&amp;#x307E;&amp;#x3057;&amp;#x305F;&amp;#x3002;


    &amp;#x8A73;&amp;#x3057;&amp;#x304F;&amp;#x306F;&amp;#x3001;see &amp;#x30C0;&amp;#x30F3;&amp;#x30B3;&amp;#x30AC;&amp;#x30A4; &amp;#x3067;&amp;#x3002;
  • &amp;#x6C17;&amp;#x8EFD;&amp;#x306B;&amp;#x30D7;&amp;#x30ED;&amp;#x30B0;&amp;#x30E9;&amp;#x30DF;&amp;#x30F3;&amp;#x30B0;&amp;#x3092;&amp;#x306F;&amp;#x3058;&amp;#x3081;&amp;#x3066;&amp;#x307F;&amp;#x3088;&amp;#x3046;&amp;#x3088;!
  • &amp;#x6B74;&amp;#x53F2;&amp;#x3092;&amp;#x632F;&amp;#x308A;&amp;#x304B;&amp;#x3048;&amp;#x3063;&amp;#x3066;&amp;#x307F;&amp;#x308B;&amp;#x3068;&amp;#x3001;BASIC&amp;#x2192;CGI&amp;#x2192;&amp;#x3001;&amp;#x3044;&amp;#x307E;&amp;#x306F;Web&amp;#x30A2;&amp;#x30D7;&amp;#x30EA;&amp;#x304C;&amp;#x5168;&amp;#x76DB;&amp;#x3067;&amp;#x3059;&amp;#x306D;&amp;#x3002;
  • &amp;#x4ECA;&amp;#x65E5;&amp;#x3044;&amp;#x3061;&amp;#x3070;&amp;#x3093;&amp;#x8A00;&amp;#x3044;&amp;#x305F;&amp;#x3044;&amp;#x3053;&amp;#x3068;&amp;#x306F;&amp;#x3001;&amp;#x300C;Web&amp;#x30A2;&amp;#x30D7;&amp;#x30EA;&amp;#x3058;&amp;#x3083;&amp;#x306A;&amp;#x3044;&amp;#x3068;&amp;#x3053;&amp;#x306B;&amp;#x3082;&amp;#x697D;&amp;#x3057;&amp;#x3044;&amp;#x3053;&amp;#x3068;&amp;#x306F;&amp;#x305F;&amp;#x304F;&amp;#x3055;&amp;#x3093;&amp;#x3042;&amp;#x308B;&amp;#x3088;&amp;#x300D;&amp;#x3068;&amp;#x3044;&amp;#x3046;&amp;#x3053;&amp;#x3068;&amp;#x3067;&amp;#x3059;&amp;#x3002;
  • &amp;#x307F;&amp;#x3093;&amp;#x306A;Web&amp;#x30A2;&amp;#x30D7;&amp;#x30EA;&amp;#x3084;&amp;#x3063;&amp;#x3066;&amp;#x308B;&amp;#x3057;&amp;#x3001;&amp;#x3044;&amp;#x3063;&amp;#x3057;&amp;#x3087;&amp;#x306E;&amp;#x3053;&amp;#x3068;&amp;#x3084;&amp;#x3063;&amp;#x3066;&amp;#x3082;&amp;#x9762;&amp;#x767D;&amp;#x304F;&amp;#x306A;&amp;#x3044;&amp;#x3067;&amp;#x3059;&amp;#x3088;&amp;#x306D;&amp;#x3002;
  • &amp;#x591A;&amp;#x69D8;&amp;#x6027;&amp;#x3067;&amp;#x3059;&amp;#x306D;&amp;#x3002;
  • &amp;#x30E6;&amp;#x30FC;&amp;#x30B6;&amp;#x30A4;&amp;#x30F3;&amp;#x30BF;&amp;#x30FC;&amp;#x30D5;&amp;#x30A7;&amp;#x30A4;&amp;#x30B9;&amp;#x306E;&amp;#x5B9F;&amp;#x9A13;&amp;#x3068;&amp;#x304B;&amp;#x3002;
  • &amp;#x305D;&amp;#x3046;&amp;#x3044;&amp;#x3046;&amp;#x306E;&amp;#x3063;&amp;#x3066;&amp;#x697D;&amp;#x3057;&amp;#x304F;&amp;#x306A;&amp;#x3044;&amp;#x3067;&amp;#x3059;&amp;#x304B;?
  • &amp;#x3068;&amp;#x3044;&amp;#x3046;&amp;#x3053;&amp;#x3068;&amp;#x3067;&amp;#x3001;&amp;#x307C;&amp;#x304F;&amp;#x306E;&amp;#x304A;&amp;#x3059;&amp;#x3059;&amp;#x3081;&amp;#x306F;
  • &amp;#x30D7;&amp;#x30E9;&amp;#x30B0;&amp;#x30A4;&amp;#x30F3;&amp;#x3065;&amp;#x304F;&amp;#x308A;&amp;#x3067;&amp;#x3059;&amp;#x3002;
  • &amp;#x306A;&amp;#x3093;&amp;#x3067;&amp;#x30D7;&amp;#x30E9;&amp;#x30B0;&amp;#x30A4;&amp;#x30F3;&amp;#x306A;&amp;#x3093;&amp;#x3067;&amp;#x3057;&amp;#x3087;&amp;#x3046;&amp;#x3002;
  • &amp;#x30A4;&amp;#x30C1;&amp;#x304B;&amp;#x3089;&amp;#x3059;&amp;#x3054;&amp;#x3044;&amp;#x30A2;&amp;#x30D7;&amp;#x30EA;&amp;#x3092;&amp;#x3064;&amp;#x304F;&amp;#x308B;&amp;#x3088;&amp;#x308A;&amp;#x3082;&amp;#x624B;&amp;#x8EFD;&amp;#x3060;&amp;#x304B;&amp;#x3089;&amp;#x3002;
  • &amp;#x5C0F;&amp;#x5224;&amp;#x30B6;&amp;#x30E1;&amp;#x307F;&amp;#x305F;&amp;#x3044;&amp;#x306B;&amp;#x3001;&amp;#x89AA;&amp;#x30A2;&amp;#x30D7;&amp;#x30EA;&amp;#x306B;&amp;#x5BC4;&amp;#x751F;&amp;#x3059;&amp;#x308B;&amp;#x306E;&amp;#x3067;&amp;#x3001;&amp;#x4F7F;&amp;#x3063;&amp;#x3066;&amp;#x3082;&amp;#x3089;&amp;#x3048;&amp;#x3084;&amp;#x3059;&amp;#x3044;&amp;#x3067;&amp;#x3059;&amp;#x3002;
  • &amp;#x3064;&amp;#x307E;&amp;#x308A;&amp;#x3001;&amp;#x6577;&amp;#x5C45;&amp;#x304C;&amp;#x4F4E;&amp;#x3044;&amp;#x3068;&amp;#x3044;&amp;#x3046;&amp;#x3053;&amp;#x3068;&amp;#x3067;&amp;#x3059;&amp;#x3002;
    &amp;#x30D7;&amp;#x30ED;&amp;#x30B0;&amp;#x30E9;&amp;#x30DF;&amp;#x30F3;&amp;#x30B0;&amp;#x3092;&amp;#x59CB;&amp;#x3081;&amp;#x308B;&amp;#x306B;&amp;#x306F;&amp;#x3060;&amp;#x3044;&amp;#x3058;&amp;#x306A;&amp;#x3053;&amp;#x3068;&amp;#x3067;&amp;#x3059;&amp;#x3002;
  • &amp;#x305D;&amp;#x3046;&amp;#x306F;&amp;#x3044;&amp;#x3063;&amp;#x3066;&amp;#x3082;&amp;#x96E3;&amp;#x3057;&amp;#x3044;&amp;#x3093;&amp;#x3058;&amp;#x3083;&amp;#x306A;&amp;#x3044;&amp;#x306E;&amp;#x3001;&amp;#x3068;&amp;#x601D;&amp;#x308F;&amp;#x308C;&amp;#x308B;&amp;#x304B;&amp;#x3082;&amp;#x3057;&amp;#x308C;&amp;#x307E;&amp;#x305B;&amp;#x3093;&amp;#x3002;
  • &amp;#x3044;&amp;#x3048;&amp;#x3044;&amp;#x3048;&amp;#x3002;&amp;#x3061;&amp;#x304C;&amp;#x3046;&amp;#x3088;&amp;#x5168;&amp;#x7136;&amp;#x3061;&amp;#x304C;&amp;#x3046;&amp;#x3088;&amp;#x3002;
  • &amp;#x305D;&amp;#x3053;&amp;#x3067;Ruby&amp;#x3067;&amp;#x3059;&amp;#x3088;&amp;#x3002;
  • &amp;#x3044;&amp;#x304F;&amp;#x3064;&amp;#x304B;&amp;#x4F8B;&amp;#x3092;&amp;#x3002;
  • HTTP&amp;#x3084;&amp;#x30C6;&amp;#x30AD;&amp;#x30B9;&amp;#x30C8;&amp;#x51E6;&amp;#x7406;&amp;#x306F;Ruby&amp;#x3067;&amp;#x6163;&amp;#x308C;&amp;#x3063;&amp;#x3053;&amp;#x3067;&amp;#x3059;&amp;#x3088;&amp;#x306D;&amp;#x3002;
  • QSTwitter
  • &amp;#x30D5;&amp;#x30A9;&amp;#x30ED;&amp;#x30EF;&amp;#x30FC;&amp;#x306E;&amp;#x30EA;&amp;#x30B9;&amp;#x30C8;&amp;#x3092;&amp;#x4FDD;&amp;#x5B58;&amp;#x3059;&amp;#x308B;&amp;#x306E;&amp;#x306B;&amp;#x3001;Marshal.dump&amp;#x3092;&amp;#x3064;&amp;#x304B;&amp;#x3063;&amp;#x3066;&amp;#x307E;&amp;#x3059;&amp;#x3002;
    &amp;#x3068;&amp;#x3063;&amp;#x3066;&amp;#x3082;&amp;#x304A;&amp;#x624B;&amp;#x8EFD;&amp;#x3067;&amp;#x3059;&amp;#x306D;&amp;#x3002;
  • &amp;#x30D3;&amp;#x30B8;&amp;#x30E5;&amp;#x30A2;&amp;#x30EB;&amp;#x3067;&amp;#x30D5;&amp;#x30A3;&amp;#x30B8;&amp;#x30AB;&amp;#x30EB;&amp;#x3067;&amp;#x3059;&amp;#x306D;&amp;#x3002;
  • Ruby&amp;#x304C;Gainer&amp;#x306E;&amp;#x5236;&amp;#x5FA1;&amp;#x3068;QuartzComposer&amp;#x3068;&amp;#x3092;&amp;#x3064;&amp;#x306A;&amp;#x3052;&amp;#x3066;&amp;#x304F;&amp;#x308C;&amp;#x307E;&amp;#x3057;&amp;#x305F;&amp;#x3002;
  • Refe2.vim
  • Vim&amp;#x304B;&amp;#x3089;Ruby&amp;#x30B9;&amp;#x30AF;&amp;#x30EA;&amp;#x30D7;&amp;#x30C8;&amp;#x3067;BitCluset&amp;#x3092;&amp;#x76F4;&amp;#x63A5;&amp;#x547C;&amp;#x3093;&amp;#x3067;&amp;#x307E;&amp;#x3059;&amp;#x3002;
    VimScript&amp;#x3092;&amp;#x3042;&amp;#x307E;&amp;#x308A;&amp;#x899A;&amp;#x3048;&amp;#x306A;&amp;#x304F;&amp;#x3066;&amp;#x3082;&amp;#x6E08;&amp;#x307F;&amp;#x307E;&amp;#x3057;&amp;#x305F;&amp;#x3002;
  • &amp;#x3042;&amp;#x306A;&amp;#x305F;&amp;#x304C;&amp;#x697D;&amp;#x3057;&amp;#x3044;&amp;#x3001;&amp;#x306A;&amp;#x306B;&amp;#x304B;&amp;#x3092;&amp;#x3064;&amp;#x304F;&amp;#x308A;&amp;#x307E;&amp;#x3057;&amp;#x3087;&amp;#x3046;&amp;#x3002;
  • Ruby Kaigi 2008 LT

    1. 1. Folk Programming with Ruby ( Web Application ) mootoh
    2. 2. Folk ?
    3. 3. Fork × by tetzl
    4. 4. Fork Ball × by capn madd matt
    5. 5. Forksuke × http://foxkeh.jp/downloads/materials/
    6. 6. Folk Programming ! •Like Folk Song • Programming Casually by Rich Moffitt
    7. 7. Importance • Introduced at • see DK • http://blog.livedoor.jp/dankogai/archives/51052844.html
    8. 8. More Folks !
    9. 9. Folkish Trends BASIC CGI Web Application 10 PRINT “Ruby” #!/usr/bin/ruby % rails ruby_web_app 20 END require ‘cgi’ cgi = CGI.new cgi.print “Ruby” Present
    10. 10. But...
    11. 11. Yet Another Fun in none Web App !
    12. 12. Why none Web App ?
    13. 13. Everyone playing in Web App by cobalt123
    14. 14. Diversity
    15. 15. Explore Rich User Experience
    16. 16. Fun for Me ! by allfr3d
    17. 17. My Recommendation
    18. 18. Plug-in by Darren Hester
    19. 19. Why Plug-in ? by imjustincognito
    20. 20. Easier than creating Great App
    21. 21. Like Remora
    22. 22. Lower Hurdle
    23. 23. But...
    24. 24. Seems difficult... by an untrained eye
    25. 25. No!
    26. 26. Use Ruby !
    27. 27. 4 Examples
    28. 28. Safari + Hatena Bookmark RubyCocoa++
    29. 29. def addEntry(entry) bmk = OSX::NSEntityDescription.objc_send( :insertNewObjectForEntityForName, 'Bookmark', :inManagedObjectContext, @context_) # title title = entry.elementsForName('title').first.stringValue bmk.setValue_forKey(title, 'title') # id eid = entry.elementsForName('id').first.stringValue.to_s pos = eid.rindex('-') eid = eid[pos+1,eid.size] bmk.setValue_forKey(eid, 'eid'); # links entry.elementsForName('link').each do |url| if url.attributeForName('rel').stringValue.compare('related') siteUrl = url.attributeForName('href').stringValue bmk.setValue_forKey(siteUrl, 'siteUrl') else bookmarkUrl = url.attributeForName('href').stringValue bmk.setValue_forKey('bookmarkUrl', 'bookmarkUrl') end end
    30. 30. QuickSilver + Twitter RubyCocoa+++
    31. 31. class TwitterPluginAction < OSX::QSActionProvider # reload itself def reload Shared.logger.info('reloading ' + __FILE__) load(__FILE__) end # get screenName:password from PreferencePane def name_pass dict = OSX::NSUserDefaultsController. sharedUserDefaultsController.values; screen_name = dict.valueForKey("TwitterPreference.screenName") password = dict.valueForKey("TwitterPreference.password") screen_name.to_s + ':' + password end
    32. 32. Aren’t they Web App ?
    33. 33. Quartz Composer + Gainer RubyCocoa++++
    34. 34. def execute_atTime_withArguments(context, time, args) unless @initialized 4.times do |i| @gio.ain(i).on Funnel::PortEvent::CHANGE do |event| @ain[i] = event.target.value end @gio.din(i).on Funnel::PortEvent::CHANGE do |event| @din[i] = event.target.value end end @initialized = false end 4.times do |i| setValue_forOutputKey(@ain[i], "ain_" + i.to_s) setValue_forOutputKey(@din[i], "din_" + i.to_s) end
    35. 35. Vim + Refe
    36. 36. function! s:RubyRefe2(args) ruby << EOR bitclust_path = VIM::evaluate("s:bitclust_path") db_path = bitclust_path + '/../db-1_9_0' args = ['-d', db_path, VIM::evaluate("a:args")] $LOAD_PATH << bitclust_path + '/lib' require 'stringio' old_stdout = $stdout $stdout = StringIO.new require 'bitclust/searcher' require 'kconv' refe = BitClust::Searcher.new('refe.rb') refe.parse args refe.exec nil, args str = $stdout.string.toutf8 buf = VIM::Buffer.current while buf.count > 1 puts buf.count buf.delete 1 end buf.delete 1 str.split(/n/).each do |line| buf.append buf.count, line.toutf8
    37. 37. Why Ruby ?
    38. 38. Nice Glue. Between Different Worlds. by St. Murse
    39. 39. Debuggability • Dynamic ! • reload from plugin itself def reload load ‘./itself.rb’ • no need to restart app end
    40. 40. Conclusion
    41. 41. Create Something Useful for You !
    42. 42. and Us !
    43. 43. out of Browser !
    44. 44. with Ruby !
    45. 45. Thank you. mootoh@gmail.com http://deadbeaf.org/ Any pictures in these slides have their license. Follow their links to see the original ones. @mootoh

    ×