Skip to content

Instantly share code, notes, and snippets.

View mrzasa's full-sized avatar

Maciek Rząsa mrzasa

  • Toptal
  • Rzeszów
View GitHub Profile
mrzasa / Gemfile
Last active December 12, 2022 12:16
Failure in RSpec aggregate_failures with mocks
# frozen_string_literal: true
source ''
gem 'rspec'
mrzasa /
Last active February 14, 2019 21:50 — forked from hakee/Auto-Suggestion
How Google Won User's Heart :: Google Auto-Suggestion/Auto-Completion Algorithm Exposed

How Auto Suggestion Works e.g. How Google Won User's Heart

You've seen search engines suggest queries when you begin typing the first few letters of your search string. This is being done by Duck Duck Go as well as Google (to name a few). This is typically done by maintaining a list of past queries and/or important strings that the search engine thinks are worthy of being suggested to a user that is trying to find something similar. These suggestions are effective only if the search engine spits them out very fast since these should show up on the screen before the user has finished typing what he/she wanted to type. Hence the speed with which these suggestions are made is very critical to the usefulness of this feature.

Let us consider a situation (and a possible way of approaching this problem) in which when a user enters the first few letters of a search query, he/she is presented with some suggestions that have as their prefix, the string that the user has typed. Furthermore, these suggestions shou

mrzasa / intesection.rb
Last active January 19, 2019 15:03
Find intersection of arrays
# arrays
result = []
# initial data
values ={|a|}
while true
maximal_value = values.max
for i 0...values.size do
mrzasa / benchmark-results.txt
Created September 10, 2018 14:30
unrolling: 1299.0 i/s
possessive: 1146.9 i/s - same-ish: difference falls within error
greedy: 63.4 i/s - 20.48x slower
lazy: 61.8 i/s - 21.03x slower
mrzasa / benchmark.rb
Created September 10, 2018 14:25
require "benchmark/ips"
A text with 123,21231,231,23d a number: 12,212,234,12
Other 12 43 123,21231,22,22,2,33d Some other 9012,123123 12
TEXT = PART * 100
POSSESSIVE = /(\d++,?)++/
LAZY = /(\d+?,?)+?/
mrzasa / roo-percents-as-strings.xlsx
Last active February 17, 2017 11:28
Roo percent values
$ pry
[1] pry(main)> require "roo"
=> true
[2] pry(main)> require "roo/version"
=> true
[3] pry(main)> Roo::VERSION
=> "2.7.1"
[4] pry(main)> sheet ="roo-percents-as-strings.xlsx", extension: "xlsx")
=> <#Roo::Excelx:1257514717731600 @tmpdir @shared @filename @sheet_files @sheet_names @sheets @sheets_by_name @options @cell @cell_type @cells_read @first_row @last_row @first_column @last_column @header_line>
[5] pry(main)> sheet.formatted_value('A', 1)
mrzasa /
Last active November 9, 2021 02:06 — forked from wenhuizhang/
distributed systems readings

#Distributed System Course List


  • Cornell CS 614 - Advanced Course in Computer Systems - Ken Birman teaches this course. The readings cover more distributed systems research than is typical (which I am in favour of!). In fact, there's barely anything on traditional internal OS topics like filesystems or memory management. There's some worthwhile commentary at the bottom of the page.

  • Princeton COS 518 - Advanced Operating Systems - short and snappy reading list of two papers per topic, covering some interesting stuff like buffering inside the operating system, and L4.

mrzasa / devices.rb
Last active October 13, 2016 14:50
ActiveRecord::AssociationRelation vs ActiveRecord::Associations::CollectionProxy
> user.devices.all.uniq.class
=> Device::ActiveRecord_AssociationRelation
# so that we can chain more AR methods
> user.devices.all.uniq.limit(1)
=> [Device]
> u.devices.uniq.class
=> Array
# so we can only work on array:
> user.devices.uniq.limit(1)
# This file contains shared examples that helps testing classes that has
# finder methods (e.g. ActiveRecord model classes).
# It accepts :expected, :others and :results params
# passed with let blocks:
# it_behaves_like :finder do
# let(:results) { ... }
# let(:expected) { ... }
# let(:others) { ... }
# This file is an implementation of multi-level statistics.
# Value object. It can be created basing on SQL output.
SingleSubmissionStats =, :retreat_type,
:retreat_level, :retreat_type_and_level_id,
:gender, :reserve, :status, :count)
# Vlass responsible for calculating various staatistics.
# It contains a stats array that can consist of SingleSubmissionStats