Skip to content

Instantly share code, notes, and snippets.

@wrzasa
wrzasa / 00_Comment.md
Last active April 27, 2022 11:52
Ruby 2.4 hash performance benchmark

This is a comment for blog post about improved Ruby 2.4 performance http://blog.redpanthers.co/behind-scenes-hash-table-performance-ruby-2-4/ The post describes improvements in Ruby 2.4 hash implementation and suggests 3x performance improvements.

The article proves that the benchmark presented at the beginning is misleading and suggests invalid conclusions. Since in 2.4 Hash stores list of its entries in sequential array, so the hash.values operation is immediate -- just need to copy the array. So there is significant performance gain comparing to 2.3, but it has nothing to do with performance of usual hash operations: insert, find, delete. Results of the presented benchmark cannot be used to predict performance gain of the other hash operations.

I repeated the experiment (like good physicists did in good old times recalled by Dijkstra) and added some more to test performance of the other operations. The benchmark and results can be found here: https://gist.github.com/wrzasa/6b456f73012ce98ae6feb6aaa4ba9

@wrzasa
wrzasa / notes.md
Created March 28, 2018 10:17
My Raspberry PI notes (in PL) from my RRUG.pl talk

RRUG#12 notatki o RaspberryPi

pins = [ 14, 15, 18, 23, 24, 25, 8, 7 ]
  1. Sprzęt (obrazki pin outu!)
  2. (WiringPi)
  3. RPi_GPIO
  • IN piny on/off
@wrzasa
wrzasa / collectd-squid-plugins
Last active February 9, 2018 20:08
Collectd plugins to read squid statistics.
Work for me with squid 3.4 on debian jessie.
I use it with collectd exec plugin (https://collectd.org/documentation/manpages/collectd-exec.5.shtml)
to collect data from squid, send it over the network to influxdb and visualize with grafana.
Maybe someone will have some use of it. Good luck ;-)
https://gist.github.com/wrzasa/dfd7b554171159a6b2ab24b03b8e30b8/

Czytam wypowiedzi o #NangaParbat wszystkich tych mędrków, którzy mają świat poukładany, poszufladkowany, wszystko jest dla nich takie proste -- każdy człowiek, każda pasja w odpowiedniej szufladce (idiota, nieodpowiedzialny, niemoralne, zbędne dla społeczeństwa). Są "normalni", wiedzą co jest społeczeństwu potrzebne, a co zbędne. Mogą nas o wszystkim pouczać i będą pouczać. Potrafią skwitować czyjąś pasję życia krótkim "egoistyczne ryzyko dla pustej sławy i adrenaliny". Najchętniej poukładaliby nam świat po swojemu i byłby doskonały! Mają tak wąskie spojrzenie, że nie mogą pojąć, że spojrzenie na świat może mieć jakiś wymiar poza ich szufladkami. I każdy kto do tego ciasnego modelu nie pasuje jest oczywiście pod takim czy innym względem "nienormalny", "nieprzystosowany", a jak do tego jeszcze były narkoman, to w ogóle rozwiązuje sprawę. Z resztą, ja się produkuję, a Tuwim już dawno doskonale to ujął.

Straszne mieszkania. W strasznych mieszkaniach
Strasznie mieszkają straszni mieszczanie.
Pleśnią i kopcie
system 'touch /tmp/test.file'
puts "Podaj wejście: "
we = gets
puts "Podałeś: #{we}"
@wrzasa
wrzasa / gist:8496245
Last active January 3, 2016 17:29
Testing a tool
time = Time.now
# sleep 7
puts (1..100).reduce(:*)
# sleep 70
system 'ls -alh /'
system 'ls -alh /mnt'
system 'whoami'
File.open "/mnt/testfile", "w" do |f|
f.puts "Zapisałem: #{Time.now}"
@wrzasa
wrzasa / introduction.rb
Last active October 12, 2015 15:38
My introduction, in Polish
# encoding: utf-8
class OMnie; def initialize
######################################
@imie = "Wojtek"
@nazwisko = "Rząsa"
@szczegoly = {
zawod:
"Informatyk",
w_DKS:
"Sprawy techniczne, informatyczne",
class InvoiceForm
attr_reader :params
def initialize(params)
@params = params
end
def billing_date
Time.new(*[:year, :month, :day].map { |k| params[k] or raise ArgumentError})
rescue ArgumentError
end
class InvoiceForm
attr_reader :params
def initialize(params)
@params = params
end
def billing_date
Time.new(params[:year], params[:month], params[:day])
rescue ArgumentError
end
#! /bin/sh
echo "Start"
#sleep $1
sleep 13
echo "Finish"