Skip to content

Instantly share code, notes, and snippets.

require 'rubygems'
require 'nokogiri'
require 'open-uri'
# can be different for your specific search
PAGES = 140
PAGES.times do |page_num|
response = open("http://www.match.com/search/searchSubmit.aspx?by=radius&lid=226&cl=1&gc=2&tr=1&lage=27&uage=29&ua=29&pc=94121&dist=10&po=1&oln=0&do=2&q=woman,men,27,29,1915822078&st=quicksearch&pn=#{page_num}&rn=4", "cookie" => "SECU=VALUE_OF_THE_COOKIE")
require 'rubygems'
require 'nokogiri'
require 'open-uri'
# can be different for your specific search
PAGES = 140
PAGES.times do |page_num|
response = open("http://www.match.com/search/searchSubmit.aspx?by=radius&lid=226&cl=1&gc=2&tr=1&lage=27&uage=29&ua=29&pc=94121&dist=10&po=1&oln=0&do=2&q=woman,men,27,29,1915822078&st=quicksearch&pn=#{page_num}&rn=4", "cookie" => "SECU=VALUE_OF_THE_COOKIE")
def where *params
shard_key = params.find{|x| x.has_key?(:player_id)}
params.first.merge!(:shard_id => Digest::MD5.hexdigest(shard_key[:player_id])) unless shard_key.nil?
super *params
end
# checking in console
ruby-1.9.2-p290 :079 > Activity.where(:player_id => "4e5d4e27b262e3fbe0000050").selector
=> {:deleted_at=>{"$exists"=>false}, :player_id=>BSON::ObjectId('4e5d4e27b262e3fbe0000050'), :shard_id=>"0ce2aee649f332e56751b41bc9e2844e"}
+-----------------------------------------------------------------------------+
| rate | conn/s | req/s | replies/s avg | errors | 5xx status | net io (KB/s) |
+-----------------------------------------------------------------------------+
| 10 | 9.5 | 9.5 | 7.3 | 269 | 0 | 141.5 |
| 20 | 18.2 | 18.2 | 0.8 | 960 | 0 | 23.2 |
| 30 | 26.1 | 26.1 | 0.0 | 1000 | 0 | 6.0 |
| 40 | 33.6 | 33.6 | 14.3 | 641 | 359 | 18.1 |
| 50 | 40.1 | 40.1 | 26.7 | 464 | 536 | 27.7 |
| 60 | 46.1 | 46.1 | 36.8 | 263 | 737 | 39.8 |
| 70 | 52.0 | 52.0 | 49.8 | 253 | 747 | 45.4 |
from a separate instance
+-----------------------------------------------------------------------------+
| rate | conn/s | req/s | replies/s avg | errors | 5xx status | net io (KB/s) |
+-----------------------------------------------------------------------------+
| 10 | 9.9 | 9.9 | 9.8 | 12 | 1 | 173.1 |
| 20 | 18.2 | 18.2 | 15.1 | 246 | 1 | 223.6 |
| 30 | 26.1 | 26.1 | 0.0 | 1000 | 0 | 6.1 |
| 40 | 33.4 | 33.4 | 8.6 | 785 | 215 | 13.9 |
| 50 | 40.0 | 40.0 | 41.1 | 178 | 822 | 37.6 |
| 60 | 46.2 | 46.2 | 33.9 | 322 | 678 | 37.7 |
11/10/18 23:28:46 INFO mapred.JobClient: map 0% reduce 0%
11/10/18 23:29:10 INFO mapred.JobClient: Task Id : attempt_201110180937_0045_m_000000_0, Status : FAILED
Error: java.lang.InstantiationError: org.bson.BSONDecoder
at com.mongodb.hadoop.io.BSONWritable.readFields(BSONWritable.java:167)
at org.apache.hadoop.io.WritableComparator.compare(WritableComparator.java:97)
at com.mongodb.hadoop.io.BSONComparator.compare(BSONComparator.java:41)
at org.apache.hadoop.mapred.MapTask$MapOutputBuffer.compare(MapTask.java:1110)
at org.apache.hadoop.util.QuickSort.fix(QuickSort.java:30)
at org.apache.hadoop.util.QuickSort.sortInternal(QuickSort.java:83)
at org.apache.hadoop.util.QuickSort.sort(QuickSort.java:59)
[
-{
-data:
{
+result: { … }
+activity: { … }
rewards: [ ]
+user: { … }
}
}
[
-{
-data: {
-result: {
points: 1
}
+activity: { … }
rewards: [ ]
+user: { … }
}
{
'contents': [
{'content_id' : 1, 'content_url' : 'url'},
{'content_id' : 2, 'content_url' : 'url2'},
],
'result' : [existing_array] //something that we return right now
}
Badgeville.ready(function(){
Badgeville.Comet.bind( function( event, message ) {
console.log('site notification');
console.log( message );
event_handler(message);
});
Badgeville.bind( 'siteMessage', function( event, message ) {
console.log( message );