Skip to content

Instantly share code, notes, and snippets.

@a0s
a0s / vk_chat_stats.rb
Created October 8, 2015 09:33
VK chat stats by person
pp File.read('dump.txt').
scan(/class="mem_link"\starget="_blank">([^<]+)/m).
flatten.
inject(Hash.new(0)) { |total, e| total[e] += 1 ;total}.
map{|k,v| [v, k] }.
sort{|a, b| a[0] <=> b[0] }
@a0s
a0s / brew-cask-cleanup.rb
Last active November 5, 2019 14:14
Clean (move to trash) old brew cask versions
#!ruby
# Requirements:
# brew install trash
casks_path = '/opt/homebrew-cask/Caskroom'
class Version < Array
def initialize s
super(s.split('.').map { |e| e.to_i })
@a0s
a0s / steps.rb
Created May 5, 2015 21:57
Calculate optimal layer heights accordingly screw pitch and stepper motor #reprap
# Prints the value of the layer height corresponds to a whole number of steps
pitch = 1.25 # mm; 0.8mm for M5, 1.25mm for M8
substeps = 32 # 1,2,4,8,16 for A4988; 1,2,4,8,16,32 for DRV8825
motor_step = 1.8 # deg/step; 0.9 or 1.8 degrees/step
from = 0.00 # mm
to = 0.41 # mm; nozzle size
by = 0.01 # mm
accurate = 4 # decimal digits
# Update, upgrade and install development tools:
apt-get update
apt-get -y upgrade
apt-get -y install build-essential
apt-get -y install git-core
# Install rbenv
git clone git://github.com/sstephenson/rbenv.git /usr/local/rbenv
# Add rbenv to the path: