SlideShare a Scribd company logo
1 of 57
Download to read offline
2010
2010/07/16


         @kei_s
(     )




id:kei-s, @kei_s

RubyKaigi2010
(     )




id:kei-s, @kei_s

RubyKaigi2010
I like ...
Ruby
JavaScript


           ( Squarepusher )
       (           )
:
:
Ruby    JavaScript


         Ruby
                JavaScript

 Ajax            Ruby
Ruby         JavaScript




Ruby   JavaScript
1. Ajax
JavaScript ( with jQuery )

 var user = {name: ‘kei_s’};

 user.age = 26;

 $.post(‘/user’, {data: user});
Ruby ( with Sinatra )
 post ‘/user’ do

   user = params

   puts user.age

   ‘ok’

 end

 #=>
Ruby ( with Sinatra )
 post ‘/user’ do

   user = params

   puts user.age

   ‘ok’

 end

 #=> NoMethodError:
     undefined method `age'
Ruby ( with Sinatra )
 post ‘/user’ do

   user = params

   puts user.age

   ‘ok’

 end

 #=> NoMethodError:
     undefined method `age'
Ruby ( with Sinatra )
 post ‘/user’ do

   user = params

 # puts user.age

   puts user[‘age’]

   ‘ok’

 end

 #=> 26
JavaScript
  hash.key      //=> value

  hash[‘key’]   //=> value
Ruby
  hash.key       #=> key

  hash[‘key’]    #=> value
2.
Ruby
users = [

    {'age'=>22},{'age'=>26},{'age'=>31}

]

users.select{|user|

    user[‘age’] < 30

}.size

#=> 2
JavaScript
var users = [

     {'age': 22},{'age': 26},{'age': 31}

];

users.filter(function(user){

     user.age < 30;

}).length;

//=>
JavaScript
var users = [

     {'age': 22},{'age': 26},{'age': 31}

];

users.filter(function(user){

     user.age < 30;

}).length;

//=> 0
JavaScript
var users = [

     {'age': 22},{'age': 26},{'age': 31}

];

users.filter(function(user){

     user.age < 30;

}).length;

//=> 0
JavaScript
var users = [

     {'age': 22},{'age': 26},{'age': 31}

];

users.filter(function(user){

//user.age < 30;

     return user.age < 30;

}).length; //=> 2
JavaScript
  function(){ v; }        //=> undefined

  function(){ return v; } //=> v
Ruby
  def func() v; end        #=> v

  def func() return v; end #=> v
3.
JavaScript ( with jQuery )

 $.get(‘/user.json’,

      function(response){

          console.log( response );

      }

 );
Ruby ( with Typhoeus )
 hydra = Typhoues::Hydra.new

 request= Typhoeus::Request.new(‘/user.json’)

 request.on_complete do |response|

   puts response.body

 end

 hydra.queue request

 hydra.run
JavaScript ( with jQuery )

 $.get(‘/user.json’,

      function(response){

          console.log( response );

      }

 );
JavaScript ( with jQuery )

 Users.prototype.store = function(response) {
      this.responses.push(response);
 };


 var users = new Users();
 $.get(‘/user1.json’,users.store);
 $.get(‘/user2.json’,users.store);
Ruby ( with Typhoeus )
 def Users.store(response)
   @responses << response
 end
 users = Users.new
 request1 = Typhoeus::Request.new(‘/user1.json’)
 request2 = Typhoeus::Request.new(‘/user2.json’)

 request1.on_complete(users.store)
 request2.on_complete(users.store)
 hydra.queue request1
 hydra.queue request2
 hydra.run

 #=>
Ruby ( with Typhoeus )
 def Users.store(response)
   @responses << response
 end
 users = Users.new
 request1 = Typhoeus::Request.new(‘/user1.json’)
 request2 = Typhoeus::Request.new(‘/user2.json’)

 request1.on_complete(users.store)
 request2.on_complete(users.store)
 hydra.queue request1
 hydra.queue request2
 hydra.run

 #=> ArgumentError:
     wrong number of arguments (0 for 1)
Ruby ( with Typhoeus )


 request.on_complete(users.store)

 #=> Users#store

 #=> ArgumentError:
     wrong number of arguments (0 for 1)
Ruby ( with Typhoeus )
 def Users.store(response)

   @responses << response

 end

 users = Users.new

 request.on_complete do |response|

   users.store(response)

 end #=> OK
