Skip to content

Instantly share code, notes, and snippets.

View adymo's full-sized avatar

Alexander Dymo adymo

View GitHub Profile
@adymo
adymo / iterator_each_with_index.rb
Last active January 27, 2016 16:41
Example of each_with_index iterator creating extra objects
GC.disable
before = ObjectSpace.count_objects
Array.new(10000).each do |i|
[0,1].each_with_index do |j, index|
end
end
after = ObjectSpace.count_objects
puts "# of arrays: %d" % (after[:T_ARRAY] - before[:T_ARRAY])
puts "# of extra Ruby objects: %d" % (after[:T_NODE] - before[:T_NODE])
@adymo
adymo / iterator_investigation.rb
Created January 27, 2016 15:05
Ruby Nested Iterator Performance Investigation
require 'csv'
GC.disable
methods = [:all?, :any?, :chunk, :collect, :collect_concat, :compact, :count, [:cycle, 1], :delete_if, :detect, :drop_while, :each_entry, :each, :each_index, :each_key, :each_pair, :each_value, :each_with_index, [:each_with_object, Object.new], :fill, :find, :find_all, :find_index, :flat_map, [:grep, 0], :group_by, :inject, :keep_if, :map, :none?, :one?, :reduce, :reject, :reverse, :reverse_each, :rotate, :select, :shuffle, :uniq]
# print only commonly used
methods = [:all?, :any?, :collect, [:cycle, 1], :delete_if, :detect, :each, :each_index, :each_key, :each_pair, :each_value, :each_with_index, [:each_with_object, Object.new], :fill, :find, :find_all, [:grep, 0], :inject, :map, :none?, :one?, :reduce, :reject, :reverse, :reverse_each, :select]
creators = [
def new_array
@adymo
adymo / gist:7b1e6db801ed6ae5c36f
Last active May 3, 2019 13:07
Kubuntu 15.04 Linux on Dell XPS 13 2015 High DPI Setup

Xorg resolution [works]

  • not detected automatically from edid
  • check physical screen dimensions with xrandr
  • put those into /etc/X11/xorg.conf.d/90-monitor.conf
      Section "Monitor"
        Identifier ""
        DisplaySize 293 165 # xrandr reports 294, but 293 makes it 277x277dpi instead of 276x277
      EndSection