Skip to content

Instantly share code, notes, and snippets.

@eagleas
eagleas / 1.rb
Last active March 31, 2016 10:24
if depend_options[question[:id]]
hash.delete_if { |k, v| !depend_options[question[:id]].include?(k) }
depend_options[question[:id]].sum{ |opt_id| (hash[opt_id] || 0) }
else
s1 = hash.reject { |k, v|
res = cnt_replies_by_question.keys.include?(k)
puts Anketa::Question.find(k).skey if !res
res
}.values.max || 0
puts "+++ #{s1}" if s1 > 0
@eagleas
eagleas / main.rb
Created January 19, 2015 14:55
export code
module Questionary
class Main < Serializer
def values
# Продукт
options :product_demand, -> {
radio_inherit_a :product_demand, ->(b){
b[0].sub(/Спрос пока не проверяли/i, 'no').
sub(/Спрос проверили, но продаж пока еще нет/i, 'nosale').
scan report for yeti.adlabs.ru (89.188.116.34)
Host is up (0.013s latency).
Not shown: 991 closed ports
PORT STATE SERVICE VERSION
25/tcp filtered smtp
79/tcp filtered finger
80/tcp open http nginx 1.4.1 (Ubuntu)
|_http-methods: No Allow or Public header in OPTIONS response (status code 301)
|_http-title: Did not follow redirect to https://yeti.adlabs.ru/
111/tcp filtered rpcbind
@eagleas
eagleas / .bash_aliases
Created March 15, 2013 13:29
.bash_aliases with git shortcuts
HISTSIZE=10000
export HISTSIZE
bind '"\e[A": history-search-backward'
bind '"\e[B": history-search-forward'
source /etc/bash_completion.d/git
export PS1='[\u@\h:\w $(__git_ps1 "(%s)")]\$ '
__define_git_completion () {
@eagleas
eagleas / .irbrc
Last active December 14, 2015 22:49
irb with history
require 'irb/ext/save-history'
#History configuration
IRB.conf[:SAVE_HISTORY] = 1000
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-save-history"
module Webmoney
# Presets for interfaces
def interface_urls
{
:create_invoice => { :url => w3s_url + 'XMLInvoice.asp', :x509 => true } # x1
#...
:check_owner => { :url => 'https://apipassport.webmoney.ru/XMLCheckUser.aspx', # x19
:x509 => lambda {|url| url.sub(/\.aspx$/, 'Cert.aspx')} }
:bussines_level => { :url => 'https://stats.wmtransfer.com/levels/XMLWMIDLevel.aspx' }
#...
@eagleas
eagleas / all.rb
Created December 16, 2011 12:58
files slider
#encoding: utf-8
class File::Base < ActiveRecord::Base
scope :shared, where(["files.shared_at IS NOT NULL AND (files.shared_at + CAST('1 hour' AS INTERVAL) * files.shared_hours > NOW())"])
def shared=(value)
@shared =
if value.nil? || value == '0'
shared_expire!
false
$: << File.expand_path("../../lib", __FILE__)
require 'database_cleaner'
require 'mongoid'
require 'mongoid-rspec'
require 'mongoid_token'
require 'benchmark'
Mongoid.configure do |config|
config.master = Mongo::Connection.new.db("mongoid_token_benchmark")
# user system total real
# base64: 1.120000 0.030000 1.150000 ( 1.187320)
# pack: 0.170000 0.040000 0.210000 ( 0.207054)
#
require 'benchmark'
require 'base64'
N = 1000
$ rake test:spec
(in /home/asor/rails/git-wiki)
bacon -q -Ilib:test test/wiki_resource_test.rb test/request_test.rb test/wiki_config_test.rb test/string_extensions_test.rb test/wiki_util_test.rb test/wiki_templates_test.rb test/hash_extensions_test.rb test/wiki_factory_test.rb test/wiki_page_test.rb test/object_extensions_test.rb test/wiki_tree_test.rb test/wiki_hooks_test.rb
/home/asor/rails/git-wiki/plugins/misc/changelog.rb:12: warning: don't put space before argument parentheses
/home/asor/rails/git-wiki/plugins/misc/changelog.rb:14: warning: don't put space before argument parentheses
..........FFF..FF.....................F....................
Bacon::Error: #<Rack::MockResponse:0x95d1160 @headers={"Content-Type"=>"application/xhtml+xml;charset=utf-8", "Cache-Control"=>"no-cache"}, @status=500, @body="<span class=\"error\">git log failed</span>", @errors="", @original_headers={"Content-Type"=>"application/xhtml+xml;charset=utf-8", "Cache-Control"=>"no-cache"}>.redirect?() failed
./test/request_test.rb:77