Ruby ( with Typhoeus )
 def Users.store(response)

   @responses << response

 end

 users = Users.new

 request.on_complete &users.method(:store)

 #=> OK

 request.on_complete = users.method(:store)

 #=> OK (only for Typhoeus::Request)
JavaScript
  object.func   //=> Function

Ruby
  object.method(:func)
  #=> Method

  object.method(:func).to_proc
  #=> Proc
Ruby   JavaScript




=>
http://www.flickr.com/photos/magisterludi/405224443/
http://www.flickr.com/photos/delusionary/478351622/
http://www.flickr.com/photos/midgley/3687327166/
http://www.flickr.com/photos/hand-nor-glove/563554215/
A Jedi Master said ...
http://twitpic.com/22iyix
“Control, control.
 You must learn control.”
“Control, control.
 You must learn control.”
“Control, control.
 You must learn control.”
http://www.flickr.com/photos/fazen/427962176/
http://www.flickr.com/photos/hand-nor-glove/626648592/
http://www.flickr.com/photos/magisterludi/405224443/
“Control, control.
 You must learn control.”
“

More Related Content

What's hot

jQuery - 10 Time-Savers You (Maybe) Don't Know
jQuery - 10 Time-Savers You (Maybe) Don't KnowjQuery - 10 Time-Savers You (Maybe) Don't Know
jQuery - 10 Time-Savers You (Maybe) Don't Know
girish82
 
Restful services-slides
Restful services-slidesRestful services-slides
Restful services-slides
MasterCode.vn
 
Full compile invalid obje pl/sql
Full compile invalid obje pl/sqlFull compile invalid obje pl/sql
Full compile invalid obje pl/sql
Anar Godjaev
 
Jqeury ajax plugins
Jqeury ajax pluginsJqeury ajax plugins
Jqeury ajax plugins
Inbal Geffen
 

What's hot (20)

Introducing jQuery
Introducing jQueryIntroducing jQuery
Introducing jQuery
 
Everyday's JS
Everyday's JSEveryday's JS
Everyday's JS
 
Growing jQuery
Growing jQueryGrowing jQuery
Growing jQuery
 
jQuery Best Practice
jQuery Best Practice jQuery Best Practice
jQuery Best Practice
 
Lecture 5: Client Side Programming 1
Lecture 5: Client Side Programming 1Lecture 5: Client Side Programming 1
Lecture 5: Client Side Programming 1
 
jQuery - 10 Time-Savers You (Maybe) Don't Know
jQuery - 10 Time-Savers You (Maybe) Don't KnowjQuery - 10 Time-Savers You (Maybe) Don't Know
jQuery - 10 Time-Savers You (Maybe) Don't Know
 
Restful services-slides
Restful services-slidesRestful services-slides
Restful services-slides
 
Rails GUI Development with Ext JS
Rails GUI Development with Ext JSRails GUI Development with Ext JS
Rails GUI Development with Ext JS
 
Game jump: frontend introduction #1
Game jump: frontend introduction #1Game jump: frontend introduction #1
Game jump: frontend introduction #1
 
Full compile invalid obje pl/sql
Full compile invalid obje pl/sqlFull compile invalid obje pl/sql
Full compile invalid obje pl/sql
 
与 PHP 和 Perl 使用 MySQL 数据库
与 PHP 和 Perl 使用 MySQL 数据库与 PHP 和 Perl 使用 MySQL 数据库
与 PHP 和 Perl 使用 MySQL 数据库
 
Evented Javascript
Evented JavascriptEvented Javascript
Evented Javascript
 
Jquery Basics
Jquery BasicsJquery Basics
Jquery Basics
 
jQuery Way
jQuery WayjQuery Way
jQuery Way
 
Fluent Python - Chapter 15
Fluent Python - Chapter 15Fluent Python - Chapter 15
Fluent Python - Chapter 15
 
Sins Against Drupal 2
Sins Against Drupal 2Sins Against Drupal 2
Sins Against Drupal 2
 
Jqeury ajax plugins
Jqeury ajax pluginsJqeury ajax plugins
Jqeury ajax plugins
 
Make it SOLID!
Make it SOLID!Make it SOLID!
Make it SOLID!
 
Introducing AngularJS
Introducing AngularJSIntroducing AngularJS
Introducing AngularJS
 
Drupal sins 2016 10-06
Drupal sins 2016 10-06Drupal sins 2016 10-06
Drupal sins 2016 10-06
 

