Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View makaroni4's full-sized avatar

Anatoli Makarevich makaroni4

View GitHub Profile
@makaroni4
makaroni4 / duolingo.js
Created September 27, 2015 21:12
Grace Monkey script to show the remain lessons count
$(function(){
function drawLessonsCount(count) {
$(".topbar-nav-main").append("<li style='display: block; color: #fff; padding: 8px 15px;'>Осталось уроков: " + count + "</li>");
}
function countLessons() {
var count = 0;
$(".lessons-left").each(function(index, element) {
var text = $(element).text();
RSpec::Matchers.define :terminate do |code|
actual = nil
def supports_block_expectations?
true
end
match do |block|
begin
block.call
@makaroni4
makaroni4 / dup_finder.rb
Created May 6, 2015 19:55
Duplicates finder
require 'digest/md5'
hash = {}
dirname = "files"
Dir.glob("#{dirname}/**/*", File::FNM_DOTMATCH).each do |filename|
next if File.directory?(filename)
# puts 'Checking ' + filename
key = Digest::MD5.hexdigest(IO.read(filename)).to_sym
@makaroni4
makaroni4 / mimimetrics_customer_counts.rb
Created August 10, 2014 09:17
Реализация отправки CustomerCount данных в Mimimetrics API на Ruby
require 'net/http'
require 'uri'
require 'json'
def send_operation()
data = {
customer_count: {
count: "45",
datetime: "2007-09-01T21:30:04.000+04:00",
}
@makaroni4
makaroni4 / mimimetrics_cpas.rb
Created August 10, 2014 09:14
Пример запроса к API Mimimetrics для отправки данных о CPA
require 'net/http'
require 'uri'
require 'json'
def send_operation()
data = {
cpa: {
amount: "24215140440800001402186",
datetime: "2007-09-01T21:30:04.000+04:00",
}
@makaroni4
makaroni4 / mimimetrics.rb
Created August 10, 2014 09:10
Реализация отправки Operation данных в Mimimetrics API на Ruby
require 'net/http'
require 'uri'
require 'json'
def send_operation()
data = {
operation: {
operation_id: "24215140440800001402186",
amount: 571.13,
direction: "in",
def smart_subtract(arr_1, arr_2, action)
hash_1 = Hash[arr_1]
hash_2 = Hash[arr_2]
result = []
hash_1.each do |key, value|
if hash_2[key]
result << [key, value.send(action, hash_2[key])]
else
result << [key, value]
require 'benchmark/ips'
Benchmark.ips do |r|
r.report("mass") do
a, b, c, d = 1, 2, 3, 4
end
r.report("step by step") do
a = 1
b = 2
require 'benchmark/ips'
require 'benchmark'
Benchmark.ips do |r|
r.report("one") do
'string' + 'string'
end
r.report("two") do
"string" + "string"