You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert
Posted on 2015-06-14 Closures: Elixir vs. Ruby vs. JavaScript Closures are not the same across languages. Learn how they differ between Ruby, JavaScript and Elixir to avoid bugs and confusion. tl;dr Closures in Elixir prevent nasty side-effects. Closures in JavaScript are the worst of the three (suprirse, surprise!). Ruby is slightly better thanks to functional elements in the language, but not pe
Painless multithreaded programming for Ruby Celluloid is a concurrent object oriented programming framework for Ruby which lets you build multithreaded programs out of concurrent objects just as easily as you build sequential programs out of regular objects! Learn more Evented I/O for Celluloid actors. Build fast evented programs like you would with EventMachine or Node.js using regular synchronou
require 'celluloid' class Counter include Celluloid attr_reader :count def initialize @count = 0 end def increment(n = 1) sleep n @count += n end end actor = Counter.new p actor.count #=> 0 p actor.increment #=> 1 p actor.async.increment(41) #=> nil p actor.count #=> 1 Celluloidの機能を使うには、ActorにしたいクラスにCellloidをincludeします。 #asyncをはそれに続くメソッド呼び出しが非同期になるようなプロキシを返します。メソッド呼び出しはnilを返すため、本来返ってくるはずの返り値は使えません
「Rails4でサイトを構築する」シリーズ目次 Rails環境構築編 Scaffold利用編 Bootstrap導入編 WYSIWYG導入編 CSV出力機能編 スクレイピング機能編(nokogiri) 非同期処理導入編(delayed_job) デプロイ環境構築編(capistrano3) 今回は、delayed_jobを使って非同期処理を行う機能を実装してみたいと思います。 delayed_jobとは 処理に時間が掛かるようなタスクをバックグラウンドで非同期処理を実現するGemです。 delayed_job 同じようなものにResque gemがありますが、 delayed_jobを使っていて困ることはないので、使い慣れたdelayed_jobを使っています。 ファイルをアップロードして内容を解析してデータを保存する処理とかサイトをクローリングしてスクレイピングして情報を保存する処理等、
Photo by Flickr: @Doug88888's Photostream メール送信、大量データのインポート/エクスポートなど長い時間がかかる処理はバックグラウンドで処理するのが一般的です。 Railsでバックグラウンド処理を実現するためには、Sidekiq, Resque, Delayed Jobといったgemが有名です。 また、Rails4.2からActive Jobが追加されました。これは、たくさんあるバックグラウンド処理を行うgemへの共通インターフェースのようなものが追加されました。 メリットとして、バックグラウンド処理のgemがどれでも、ソースコードは同じように記述できるようになります。ちなみに、ActiveJobだけではバックグラウンド処理はできないので、バックグラウンド処理のgemを入れる必要があります。 この記事では、DelayedJobでのバックグラウンド処理
概要 Rails で WEB 画面からのキックでジョブをバックグラウンドで実行するときどうするか。 例えば、メール送信・画像変換・CSVアップロードによる大量SQL実行など。 そんなときはバックグラウンドで非同期にジョブを実行してくれる便利な gem がある。 ruby-rails.hatenadiary.com このサイトで丁寧に説明してくれてます。 代表的だと言われている下記3つについて、それぞれ実装して使い心地を比較する。 Sidekiq: mperham/sidekiq · GitHub Resque: resque/resque · GitHub Delayed Job: collectiveidea/delayed_job · GitHub それと上記サイトで書かれている Active Job これの使い勝手も試してみる。 それぞれの gem について、もっと詳しく知りたい方は
Callbacks are a great technique for achieving simplicity and flexibility. Simply put, a callback is a block of code passed as an argument to a method. In Ruby, code blocks are everywhere and Ruby makes it trivial to pass a block of code to methods. For example: def foo(bar, &block) callback = block callback.call(bar) end foo(5) {|x| x * x} # => 25 But what do we do when a method needs two blocks o
I'm not sure of the best idiom for C style call-backs in Ruby - or if there is something even better ( and less like C ). In C, I'd do something like: void DoStuff( int parameter, CallbackPtr callback ) { // Do stuff ... // Notify we're done callback( status_code ) } Whats a good Ruby equivalent? Essentially I want to call a passed in class method, when a certain condition is met within "DoStuff"
Stay Relevant and Grow Your Career in TechPremium ResultsPublish articles on SitePointDaily curated jobsLearning PathsDiscounts to dev toolsStart Free Trial7 Day Free Trial. Cancel Anytime. Key Takeaways Lazy enumerables in Ruby allow for efficient handling of large data sets by deferring computation until necessary, which improves performance especially with infinite sequences. Ruby’s `Enumerable
3. Enumerable#lazy 2013/02/22 シナジーマーケティング(株) 寺岡 佑起 [Ruby 2.0] 第3章 Enumerable#lazy 3.1. Enumerable#lazyとは 3.2. lazyが生まれた背景 3.3. 怠惰なEnumerator 3.4. 省メモリ 3.5. 無限リストに適用 3.5. IOに適用 3.6. まとめ 3.1. Enumerable#lazyとは Enumerable#lazyを一言で表すと、遅延評価を行うEnumeratorを返すメソッドです。 遅延評価とは関数型言語でよく利用される「必要とされるまで実行しない」という考え方です。 Enumerable#lazyを用いると、今まで利用できなかった箇所にselectやmapなどのメソッドを適用することができるようになります。 3.2. lazyが生まれた背景 Enumerab
2012-06-15 (鈴) 1. はじめに 2. Ruby 2.0 開発版のインストール 3. Enumerator::Lazy 4. ループ融合としての解釈 5. C# の LINQ との比較 6. おわりに 1. はじめに 本稿では Ruby 2.0 に予定されている Enumerator::Lazy について,先行する概念と対照して考察する。 それが計算量の観点からループ融合の最適化に等しいことを非形式的に論ずる。 また,C# の LINQ と実質的に同じものであることを示す。 以上の議論から Enumerator::Lazy が来るべき Ruby 2.0 の最も重要な機能の一つであることを示す。 2. Ruby 2.0 開発版のインストール 執筆時現在,Ruby 2.0 の処理系は https://github.com/ruby/ruby から $ git clone https
『るびま』は、Ruby に関する技術記事はもちろんのこと、Rubyist へのインタビューやエッセイ、その他をお届けするウェブ雑誌です。 Rubyist Magazine について 『Rubyist Magazine』、略して『るびま』は、Rubyist の Rubyist による、Rubyist とそうでない人のためのウェブ雑誌です。 最新号 Rubyist Magazine 0064 号 バックナンバー Rubyist Magazine 0064 号 Rubyist Magazine 0063 号 Rubyist Magazine 0062 号 Kaigi on Rails 特集号 RubyKaigi Takeout 2020 特集号 Rubyist Magazine 0061 号 Rubyist Magazine 0060 号 RubyKaigi 2019 直前特集号 Rubyist
■ [ruby][event] Ruby勉強会@関西-16「30分でわかるcallccの使い方」 先週末のRuby勉強会@関西で、Rubyにおけるcallccの使い方について発表させていただきました。 スライド: pdf ppt 継続の説明については「なんでも継続」がよく参照されるんだけど、 ちょっと説明がボトムアップすぎると思うので(僕も最初に読んだときは全然分からなかった)、「callccで何ができるか」という応用面から攻める 構成にしてみました。 最初は「継続かわいいよ継続」「それをすてるなんてとんでもない」と思ってたんだけど、 いろいろ調べてるうちになんでcallccが嫌われるのかが理解できてしまった。callccはかわいいけど、非常に手のかかる奴らしい。 しかも、面白い利用例はいっぱいあるけど実用的な例があんまりないんだよね^^;。 callccが無くなるとRubyの「かっこよさ
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く