Skip to content

Instantly share code, notes, and snippets.


Maciek Rząsa mrzasa

  • Toptal
  • Rzeszów
View GitHub Profile
mrzasa /
Last active Feb 14, 2019 — 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 Jan 19, 2019
Find intersection of arrays
View intesection.rb
# arrays
result = []
# initial data
values ={|a|}
while true
maximal_value = values.max
for i 0...values.size do
mrzasa / benchmark-results.txt
Created Sep 10, 2018
View benchmark-results.txt
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 Sep 10, 2018
View benchmark.rb
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+?,?)+?/
View roo-percents-as-strings.xlsx
$ 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)

#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 Oct 13, 2016
ActiveRecord::AssociationRelation vs ActiveRecord::Associations::CollectionProxy
View devices.rb
> 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)
View finder_shared_example.rb
# 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) { ... }
View stats.rb
# 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
mrzasa / gist:cf189b681d39f73cc7b4
Last active Aug 29, 2015
Array wrap and splat
View gist:cf189b681d39f73cc7b4
def print3(a,b,c)
puts "a: #{a}, b: #{b}, c:#{c}"
a = [1,2,3]
b =, 1)
c = {|i| i*2}