Viewers also liked

或るWebサービス開発のこれから - "オープンWebサービス"という妄想 -
或るWebサービス開発のこれから - "オープンWebサービス"という妄想 -或るWebサービス開発のこれから - "オープンWebサービス"という妄想 -
或るWebサービス開発のこれから - "オープンWebサービス"という妄想 -
Kei Shiratsuchi
 
ドワンゴ勉強会 090731
ドワンゴ勉強会 090731ドワンゴ勉強会 090731
ドワンゴ勉強会 090731
Kei Shiratsuchi
 
ノンデザイナーのための配色理論
ノンデザイナーのための配色理論ノンデザイナーのための配色理論
ノンデザイナーのための配色理論
tsukasa obara
 

Viewers also liked (8)

或るWebサービス開発のこれから - "オープンWebサービス"という妄想 -
或るWebサービス開発のこれから - "オープンWebサービス"という妄想 -或るWebサービス開発のこれから - "オープンWebサービス"という妄想 -
或るWebサービス開発のこれから - "オープンWebサービス"という妄想 -
 
Introduce of the parallel distributed Crawler with scraping Dynamic HTML
Introduce of the parallel distributed Crawler with scraping Dynamic HTMLIntroduce of the parallel distributed Crawler with scraping Dynamic HTML
Introduce of the parallel distributed Crawler with scraping Dynamic HTML
 
1/2 Real-time Tab Sync
1/2 Real-time Tab Sync1/2 Real-time Tab Sync
1/2 Real-time Tab Sync
 
ドワンゴ勉強会 090731
ドワンゴ勉強会 090731ドワンゴ勉強会 090731
ドワンゴ勉強会 090731
 
ノンデザイナーのための配色理論
ノンデザイナーのための配色理論ノンデザイナーのための配色理論
ノンデザイナーのための配色理論
 
Reuters: Pictures of the Year 2016 (Part 2)
Reuters: Pictures of the Year 2016 (Part 2)Reuters: Pictures of the Year 2016 (Part 2)
Reuters: Pictures of the Year 2016 (Part 2)
 
The Six Highest Performing B2B Blog Post Formats
The Six Highest Performing B2B Blog Post FormatsThe Six Highest Performing B2B Blog Post Formats
The Six Highest Performing B2B Blog Post Formats
 
The Outcome Economy
The Outcome EconomyThe Outcome Economy
The Outcome Economy
 

Similar to えっ、なにそれこわい

Desenvolvimento web com Ruby on Rails (parte 3)
Desenvolvimento web com Ruby on Rails (parte 3)Desenvolvimento web com Ruby on Rails (parte 3)
Desenvolvimento web com Ruby on Rails (parte 3)
Joao Lucas Santana
 
Introducing Rendr: Run your Backbone.js apps on the client and server
Introducing Rendr: Run your Backbone.js apps on the client and serverIntroducing Rendr: Run your Backbone.js apps on the client and server
Introducing Rendr: Run your Backbone.js apps on the client and server
Spike Brehm
 
Venturing Into The Wild: A .NET Developer's Experience As A Ruby Developer
Venturing Into The Wild: A .NET Developer's Experience As A Ruby DeveloperVenturing Into The Wild: A .NET Developer's Experience As A Ruby Developer
Venturing Into The Wild: A .NET Developer's Experience As A Ruby Developer
Jon Kruger
 
Юрий Буянов «Squeryl — ORM с человеческим лицом»
Юрий Буянов «Squeryl — ORM с человеческим лицом»Юрий Буянов «Squeryl — ORM с человеческим лицом»
Юрий Буянов «Squeryl — ORM с человеческим лицом»
e-Legion
 

Similar to えっ、なにそれこわい (20)

Real Time App with Node.js
Real Time App with Node.jsReal Time App with Node.js
Real Time App with Node.js
 
Ruby on Rails Intro
Ruby on Rails IntroRuby on Rails Intro
Ruby on Rails Intro
 
Desenvolvimento web com Ruby on Rails (parte 3)
Desenvolvimento web com Ruby on Rails (parte 3)Desenvolvimento web com Ruby on Rails (parte 3)
Desenvolvimento web com Ruby on Rails (parte 3)
 
JavaScript Fundamentals with Angular and Lodash
JavaScript Fundamentals with Angular and LodashJavaScript Fundamentals with Angular and Lodash
JavaScript Fundamentals with Angular and Lodash
 
