Skip to content

Instantly share code, notes, and snippets.

#encoding: utf-8
require 'mechanize'
KINOPOISK_SEARCH_URL = 'http://kinopoisk.ru/index.php?kp_query='
query = 'терминатор'
agent = Mechanize.new
agent.get "#{KINOPOISK_SEARCH_URL}#{query.encode("windows-1251")}"
agent.page.search("td.news[width]").map do |section|
Òåðìèíàòîð
Òåðìèíàòîð: Äà ïðèä¸ò ñïàñèòåëü
Òåðìèíàòîð 2: Ñóäíûé äåíü
Òåðìèíàòîð 3: Âîññòàíèå ìàøèí
Òåðìèíàòîð: Áèòâà çà áóäóùåå (ñåðèàë)
Òåðìèíàòîð 2 - 3D
#encoding: utf-8
require 'mechanize'
class MechanizeEncodingHook
def call(params)
return if params[:response].nil? || params[:response_body].nil?
response = params[:response]
content_type = response['Content-Type']
Терминатор
Терминатор: Да придёт спаситель
Терминатор 2: Судный день
Терминатор 3: Восстание машин
Терминатор: Битва за будущее (сериал)
Терминатор 2 - 3D
require 'rack/utils'
module Fx
class FlashSessionCookie
def initialize(app, session_key = '_session_id')
@app = app
@session_key = session_key
end
require 'benchmark'
n = 1000000
words = ["string", :symbol]
Benchmark.bm(20) do |x|
x.report("join('_')") do
n.times do
res = words.map{|s| s}.join("_")
end
end
C:\PROGRA~1\MySQL\MYSQLS~1.1\bin>gem install mysql2
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
C:/Ruby192/bin/ruby.exe extconf.rb
checking for rb_thread_blocking_region()... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
@yury
yury / comp.rb
Created January 6, 2011 23:33
benchmark
require 'benchmark'
n = 1000000
words = ["string", :symbol, "string", "string", "string"]
Benchmark.bm(20) do |x|
x.report('<< "_"') do
n.times do
res = words.inject("") {|string, p| string << "#{p}_"}
end
otool -L /usr/local/bin/mysql
/usr/local/bin/mysql:
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.10)
/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.3)
/usr/lib/libssl.0.9.8.dylib (compatibility version 0.9.8, current version 0.9.8)
/usr/lib/libcrypto.0.9.8.dylib (compatibility version 0.9.8, current version 0.9.8)
/usr/lib/libncurses.5.4.dylib (compatibility version 5.4.0, current version 5.4.0)
/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.9.0)
@yury
yury / gist:964447
Created May 10, 2011 13:16
encoding error
ERROR Encoding::UndefinedConversionError: "\xD0" from ASCII-8BIT to UTF-8
/Users/yury/.rvm/gems/ruby-1.9.2-p180@railspre/gems/activesupport-3.1.0.beta1/lib/active_support/buffered_logger.rb:104:in `write'
/Users/yury/.rvm/gems/ruby-1.9.2-p180@railspre/gems/activesupport-3.1.0.beta1/lib/active_support/buffered_logger.rb:104:in `block (2 levels) in flush'
/Users/yury/.rvm/gems/ruby-1.9.2-p180@railspre/gems/activesupport-3.1.0.beta1/lib/active_support/buffered_logger.rb:103:in `each'
/Users/yury/.rvm/gems/ruby-1.9.2-p180@railspre/gems/activesupport-3.1.0.beta1/lib/active_support/buffered_logger.rb:103:in `block in flush'
<internal:prelude>:10:in `synchronize'
/Users/yury/.rvm/gems/ruby-1.9.2-p180@railspre/gems/activesupport-3.1.0.beta1/lib/active_support/buffered_logger.rb:102:in `flush'
/Users/yury/.rvm/gems/ruby-1.9.2-p180@railspre/gems/activesupport-3.1.0.beta1/lib/active_support/log_subscriber.rb:84:in `block in flush_all!'
/Users/yury/.rvm/gems/ruby-1.9.2-p180@railspre/gems/activesupport-3.1.0.beta1