Skip to content

Instantly share code, notes, and snippets.

View jsuchal's full-sized avatar

Jano Suchal jsuchal

View GitHub Profile
# WebPage uses cache??? What the heck is cache in context of a webpage crawling process? It should only crawl pages. You need to inject some dummy cache to prevent caching.
# thumnail generation is an expensive job, thus lazy-loading. But you are not saving already generated thumbnails in cache. :(
# Nice tests.
# old style
class AddUserToUploadedFiles < ActiveRecord::Migration
def self.up
add_column :uploaded_files, :user_id, :integer
end
def self.down
remove_column :uploaded_files, :user_id
end
end
SELECT * FROM docs WHERE id <
(SELECT RAND() * m.maximum AS random_id FROM
(SELECT MAX(id) AS maximum FROM docs) AS m)
AND your_conditions
LIMIT 1
Mixiny/Extension method
5.1.2006 http://www.sitepoint.com/forums/showpost.php?p=2402347&postcount=1
1.12.2007 http://latrine.dgx.cz/nette-object-tatka-vsech-objektu
Anotations
15.8.2006 http://www.sitepoint.com/forums/showthread.php?t=413308
22.11.2008 http://forum.nette.org/cs/1033-2008-11-22-anotace-trid-a-metod
RubyOnRails
2008 @jsuchal
Restclient 8.81s vs Curb 0.98s wow!
%Total %Self Total Self Wait Child Calls Name Line
10.76 0.12 0.00 10.64 5204/5204 Tire::DSL#search 10
90.70% 1.01% 10.76 0.12 0.00 10.64 5204 Tire::Search::Search#perform 69
8.81 0.03 0.00 8.78 2602/2602 <Class::Tire::HTTP::Client::RestClient>#get 70
0.98 0.03 0.00 0.95 2602/2602 <Class::Tire::HTTP::Client::Curb>#get 70
0.32 0.03 0.00 0.29 5204/5204 <Module::MultiJson>#decode 75
0.26 0.02 0.00 0.24 5204/5204 Tire::Search::Search#to_json 70
0.15 0.02 0.00 0.13 5204/50843 Class#new 76
index:
analysis:
analyzer:
eulang:
type: custom
tokenizer: standard
filter: [standard, lowercase, asciifolding, stop]
@jsuchal
jsuchal / results
Created December 31, 2011 01:04 — forked from karmi/tire_http_clients_benchmark.rb
Benchmark Tire gem with RestClient, Curb and Thrift Clients
================================================================================
["RestClient", 5.152005974]
--------------------------------------------------------------------------------
["Curb", 2.073422755]
--------------------------------------------------------------------------------
["Thrift", 3.357725494]
--------------------------------------------------------------------------------
Series.create_from_speakerrate('http://speakerrate.com/series/241-rubyslava-pyvo?all')
describe Series do
it "should " do
url = 'http://speakerrate.com/series/241-rubyslava-pyvo?all'
html = ''
downloader = mock(:Downloader)
downloader.should_receive(:download).with(url).and_return(html)
@jsuchal
jsuchal / staging.log
Created May 9, 2012 14:49
Redis FTW!
Started GET "/api/v2/why/user/1870797446/for_user/701647404" for 127.0.0.1 at 2012-05-09 16:45:50 +0200
Processing by Api::V2::WhyController#user as HTML
Parameters: {"user_id"=>"1870797446", "for_user_id"=>"701647404"}
Completed 200 OK in 4ms (Views: 1.6ms | ActiveRecord: 0.0ms)
Started GET "/api/v2/why/user/1870797446/for_user/701647404" for 127.0.0.1 at 2012-05-09 16:45:50 +0200
Processing by Api::V2::WhyController#user as HTML
Parameters: {"user_id"=>"1870797446", "for_user_id"=>"701647404"}
Completed 200 OK in 5ms (Views: 1.8ms | ActiveRecord: 0.0ms)
class Object
def self.include_with_args(base, *args)
base.included_with_args(self, *args) if base.respond_to?(:included_with_args)
include(base)
end
end
describe 'mixins with args' do
it 'calls hook method with args' do
module AMixin end