Skip to content

Instantly share code, notes, and snippets.

View rickhull's full-sized avatar

Rick Hull rickhull

View GitHub Profile
@rickhull
rickhull / happy_eyeballs.rb
Last active February 8, 2023 01:36
Happy Eyeballs
View happy_eyeballs.rb
require 'thread'
class ThreadInterrupt < RuntimeError; end
def try_ip
if rand(2).zero?
sleep 0.5
true
else
sleep(rand(5) + 1)
@rickhull
rickhull / output.txt
Last active January 17, 2023 01:20
What are the available Unix Socket types in Ruby (on Linux)?
View output.txt
best [:SOCK_STREAM, :SOCK_DGRAM, :SOCK_SEQPACKET]
:SOCK_STREAM TYPE SOCK_STREAM
:SOCK_DGRAM TYPE SOCK_DGRAM
:SOCK_SEQPACKET TYPE SOCK_SEQPACKET
other [nil, :SOCK_RAW]
nil TYPE SOCK_STREAM
:SOCK_RAW TYPE SOCK_DGRAM
unsupported [:SOCK_RDM, :SOCK_PACKET, :SOCK_NONBLOCK, :SOCK_CLOEXEC]
@rickhull
rickhull / configuration.nix
Last active October 27, 2023 11:34
Prometheus, Grafana, Loki, Promtail on NixOS
View configuration.nix
# MONITORING: services run on loopback interface
# nginx reverse proxy exposes services to network
# - grafana:3010
# - prometheus:3020
# - loki:3030
# - promtail:3031
# prometheus: port 3020 (8020)
#
services.prometheus = {
@rickhull
rickhull / shell.nix
Last active July 5, 2020 22:33
shell.nix that prepares tildes for pytest
View shell.nix
with import <nixpkgs> {};
with python3Packages;
let
testing_common_database = buildPythonPackage rec {
pname = "testing.common.database";
version = "2.0.3";
src = fetchPypi {
inherit pname version;
View configuration.nix
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).
{ config, pkgs, ... }:
{
imports =
[ # Include the results of the hardware scan.
./hardware-configuration.nix
View gist:f940d107fd13e725a29d62af25189e4f
gggI trained Aikido for many years. About the third year, I began a very basic rings routine coupled with running two miles per day. The running meant I no longer ran out of breath during class unless I was testing. The rings meant my hip speed was faster than ever before and I could counter just about every attack with a level of comfort I never had before the rings.
Because my core was so stable and strong, when I turned my hips, my feet and shoulders moved at the same time, like a door. Long lanky me became super quick for the first time in my life. Better shape and posture than in college basketball. Still skinny, but deceptively strong, even at extreme angles.
No injuries to shoulders and a chronic back pain between my shoulder blades went away (shiatsu also played a roll in the pain going away).
What was my ring routine? Dead hangs every day, adding a second a day (that's all; one second) until I could hang for two minutes. This took a few months.
Then I started over with one arm dead hangs until e
View private_methods.rb
class Foo
def initialize
@foo = :foo
end
private
def bar
:bar
end
View constant_lookup_with_nesting.rb
# normal nesting
module Outer
X = 1
Y = 2
class C
X = Y
end
end
# alternative nesting
View command-processor.rb
def self.def_builtin_commands(delegation_class, command_specs)
for meth, args in command_specs
arg_str = args.collect{|arg| arg.downcase}.join(", ")
call_arg_str = args.collect{
|arg|
case arg
when /^(FILENAME.*)$/
format("expand_path(%s)", $1.downcase)
when /^(\*FILENAME.*)$/
# \*FILENAME* -> filenames.collect{|fn| expand_path(fn)}.join(", ")
View minirake_output.txt
rwh@DESKTOP-VA6OTK5:/mnt/c/Users/Rick/git/mruby_tools/mruby$ ruby minirake --trace
(in /mnt/c/Users/Rick/git/mruby_tools/mruby)
/mnt/c/Users/Rick/git/mruby_tools/mruby/tasks/toolchains/gcc.rake:38: warning: Insecure world writable dir /mnt/c in PATH, mode 040777
/mnt/c/Users/Rick/git/mruby_tools/mruby/bin/mrbc
/mnt/c/Users/Rick/git/mruby_tools/mruby/bin/mirb
/mnt/c/Users/Rick/git/mruby_tools/mruby/bin/mruby
/mnt/c/Users/Rick/git/mruby_tools/mruby/bin/mruby-strip
/mnt/c/Users/Rick/git/mruby_tools/mruby/bin/mrdb
/mnt/c/Users/Rick/git/mruby_tools/mruby/build/test/bin/mirb
/mnt/c/Users/Rick/git/mruby_tools/mruby/build/test/bin/mruby