Skip to content

Instantly share code, notes, and snippets.

View kzaitsev's full-sized avatar

Kirill Zaitsev kzaitsev

  • Limassol, Cyprus
View GitHub Profile
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@kzaitsev
kzaitsev / backup.sh
Last active December 20, 2015 18:28
zbackup
sshfs backup_name.your-backup.de: /backups
for dir in /home/deploy/apps/*
do
if [ -d "$dir/current" ]; then
if [ ! -d "/backups/$(echo $dir | sed 's#.*/##')" ]; then
mkdir "/backups/$(echo $dir | sed 's#.*/##')"
fi
if [ -f "$dir/shared/config/database.yml" ]; then
sudo -u deploy -H bash -c "source /usr/local/rvm/scripts/rvm && cd $dir/current && pwd && bundle exec rake db:dump RAILS_ENV=production"
if [ -f "$dir/current/db/data.yml" ]; then
{
data: [1]
0: {
SearchedAlso: [83]
0: {
Shows: 65790
Phrase: "срубы бань"
}-
1: {
Shows: 65785
ii libruby1.8 1.8.7.352-2ubuntu1.3 Libraries necessary to run Ruby 1.8
ii libruby1.9.1 1.9.3.0-1ubuntu2.7 Libraries necessary to run Ruby 1.9.1
ii ruby 4.8 Transitional package for ruby1.8
ii ruby-passenger 1:4.0.10-1bbox1~precise1 Rails and Rack support for Apache2 and Nginx
ii ruby-passenger-doc 1:4.0.10-1bbox1~precise1 Rails and Rack support for Apache2 - Documentation
ii ruby-rack 1.4.1-2~precise1 Modular Ruby webserver interface
ii ruby1.8 1.8.7.352-2ubuntu1.3 Interpreter of object-oriented scripting language Ruby 1.8
ii ruby1.8-dev 1.8.7.352-2ubuntu1.3 Header files for compiling extension modules for the Ruby 1.8
rc ruby1.9.1 1.9.3.0-1ubuntu2.7 Interprete
doc = Nokogiri::HTML(body)
doc.encoding = 'utf-8'
tic = 0
pr = 0
doc.search('div.resp-analysis/div#box-basik').each do | yandex |
content = yandex
if content.to_s.include?('-- тИЦ --')
tic = yandex.search('div.row-fluid/div.span4/div.pull-right/a.black.bold.noun')[0].text.to_s.split(' ').join.to_i
end
end
@kzaitsev
kzaitsev / es
Created September 29, 2013 23:22
# 2013-09-30 03:21:51:392 [_search] (["seobase-donors"])
#
curl -X GET 'http://127.0.0.1:9200/seobase-donors/donor/_search?load=true&size=25&pretty' -d '{"query":{"bool":{"must":[{"query_string":{"query":"*.*","default_operator":"AND"}}]}},"sort":[{"rating":"desc"}],"filter":{"term":{"links.project_id":"12"}},"size":25}'
# 2013-09-30 03:21:51:495 [200] (8 msec)
#
# {"took":8,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":117,"max_score":null,"hits":[{"_index":"seobase-donors","_type":"donor","_id":"2375","_score":null,"_source":{"id":2375,"name":"quote.rbc.ru","rating":20,"comment":"","google_anchor":0,"yandex_anchor":0,"google_index":1,"yandex_index":1,"exclude":null,"donor_type_id":1,"adviser_status":3,"tic":4000,"register_link":null,"broken_old":"","created_at":"2012-05-09T19:55:38.000Z","updated_at":"2013-09-23T22:42:37.544Z","browser_id":1,"broken":false,"pr":7,"last_pr":"2013-09-20T07:03:59.116Z","last_tic":"2013-09-18T03:42:53.657Z","links":[{"project_id":1,"status":
require 'http'
require 'colored'
require 'nokogiri'
$url = 'http://playo.ru/goods/241/#.Ur8zaWRdVmg'
$run = '/Applications/VLC.app/Contents/MacOS/VLC /Users/bugagazavr/Downloads/1.mp3'
$start_price = 695
def get
res = HTTP.get($url).response
@kzaitsev
kzaitsev / carrierwave.rb
Created January 15, 2014 19:44
Carrierwave + Selectel
CarrierWave.configure do |config|
if Rails.env.development? || Rails.env.test?
config.storage = :file
else
config.storage = :fog
config.fog_credentials = {
:provider => 'OpenStack',
:openstack_auth_url => 'https://auth.selcdn.ru/v1.0',
:openstack_username => Rails.application.secrets.openstack_username,
:openstack_api_key => Rails.application.secrets.openstack_api_key
@kzaitsev
kzaitsev / fog.txt
Created January 15, 2014 23:13
excon fog
excon.request {:chunk_size=>1048576, :ciphers=>"HIGH:!SSLv2:!aNULL:!eNULL:!3DES", :connect_timeout=>60, :debug_request=>false, :debug_response=>true, :headers=>{"User-Agent"=>"fog/1.19.0", "X-Auth-Key"=>"SOMEKEY", "X-Auth-User"=>"SOMEUSER", "Host"=>"auth.selcdn.ru:443"}, :idempotent=>false, :instrumentor_name=>"excon", :middlewares=>[Excon::Middleware::ResponseParser, Excon::Middleware::Expects, Excon::Middleware::Idempotent, Excon::Middleware::Instrumentor, Excon::Middleware::Mock], :mock=>false, :nonblock=>true, :omit_default_port=>false, :persistent=>false, :read_timeout=>60, :retry_limit=>4, :ssl_verify_peer=>true, :tcp_nodelay=>false, :uri_parser=>URI, :write_timeout=>60, :host=>"auth.selcdn.ru", :path=>"/v1.0", :port=>443, :query=>nil, :scheme=>"https", :user=>nil, :password=>"REDACTED", :instrumentor=>Excon::StandardInstrumentor, :expects=>[200, 204], :method=>"GET", :retries_remaining=>4, :connection=>#<Excon::Connection:7f976f534450 @data={:chunk_size=>1048576, :ciphers=>"HIGH:!SSLv2:!aNULL:!eNULL:!
@kzaitsev
kzaitsev / Gemfile
Created January 16, 2014 16:53
Gemfile
source 'http://rubygems.org'
source 'https://rails-assets.org'
gem 'rails', '4.1.0.beta1'
gem 'pg', '~> 0.17.1'
gem 'devise', '~> 3.2.2'
gem 'yaml_db', github: 'Teobit/yaml_db'
gem 'nokogiri', '1.6.0'
gem 'carrierwave', '~> 0.9.0'