Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View caius's full-sized avatar
👻

Caius Durling caius

👻
View GitHub Profile
@caius
caius / gist:6669933
Created September 23, 2013 12:48
Script to grab MSFT Virtualbox VMs for mac
require "net/http"
require "uri"
base_dir = File.expand_path(ARGV.first || ".")
response = Net::HTTP.get(URI("http://www.modern.ie/en-us/virtualization-tools"))
urls = response.scan(/[^"'\s]+VirtualBox\/OSX[^"'\s]+/)
urls.each do |u|
name = u[%r{VirtualBox/OSX/([^/]+)}, 1]
# .. snip ..
# Lifted from https://grafana.com/docs/grafana-cloud/quickstart/docker-compose-linux/#step-1-create-the-compose-file on 2022-10-07
grafana-node-exporter = {
# https://github.com/prometheus/node_exporter/releases
image = "prom/node-exporter:v1.7.0";
autoStart = true;
extraOptions = [
"--cpus=1"
"--memory=512m"
];
@caius
caius / my-jobs.rb
Last active January 16, 2024 18:43
ActiveJob::Base.queue_adapter = :delayed
$stdout.sync = true
$stdout.flush
class MyBaseJob < ActiveJob::Base
# Stop delayed retrying at all
def max_attempts
0
end
Error = Class.new(StandardError)
class Client
Error = Class.new(StandardError)
def call
raise "ZOMG"
rescue => e
raise Error.new("Uh oh #{e.inspect}")
end
@caius
caius / our_inflector.rb
Created October 16, 2023 20:18
Zeitwerk Inflector for full path -> Constant
# frozen_string_literal: true
# Custom inflector for Zeitwerk
#
# The default inflector at ActiveSupport::Dependencies::ZeitwerkIntegration::Inflector only
# lets us override by `basename`, but we have both `Thing` and `THING` defined as constants
# in the app so that doesn't work for us. Rather than rename everything just now, work around it
# by letting us define overrides by _filepath_ (`abspath`) as well as `basename`.
#
# NB: Normally we'd subclass the default implementation, but it's a Module so can't do that.
@caius
caius / settings.json
Created October 2, 2023 10:17
Zed Config 2023-10-02
{
"auto_update": true,
"base_keymap": "TextMate",
"default_dock_anchor": "bottom",
"projects_online_by_default": false,
"theme": "Ayu Light",
"buffer_font_family": "FiraCode Nerd Font Mono",
"buffer_font_size": 14,
"tab_size": 2,
"hard_tabs": false,
def output name=((default=true); "caius")
puts "name: #{name.inspect}"
puts "default: #{default.inspect}"
end
output
# >> name: "caius"
# >> default: true
output "avdi"
require "benchmark/ips"
Benchmark.ips do |b|
b.report("Array.new block") do
Array.new(100) { 10 }
end
b.report("Array.new argument") do
Array.new(100, 10)
end
{
auto_https off
}
:8080 {
root * .
file_server
templates
}
// something
{
"one": true,
"bar": "Something",
}