Skip to content

Instantly share code, notes, and snippets.

Mckomo mckomo

  • Poland
View GitHub Profile
@mckomo
mckomo / extract_string.rb
Last active Jun 5, 2018
Kata extract_strings.rb
View extract_string.rb
def extract_strings(object)
# TODO
end
errors = {
options: {
frequency_limits: [
{
time_unit: [
'must be one of: day, week, month'
View gist:480546f2d91811510cb1262d9dfa8c26
Test Suite 'All tests' started at 2017-08-20 15:59:02.890
Test Suite 'AirMonitorBotPackageTests.xctest' started at 2017-08-20 15:59:02.890
Test Suite 'WebhookControllerTests' started at 2017-08-20 15:59:02.890
Test Case '-[AppTests.WebhookControllerTests test_get_without_verification_params]' started.
/Users/mckomo/Projects/AirMonitor/AirMonitorBot/Tests/AppTests/WebhookControllerTests.swift:15: error: -[AppTests.WebhookControllerTests test_get_without_verification_params] : failed - expected to equal <badRequest>, got <ok>
Test Case '-[AppTests.WebhookControllerTests test_get_without_verification_params]' failed (0.073 seconds).
Test Suite 'WebhookControllerTests' failed at 2017-08-20 15:59:02.963.
Executed 1 test, with 1 failure (0 unexpected) in 0.073 (0.073) seconds
Test Suite 'AirMonitorBotPackageTests.xctest' failed at 2017-08-20 15:59:02.963.
View eventStub.js
const eventStub = value => ({
stopPropagation: () => {},
preventDefault: () => {},
persist: () => {},
target: {
value,
checked: value,
},
...value,
});
View recursive-reverse.js
const list = ['m', 'c', 'k', 'o', 'm', 'o']
const reverse = (list) => {
if (list.length == 0) return [];
let first = list.splice(0, 1);
return reverse(list).concat(first);
}
@mckomo
mckomo / curry.js
Last active Jul 5, 2016
JS implementation of curry function with some ES6 sugar.
View curry.js
function curry(fn) {
const arity = fn.length;
const curring = function() {
var args = asArray(arguments);
if (args.length >= arity) {
return fn(... args);
@mckomo
mckomo / roulette.cpp
Created Feb 16, 2015
Roulette progression strategy simulator
View roulette.cpp
#include <random>
#include <iostream>
#define START_CREDITS 1000
#define PROGRESSION_RATION 2
#define MINIMAL_BET 0.5
bool is_odd(int result)
{
return result % 2 == 1;
@mckomo
mckomo / missing_integer.rb
Created Dec 27, 2014
Codility – MissingInteger
View missing_integer.rb
def solution(a)
n = a.length
r = (1 .. n).to_a
diff = r - a
if diff.empty?
return n+1
end
@mckomo
mckomo / pretty_json.rb
Last active Aug 29, 2015
Liquid filter suited for Jekyll that generates pretty JSON output.
View pretty_json.rb
module Jekyll
module PrettyJsonFilter
def pretty_json(input)
begin
JSON.pretty_generate(input)
rescue JSON::GeneratorError => e
"Error: #{e}."
end
end
View counter.rb
class Counter
def initialize
@counter = "0"
end
def hit
@counter.replace( increment_string( @counter ) ); @counter.dup
end
You can’t perform that action at this time.