Skip to content

Instantly share code, notes, and snippets.

View VorontsovIE's full-sized avatar

Ilya Vorontsov VorontsovIE

View GitHub Profile
@VorontsovIE
VorontsovIE / oj_install.log
Created September 23, 2012 10:45
gem intall oj - log
C:/Ruby193/bin/ruby.exe extconf.rb
>>>>> Creating Makefile for ruby version 1.9.3 <<<<<
creating Makefile
make
generating oj-i386-mingw32.def
compiling cache.c
cache.c: In function 'oj_cache_new':
cache.c:54:5: warning: implicit declaration of function 'bzero'
cache.c:54:5: warning: incompatible implicit declaration of built-in function 'bzero'
@VorontsovIE
VorontsovIE / dci_example.rb
Created November 10, 2012 08:08
DCI how I want it to work
module BadFlyer
def fly
puts 'Not a chance'
false
end
end
module Runner
def run
puts 'Run, #{self}! Run!'
@VorontsovIE
VorontsovIE / multi_testcases.rb
Last active December 16, 2015 11:19
Run multiple test-cases at the same time.
def wrong_result(meth, args, expected, real)
$stderr.puts "test #{meth}(#{args.map(&:inspect).join(',')}) expected to be #{expected} but was #{real}"
end
def failed_test(meth, args, expected, exception)
$stderr.puts "test #{meth}(#{args.map(&:inspect).join(',')}) expected to be #{expected} but raised an error #{exception}"
end
def test_method(meth, test_cases)
@VorontsovIE
VorontsovIE / defnil.rb
Last active December 16, 2015 11:29 — forked from sherpc/defnil.rb
module DefNil
def defnil(meth)
self.class.class_eval do
alias_method "#{meth}_before_defnil", meth
define_method meth do |first_arg, *args, &block|
if first_arg
send("#{meth}_before_defnil", first_arg, *args, &block)
else
nil
end
@VorontsovIE
VorontsovIE / defnil.rb
Last active December 16, 2015 11:29 — forked from sherpc/defnil.clj
# Если ты создаешь новую функцию, а не меняешь старую, то всё проще, конечно.
def nillified(&block)
->(first_arg, *args) {
first_arg ? block.call(first_arg, *args) : nil
}
end
f = nillified{|x,y| x + y }
@VorontsovIE
VorontsovIE / js_calc.js
Created September 4, 2014 06:45
JS calc
var emcntnt = '' +
'<h2 id = "osemi-header">Рассчитать стоимость услуг</h2>' +
'<div class = "emi-form"><table class = "table table-bordered">' +
'<tr class = "outstanamount">' +
'<td>Количество документов в месяц:</td> ' +
'<td>' +
'<div> <input type = "text" placeholder = "0.00" id = "outstanding_principle" value = "0" onchange = "calculateEMI();"></div>' +
'<div id = "osp_range"></div>' +
'</td>' +
'</tr>' +
import os, sys
currentdir = os.path.dirname(os.path.abspath(__file__))
parentdir = os.path.dirname(currentdir)
sys.path.insert(0, parentdir)
import wikilib
import parsing_dates
import apiRequest
import parseToDB
import sys
def check_sum(xs_head_sum, xs_tail, goal_sum, equation_head):
if len(xs_tail) == 0:
if xs_head_sum == goal_sum:
return '{}={}'.format(equation_head, goal_sum)
else:
return None
result_1 = check_sum(xs_head_sum + xs_tail[0], xs_tail[1:], goal_sum, '{}+{}'.format(equation_head, xs_tail[0]))
if result_1:
return result_1
result_2 = check_sum(xs_head_sum - xs_tail[0], xs_tail[1:], goal_sum, '{}-{}'.format(equation_head, xs_tail[0]))
#!/bin/bash
testfile=`realpath $1`
FEATURE=`echo $1 | xargs basename | sed -re 's/\.test\.tsv$//'`
CL=`echo $FEATURE | sed -re 's/^([^.]+)\..+$/\1/'`
if [ "$CL" == "all" ]; then
DIRNAME=`echo $1 | xargs dirname | xargs --replace echo {}/.. | xargs realpath`
train_file="${DIRNAME}/train/${FEATURE}.train.tsv"
fit_file="${DIRNAME}/fit_chr_not2_9_22/${FEATURE}.fit_chr_not2_9_22.tsv"
validation_file="${DIRNAME}/val_chr_2_9_22/${FEATURE}.val_chr_2_9_22.tsv"
@VorontsovIE
VorontsovIE / winnie.py
Created December 5, 2018 23:55
Winnie - step 1
import random
state = 'start'
Tram = 0.5
param = 0.5
pa = 3/8
pam = 5/8
Trym = 2/7
Tyrym = 5/7
pym = 1