Skip to content

Instantly share code, notes, and snippets.

View fnordfish's full-sized avatar

Robert Schulze fnordfish

View GitHub Profile
@fnordfish
fnordfish / index.html
Created September 27, 2023 13:44
simple test case for a JS ServiceWorker with import statement.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Test</title>
</head>
<body>
<h2>Output:</h2>
<div id="out"></div>
@fnordfish
fnordfish / sslserver.ru
Created September 27, 2023 12:58
Start a static file server with self signed tls using ruby and falcon
#!/usr/bin/env falcon serve --hybrid -c
# frozen_string_literal: true
# Adapted from
# https://github.com/socketry/falcon/blob/9170a2a59c360945837f5c993e5684bce63b0672/examples/hello/config.ru
#
# * `gem install falcon`
# * This file needs to be named `.ru`, otherwise it won't be loaded as a rackup file.
# For a less verbose console
require "bundler/inline"
gemfile do
# eval_gemfile(File.expand_path("../Gemfile", __dir__))
gem "psych", git: "https://github.com/fnordfish/psych.git", branch: "dump-stringify-names"
gem "benchmark-ips"
gem "benchmark-memory"
gem "activesupport"
gem "dry-transformer"
end
@fnordfish
fnordfish / psych.patch
Last active February 22, 2023 16:22
Add :stringify_names option to Psych.safe_dump
diff --git a/lib/psych/visitors/yaml_tree.rb b/lib/psych/visitors/yaml_tree.rb
index 5149178..673c8bc 100644
--- a/lib/psych/visitors/yaml_tree.rb
+++ b/lib/psych/visitors/yaml_tree.rb
@@ -70,6 +70,7 @@ module Psych
fail(ArgumentError, "Invalid line_width #{@line_width}, must be non-negative or -1 for unlimited.")
end
end
+ @stringify_names = options[:stringify_names]
@coders = []
@fnordfish
fnordfish / dry-types-corcible-set.rb
Created July 15, 2022 07:05
Dry-Types Coercible::Set like Coercible:Array
Coercible::Set = Types.Constructor(
Set,
->(a) {
# mock behavior of `Kernel.Array`
case a
when nil then Set.new
when Enumerable then Set.new(a)
else Set[a]
end
}
@fnordfish
fnordfish / config.ru
Last active January 14, 2022 11:11
Dead simple static file server using Ruby Rack, implementing Apaches RewriteMap feature using a plain-text mapping file.
# frozen_string_literal: true
# Dead simple static file server using Ruby Rack implementing
# Apaches RewriteMap feature using a plain-text mapping file.
# See: https://httpd.apache.org/docs/current/rewrite/rewritemap.html#txt
#
# Deliberately does not use any caching, so keep the size of your redirects.txt
# in mind.
#
# Usage:
VAGRANT_LOG=debug vagrant plugin install --debug vagrant-dns
INFO global: Vagrant version: 2.2.19
INFO global: Ruby version: 2.7.4
INFO global: RubyGems version: 3.1.6
INFO global: VAGRANT_LOG="debug"
INFO global: VAGRANT_EXECUTABLE="/opt/vagrant/embedded/gems/2.2.19/gems/vagrant-2.2.19/bin/vagrant"
INFO global: VAGRANT_INSTALLER_VERSION="2"
INFO global: VAGRANT_INSTALLER_ENV="1"
INFO global: VAGRANT_INSTALLER_EMBEDDED_DIR="/opt/vagrant/embedded"
INFO global: VAGRANT_NO_PLUGINS="1"
@fnordfish
fnordfish / hugo-github-issue-8279.patch
Last active November 5, 2021 09:49
A proof-of-concept patch to illustrate the proposed feature
From 666e8b2ce0a000168ee5de0e5b98147e462dab79 Mon Sep 17 00:00:00 2001
From: Robert Schulze <robert@dotless.de>
Date: Tue, 2 Nov 2021 14:38:57 +0100
Subject: [PATCH] --wip-- [skip ci]
---
hugolib/paths/paths.go | 5 +++++
hugolib/site.go | 30 +++++++++++++++++++++++++-----
hugolib/site_render.go | 8 +++++++-
langs/config.go | 2 ++
@fnordfish
fnordfish / content_for_extensions.rb
Last active October 21, 2021 15:09
Iterateable extensions for Rodas "content_for" plugin
# frozen_string_literal: true
class Roda
module RodaPlugins
module ContentForExtensions
def self.load_dependencies(app, _opts = OPTS)
app.plugin :content_for
end
module InstanceMethods
@fnordfish
fnordfish / rubocop
Created May 5, 2021 15:49
inline bundler version of a rubocop "binstub"
#!/usr/bin/env ruby
# frozen_string_literal: true
require "bundler"
require "bundler/inline"
Bundler.settings.temporary(frozen: false, deployment: false) do
gemfile do
source "https://rubygems.org"
platform "ruby" do