|
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 |
square = (x) -> x * x cube = (x) -> square(x) * x fill = (container, liquid = "coffee") -> "Filling the #{container} with #{liquid}..." mood = greatlyImproved if singing if happy and knowsIt clapsHands() chaChaCha() else showIt() date = if friday then sue else jill # Eat lunch. eat food for food in ['toast', 'cheese', 'wine'] # Fine five course dining. courses = ['greens', 'caviar', 'truffles', 'roast', 'cake'] menu i + 1, dish for dish, i in courses # Health conscious meal. foods = ['broccoli', 'spinach', 'chocolate'] eat food for food in foods when food isnt 'chocolate' yearsOld = max: 10, ida: 9, tim: 11 ages = for child, age of yearsOld "#{child} is #{age}" if this.studyingEconomics buy() while supply > demand sell() until supply > demand for filename in list do (filename) -> grade = (student) -> if student.excellentWork "A+" else if student.okayStuff if student.triedHard then "B" else "B-" else "C" eldest = if 24 > 21 then "Liz" else "Ike" alert( try nonexistent / undefined catch error "And the error is ... #{error}" ) class Animal constructor: (@name) -> move: (meters) -> alert @name + " moved #{meters}m." alert @name.foo alert this.name class Snake extends Animal move: -> alert "Slithering..." super 5 class Horse extends Animal move: -> alert "Galloping..." super 45 sam = new Snake "Sammy the Python" tom = new Horse("Tommy the Palomino") yes no on off true false null void arguments RangeError (Foo.Bar.EventEmitter) Duck::howOld = -> "I'm #{@age} years old." document.write("aaaa") console.log("aaaa") |
|
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 |
# config/initializers/amqp.rb require 'amqp/utilities/event_loop_helper' require 'amqp/integration/rails' module AMQPManager def self.start AMQP::Utilities::EventLoopHelper.run AMQP::Integration::Rails.start do |connection| connection.on_error do |ch, connection_close| raise connection_close.reply_text end connection.on_tcp_connection_loss do |conn, settings| conn.reconnect(false, 2) end connection.on_tcp_connection_failure do |conn, settings| conn.reconnect(false, 2) end channel = AMQP::Channel.new(connection, AMQP::Channel.next_channel_id, :auto_recovery => true) channel.on_error do |ch, channel_close| raise channel_close.reply_text end AMQP.channel = channel end end end AMQPManager.start unless ENV["UNICORN"] |