Skip to content

Instantly share code, notes, and snippets.

View fnordfish's full-sized avatar

Robert Schulze fnordfish

View GitHub Profile
@fnordfish
fnordfish / berotec.scad
Last active March 18, 2021 16:31
Clips for Berotec Mofessor
$fa = 0.5;
$fs = 0.2;
module outerShape() {
module wrapCyl() {
cylinder(d=50, h = 15);
};
hull() {
translate([0,0,0]) wrapCyl();
translate([-30,(-15/2),0]) cube(15);
@fnordfish
fnordfish / logger.rb
Created March 16, 2021 14:02
trap HUP to reopen logfile in ruby
$logger = Logger.new("my.log")
prev_trap = Signal.trap("HUP") do |*args|
$logger.reopen
prev_trap.call(*args) if prev_trap.respond_to?(:call)
end
@fnordfish
fnordfish / dmp.rb
Created February 16, 2021 13:22
DMP - diff-match-patch using it's JS distribution and mini_racer
# frozen_string_literal: true
# renamed files for gist compatibility - should be in sub-folders (dmp/*)
require_relative "dmp__diff"
require_relative "dmp__render"
# Diff-Match-Path
# https://github.com/google/diff-match-patch
module DMP
extend Diff
@fnordfish
fnordfish / env_dev
Created August 4, 2020 13:29
copy big data dirs into docker container and sync back
SRC_PATH=../big_data_dir
DEST_PATH=/var/data
SERVICE=app
$ vagrant up --debug
INFO global: Vagrant version: 2.2.9
INFO global: Ruby version: 2.6.6
INFO global: RubyGems version: 3.0.3
INFO global: VAGRANT_EXECUTABLE="C:\\HashiCorp\\Vagrant\\embedded\\gems\\2.2.9\\gems\\vagrant-2.2.9\\bin\\vagrant"
INFO global: VAGRANT_INSTALLER_EMBEDDED_DIR="C:\\HashiCorp\\Vagrant\\embedded"
INFO global: VAGRANT_INSTALLER_ENV="1"
INFO global: VAGRANT_INSTALLER_VERSION="2"
INFO global: VAGRANT_LOG="debug"
WARN global: resolv replacement has not been enabled!
@fnordfish
fnordfish / bench_error_handling.rb
Created December 5, 2018 10:21
Micro-benchmarking different error handling methods in ruby
# frozen_string_literal: true
# Some, probable not extreamly clever, micro benchmarks to compare
# different methods of "return a value or error".
# The samples benchmark the error path only.
require 'benchmark/ips'
require 'dry/monads/result'
M = Dry::Monads
@fnordfish
fnordfish / trb_dry_sync.rb
Last active June 28, 2018 10:19
Trailblazer Operation without Reform contracts for sync
require "pp"
require "reform" # that's what we want to get rid of
require "dry-validation"
require "trailblazer"
require "trailblazer/operation"
# For the sake of this sample, the "model" class is a bit simple
Customer = Hash
@fnordfish
fnordfish / from.rb
Last active August 4, 2017 07:20
Trailblazer Wishlist: Contract with dry-v Schema reusage
class MyBaseSchema < Dry::Validation::Schema
configure do
# my custom predicates, messages_file, etc.
end
end
TestSchema = Dry::Validation.Form(MyBaseSchema) do
required(:foo).filled
end

Keybase proof

I hereby claim:

  • I am fnordfish on github.
  • I am fnordfish (https://keybase.io/fnordfish) on keybase.
  • I have a public key ASAsnbLeS3CQ3GCuWeQ8aT64rQwmS0BcH_jMEuBN8-HP_Ao

To claim this, I am signing this object:

@fnordfish
fnordfish / hamlit_plugin.rb
Last active January 12, 2017 21:02
Padrino plugin for using Using hamlit as redering engine instead of haml
##
# Use hamlit instead of haml for rendering
# This is basically a copy of the existing integration for slim
RENDERING=<<'RUBY'
module Padrino
module Helpers
module OutputHelpers
##
# Handler for Hamlit templates.