Skip to content

Instantly share code, notes, and snippets.

View btihen's full-sized avatar

Bill Tihen btihen

  • Switzerland
View GitHub Profile
module RactorPool
# static sized pool with supervision
# use multi_use at own risk - be sure to collect results before submitting more messages
class WorkerPool
attr_reader :behavior, :inputs, :input_queue, :multi_use, :worker_count, :workers_pool
def self.call(input, behavior, options = {})
new(input, behavior, options)
end
module RactorPool
# using the ForkedJoin pattern - https://en.wikipedia.org/wiki/Fork%E2%80%93join_model
# this creates a worker pool (of Ractors) as large as the number of input messages
# and then collects the results upon completion - at which point the Ractors are
# removed from the worker pool and available to be garbage collected
# note: the injected behavior must respond to #call(input)
# usage: define a behavior that responds to #call(input)
# class Fibonacci
# def call(n) = [n, fib(n)]
# def fib(n) = n < 2 ? 1 : fib(n-2) + fib(n-1)
@btihen
btihen / gist:745aef5c2b3fedf6955a
Last active August 29, 2015 14:02
Utilization Analysis
# returns analysis
# Utilization
# Bash
echo "count day hour techs" > util-by-hr.csv
cat laptop-inventory.csv | cut -d';' -f44 | grep 2014 | cut -d'"' -f2 | sed 's/:[0-9][0-9]:[0-9][0-9]$/:00/g' | grep '2014-05' | sed 's/2014-05-//g' | grep '2[0-9]' | sort | uniq -c | awk ' {print $1, $2, $3, 1}' >> util-by-hr.csv
echo "count day time techs" > util-by-10min.csv
@btihen
btihen / gist:f2cef87050bc29a83d2d
Last active August 29, 2015 14:02
Return Analysis - needs colors, line graph (box plots too)
----------------
# returns analysis
# Start in Bash
# METHOD 1
curl -k https://inventory.las.ch/serial.csv?scope=computers > laptop-inventory.csv
cat laptop-inventory.csv | cut -d';' -f44 | grep 2014 | cut -d'"' -f2 > return-data.csv
@btihen
btihen / gist:11363359
Last active August 29, 2015 14:00
Retire via DB
use inventory;
UPDATE computers SET status='Retired' WHERE id='96';
UPDATE computers SET status='Retired' WHERE id='104';
UPDATE computers SET status='Retired' WHERE id='108';
UPDATE computers SET status='Retired' WHERE id='119';
UPDATE computers SET status='Retired' WHERE id='181';
UPDATE computers SET status='Retired' WHERE id='187';
@btihen
btihen / gist:10048345
Last active August 29, 2015 13:58
Inventory DB updates
USE inventory;
#ALTER TABLE computers ADD fleet_id INT(11) AFTER id;
#UPDATE computers SET fleet_id=date_made WHERE date_made REGEXP '^-?[0-9]+$';
#SELECT fleet_id FROM computers;
ALTER TABLE computers ADD fleetid TEXT AFTER id;
UPDATE computers SET fleetid=fleet_id;
#ALTER TABLE computers DROP fleet_id;
@btihen
btihen / gist:9714335
Last active August 29, 2015 13:57
.vimrc
git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle
cat <<EOF >> .vimrc
set tabstop=2 shiftwidth=2 expandtab
:set invlist
set listchars=eol:¬,tab:->,trail:~,extends:>,precedes:<
:set list
@btihen
btihen / gist:9327773
Last active August 29, 2015 13:56
MacOSX 10.9.2 upgrade fix
sudo diskutil repairPermissions /
sudo softwareupdate -dia
sudo diskutil repairPermissions /
sudo reboot
@btihen
btihen / gist:9327698
Created March 3, 2014 15:45
Brew Management
brew doctor
brew update
brew upgrade
brew cleanup