えっ、なにそれこわい
Upcoming SlideShare
Loading in...5
×
 

えっ、なにそれこわい

on

  • 2,144 views

オブジェクト倶楽部2010夏イベント

オブジェクト倶楽部2010夏イベント
ぴちぴち若人トラック
http://www.objectclub.jp/event/2010summer/

Statistics

Views

Total Views
2,144
Views on SlideShare
2,077
Embed Views
67

Actions

Likes
0
Downloads
10
Comments
0

2 Embeds 67

http://d.hatena.ne.jp 59
http://coderwall.com 8

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

えっ、なにそれこわい えっ、なにそれこわい Presentation Transcript

  • 2010 2010/07/16 @kei_s
  • ( ) id:kei-s, @kei_s RubyKaigi2010
  • ( ) id:kei-s, @kei_s RubyKaigi2010 View slide
  • I like ... Ruby JavaScript ( Squarepusher ) ( ) View slide
  • :
  • :
  • 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.”