タグを付けてfacetsするところまで。コードは全く書きません。 便利でいいですね。 gem "searchkick" # full text search gem 'acts-as-taggable-on' # For tags インストール後migration実行 $ rake acts_as_taggable_on_engine:install:migrations $ rake db:migrate モデル定義 class Product < ActiveRecord::Base searchkick # For full text search powerd by elasticsearch. acts_as_taggable # Alias for acts_as_taggable_on :tags # for searchkick reindex data. # def se
require 'parslet' include Parslet # Constructs a parser using a Parser Expression Grammar parser = str('"') >> ( str('\\').ignore >> any | str('"').absent? >> any ).repeat.as(:string) >> str('"') result = parser.parse %Q("this is a valid \\"string\\"") result # => {:string=>"this is a valid \"string\""@1} A small Ruby library for constructing parsers in the PEG (Parsing Expression Grammar) fashion
JSON, or JavaScript Object Notation has become the most widely used serialization and transport mechanism for information across various web-services. From it's initial conception, the format garnered swift and wide appreciation for being really simple and non-verbose. Lets say you want to consume the following JSON object via an API: { id: 3232, name: "Kashyap", email: "kashyap@example.com" conta
まつもと ゆきひろ1965年大阪府生まれで、4歳の頃から鳥取県米子市で育つ。筑波大学卒業後、数社を経て(株)ネットワーク応用通信研究所に入社。プログラミング言語「Ruby」の生みの親として知られる。島根県松江市在住で、Ruby開発の功績から同市の名誉市民にも選ばれた。 まつもとさんのブログ『Matzにっき』twitter 世界中に大勢のユーザーを抱える、日本産プログラミング言語 Ruby。その開発者である まつもとゆきひろ さんに、Ruby 開発の裏側と成功までの道のり、そして未来を生き抜くエンジニアさんへのアドバイスを伺いました。 プログラミングとの出会いは、父が買ってきたポケコンのBASICー プログラミング言語に興味を持ったキッカケはなんですか? 私が子供の頃は、コンピュータって全然一般的ではなかったんですよ。ものすごく尖った人だけが、NECのPC-8001 や SHARP の MZ
Guard Guard automates various tasks by running custom rules whenever file or directories are modified. It's frequently used by software developers, web designers, writers and other specialists to avoid mundane, repetitive actions and commands such as "relaunching" tools after changing source files or configurations. Common use cases include: an IDE replacement, web development tools, designing "sm
Twitter のタイムラインを保存しておくとなにかと便利なので、色々と保存形式を変えながら 4 年くらい記録し続けている。ツイートの保存が便利すぎるので、ツイセーブというサービス化までした。かつてはテキストで、MongoDB や MySQL とか Groonga とかいろいろやってきた。どれも問題ないんだけど、増え続けるログデータを保存する場所として考えると BigQuery が現代にマッチしてるようなのでそちらに移行した。 BigQuery に TL を保存するとできること TL の全てのデータをフルスキャンできる。これはかなり便利で、今回このブログ記事を書くにあたっても ‘BigQuery’ を TL から検索すれば、信頼できるフォローイングの人々の声を見ることができた。これにより「某 CA 社では 5000 台の MongoDB クラスタで BigQuery に対抗している」という
Vim is one of the most popular code editors used by many since Vim is found in most Unix systems (this includes Linux) it is one of the great options that programmers and system administrators tend to use. This editor is very complete and above all very versatile as it has great features that make it a great option to use. Although natively many would discard the use of Vim is because they do not
最近のRubyのクローラーは、EventMachineを使って並列化するのが流行のようです。EventMachineは、非同期処理をお手軽に実装できるフレームワークです。Rubyのスレッド機能との違いは、Reactorパターンを使いシングルスレッドで実装している点です。こちらのブログが詳しいので参考になります。 「見えないチカラ: 【翻訳】EventMachine入門」 EventMachineを使うと、イベント・ドリブンの処理を簡単に実装出来ます。使い方は簡単ですが、通常の同期処理やスレッドをつかった処理に比べると、どうしてもコードの記述量は多くなります。今回の例である並列化してクローラーを走らせるという用途であれば、短時間で多くのサイトにアクセスするのが目的です。イベント・ドリブンで並列化処理を実装するのが目的ではないはずです。その辺りの面倒くさい処理を実装したライブラリがcosmic
README.rdoc UserAgent UserAgent is a Ruby library that parses and compares HTTP User Agents. Example Browser = Struct.new(:browser, :version) SupportedBrowsers = [ Browser.new("Safari", "3.1.1"), Browser.new("Firefox", "2.0.0.14"), Browser.new("Internet Explorer", "7.0") ] user_agent = UserAgent.parse(request.user_agent) SupportedBrowsers.detect { |browser| user_agent >= browser } Copyright © 2009
どうも。バックエンドエンジニアの吉田です。 前回は1サイトをクロールする際の最適化戦略としてRedisベースの分散ロック機構を使った実例を紹介しました。 前回の記事:Redis::DistMutex – 時限付き分散ロックで効率良くサイトクロールをしよう 今回は複数サイトに対する処理をResqueを使って最適化した事例を紹介したいと思います。 ※ランダムにキューをlistenする話の予定でしたが、話がとっ散らかるので主題を変更しました。 主なキーワードとしては、「Resqueのキュー分割」、「Rubyでクラス定義を動的生成」といった感じです。 おさらい 前回使った図を使います。 iQONのクローラーは、提携サイトの商品一覧から商品ページのURLを取得し、ページをダウンロードする処理(fetchフェーズ)を必要な数だけWorkerプロセスとして起動しておき、Resqueを使って処理をして
はじめまして。バックエンドエンジニアの吉田です。 2013年5月末の入社以降、大量のEC2インスタンスのVPC移行を担当した後、今はiQONの商品DBを支えるクローラーの改善に取り組んでいます。今回はその改善の1つとして開発したRedis::DistMutexという分散ロック機構のruby実装を紹介をしようと思います。 Redis::DistMutex 開発の経緯や細かい設計の話は後述するとして、まずはつくったgemの紹介をします。 Redis::DistMutex Redisベースの分散ロック機構 rubyのライブラリにあるMutex互換 スレッド間だけでなく、プロセス間・ホスト間でも共有できるMutex 時限つきロックの作成が可能(redisのsetnxとexpireを活用) namespaceを指定できるので、特定の処理ごとにロックの作成が可能 redis2.6以上のみサポート(1秒
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く