Server Side Swift with Swag
Server Side Swift with SwagServer Side Swift with Swag
Server Side Swift with Swag
 
Bonnes pratiques de développement avec Node js
Bonnes pratiques de développement avec Node jsBonnes pratiques de développement avec Node js
Bonnes pratiques de développement avec Node js
 
AngularJs
AngularJsAngularJs
AngularJs
 
Doctrine For Beginners
Doctrine For BeginnersDoctrine For Beginners
Doctrine For Beginners
 
Optimizing Angular Performance in Enterprise Single Page Apps
Optimizing Angular Performance in Enterprise Single Page AppsOptimizing Angular Performance in Enterprise Single Page Apps
Optimizing Angular Performance in Enterprise Single Page Apps
 
Introducing Rendr: Run your Backbone.js apps on the client and server
Introducing Rendr: Run your Backbone.js apps on the client and serverIntroducing Rendr: Run your Backbone.js apps on the client and server
Introducing Rendr: Run your Backbone.js apps on the client and server
 
Venturing Into The Wild: A .NET Developer's Experience As A Ruby Developer
Venturing Into The Wild: A .NET Developer's Experience As A Ruby DeveloperVenturing Into The Wild: A .NET Developer's Experience As A Ruby Developer
Venturing Into The Wild: A .NET Developer's Experience As A Ruby Developer
 
AngularJS and SPA
AngularJS and SPAAngularJS and SPA
AngularJS and SPA
 
Testing in JavaScript
Testing in JavaScriptTesting in JavaScript
Testing in JavaScript
 
mondrian-olap JRuby library
mondrian-olap JRuby librarymondrian-olap JRuby library
mondrian-olap JRuby library
 
Юрий Буянов «Squeryl — ORM с человеческим лицом»
Юрий Буянов «Squeryl — ORM с человеческим лицом»Юрий Буянов «Squeryl — ORM с человеческим лицом»
Юрий Буянов «Squeryl — ORM с человеческим лицом»
 
BDD de fuera a dentro
BDD de fuera a dentroBDD de fuera a dentro
BDD de fuera a dentro
 
Ruby/Rails
Ruby/RailsRuby/Rails
Ruby/Rails
 
Virtual Madness @ Etsy
Virtual Madness @ EtsyVirtual Madness @ Etsy
Virtual Madness @ Etsy
 
Express JS
Express JSExpress JS
Express JS
 
Rails3 changesets
Rails3 changesetsRails3 changesets
Rails3 changesets
 

Recently uploaded

Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider  Progress from Awareness to Implementation.pptxTales from a Passkey Provider  Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
FIDO Alliance
 
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
FIDO Alliance
 
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
panagenda
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc
 

Recently uploaded (20)

2024 May Patch Tuesday
2024 May Patch Tuesday2024 May Patch Tuesday
2024 May Patch Tuesday
 
Generative AI Use Cases and Applications.pdf
Generative AI Use Cases and Applications.pdfGenerative AI Use Cases and Applications.pdf
Generative AI Use Cases and Applications.pdf
 
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
 
Portal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russePortal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russe
 
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider  Progress from Awareness to Implementation.pptxTales from a Passkey Provider  Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
 
Intro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptxIntro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptx
 
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
 
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
 
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptxCyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
 
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on ThanabotsContinuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
 
The Ultimate Prompt Engineering Guide for Generative AI: Get the Most Out of ...
The Ultimate Prompt Engineering Guide for Generative AI: Get the Most Out of ...The Ultimate Prompt Engineering Guide for Generative AI: Get the Most Out of ...
The Ultimate Prompt Engineering Guide for Generative AI: Get the Most Out of ...
 
(Explainable) Data-Centric AI: what are you explaininhg, and to whom?
(Explainable) Data-Centric AI: what are you explaininhg, and to whom?(Explainable) Data-Centric AI: what are you explaininhg, and to whom?
(Explainable) Data-Centric AI: what are you explaininhg, and to whom?
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
 
Overview of Hyperledger Foundation
Overview of Hyperledger FoundationOverview of Hyperledger Foundation
Overview of Hyperledger Foundation
 
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
 
ChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps ProductivityChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps Productivity
 
State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
 
How to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cfHow to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cf
 
The Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightThe Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and Insight
 

えっ、なにそれこわい