This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
comps = ["PC", "MAC", "PC", "PC", "LINUX", "MAC", "DIDAKTIK"] | |
duplicities = comps.group_by{|x| x.first}.find_all{|k,v| v.size > 1}.map{|x| x.first} | |
duplicities # => ["MAC","PC"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Usage: | |
# | |
# Then directory "tmp/sample" should have the following tree: | |
# """ | |
# monday | |
# | beer.rb | |
# tuesday | |
# | vodka.php | |
# | wine.rb | |
# wednesday |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Why it is not a good idea to rescue without explicit exception type? | |
# Because: | |
# | |
# begin | |
# "..." | |
# rescue | |
# end | |
# | |
# Handles only StandardError descendants (no Excpetion descendants catched) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_distribution env, id | |
self.repos(env).map do |repo| | |
repo.distributions.find_all {|d| d.id == id } | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Disable ctrl-alt-backpace (restart X11) server. | |
# Put into /etc/X11/xorg.conf.d | |
Section "ServerFlags" | |
Option "DontZap" "yes" | |
EndSection |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unbind C-b | |
set -g prefix F12 | |
# Use vim-like keys for moving around | |
bind h select-pane -L | |
bind j select-pane -D | |
bind k select-pane -U | |
bind l select-pane -R | |
bind C-h select-pane -t :- | |
bind C-l select-pane -t :+ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*background: black | |
*foreground: white | |
xterm*background: #3c3c3c | |
urxvt*depth: 32 | |
urxvt*background: rgba:1111/1111/1111/ffff | |
URxvt.scrollBar: false | |
URxvt.tabbed.tabbar-fg: 4 | |
URxvt.tabbed.tabbar-bg: -1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[<<EOS1, <<EOS2, <<EOS3] | |
This is | |
an array | |
EOS1 | |
of very very | |
very very | |
EOS2 | |
long strings | |
EOS3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# shift indented text to the left as much as possible | |
def align_indented(text) | |
shift_left = text.lines.map { |l| l[/^\s*/].size }.min | |
text.lines.map { |l| l[shift_left..-1] }.join | |
end | |
puts align_indented(<<TEXT) | |
this is some | |
indented text | |
we would like to |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%w[one two three].each do |method| | |
define_method method do |*args| | |
"My uebercool method #{method}" | |
end | |
end |