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
apt install linux-image-5.4.0-0.bpo.2-amd64 linux-headers-5.4.0-0.bpo.2-amd64 | |
apt-get -t buster-backports install linux-image-5.4.0-0.bpo.2-amd64 linux-headers-5.4.0-0.bpo.2-amd64 | |
sudo dd bs=4M if=debian-10.4.0-amd64-netinst.iso of=/dev/sde status=progress oflag=sync | |
/etc/init.d/network-manager start | |
deb http://deb.debian.org/debian buster-backports main | |
firmware-amd-graphics |
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
#!/bin/bash | |
# always try to start notes | |
session_name="!notes" | |
tmux has-session -t "$session_name" > /dev/null 2>&1 | |
if [ $? != 0 ]; then | |
echo "starting session: $session_name" | |
tmux new-session -s "$session_name" -d | |
tmux rename-window -t "$session_name" "$session_name" | |
tmux send-keys -t "$session_name" "vim $DROPBOX_DIR/notes.txt" C-M |
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
# inherit from Enumerator | |
class Pager1 < Enumerator | |
def initialize(url, page_size: 100, max_pages: Float::INFINITY, first_page: 0) | |
@url = url | |
super() do |receiver| | |
page = first_page | |
pages = [] | |
while page < (first_page + max_pages) | |
get(page, page_size).each do |row| | |
receiver.yield row |
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
Rules = { | |
enter: [ 'created' ], | |
exit: [ 'completed' ], | |
uncancelable: %w[ completing completed ], | |
tasks: [ | |
{ | |
name: 'tag', | |
desc: 'taggable', | |
transitions: [ | |
{ from: { state: 'tagging', :status: 'pending' }, to: { state: 'tagged' } }, |
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
require 'pp' | |
Rules = [ | |
{ | |
is: { state: 'created', status: 'pending', provider: 'aws' }, | |
in: 'taggable', | |
to: { state: 'tagged' }, | |
as: { state: 'tagging' }, | |
on: 'housekeeper' | |
}, |
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
require 'concurrent' | |
MAX_THREADS = 20 | |
class Job | |
def step | |
sleep 3 # simulates performing the next task in the jobs workflow | |
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
# | |
# The key thing to understand about this is that an `ensure` section is not guarnteed to run! | |
# | |
# If code executing is in the main thread of the process and a Interrupt, caused by a SIGINT or SIGTERM, occurs | |
# `ensure` blocks in that thread will not be executed. This is because Interrupt is an asynchrnous event and | |
# Ruby has no way to return to the point in execution it left when the signal happened. | |
# | |
# But, because Interrupts are only processed in the main thread of a process, moving all the actual code of an | |
# application into a child thread fixes this problem. | |
# |
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
#!/bin/sh | |
tmux has-session -t notes > /dev/null 2>&1 | |
if [ $? != 0 ]; then | |
echo 'starting session: notes' | |
tmux new-session -s notes -d | |
tmux rename-window -t notes notes | |
tmux send-keys -t notes "vim $DROPBOX_DIR/documents/notes.txt" C-M | |
fi |
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
require 'logger' | |
# This logger will notice the log has been rotated and reopen it. | |
# The logrotate options must include 'nocreate'. | |
class RotatableLogger < Logger | |
def add(*args) | |
reopen if @logdev.filename && !File.exist?(@logdev.filename) | |
super | |
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
class Channel < SizedQueue | |
def initialize | |
super(1) | |
end | |
end | |
channel = Channel.new | |
Thread.new(channel) do |ch| | |
val = rand(3.0) + 1.0 |