Skip to content

Instantly share code, notes, and snippets.

View flavorjones's full-sized avatar

Mike Dalessio flavorjones

View GitHub Profile
@flavorjones
flavorjones / Makefile
Last active August 11, 2023 21:10
2023-08-11 reproduction of libxml2 encoding behavior changes
CFLAGS=$(shell ./local/bin/xml2-config --cflags)
LDFLAGS=$(shell ./local/bin/xml2-config --libs)
foo: foo.o
$(CC) -o foo foo.o $(LDFLAGS)
foo.o: foo.c
$(CC) $(CFLAGS) -c -o foo.o foo.c
clean:
#! /usr/bin/env ruby
require "bundler/inline"
gemfile do
source "https://rubygems.org"
gem "builder"
gem "nokogiri"
gem "benchmark-ips"
end
@flavorjones
flavorjones / Makefile
Last active April 30, 2023 13:05
repro of libxml2 memory leak in v2.11.0
CFLAGS=$(shell ./local/bin/xml2-config --cflags)
LDFLAGS=$(shell ./local/bin/xml2-config --libs)
foo: foo.o
$(CC) -o foo foo.o $(LDFLAGS)
foo.o: foo.c
$(CC) $(CFLAGS) -c -o foo.o foo.c
clean:
@flavorjones
flavorjones / README.md
Created November 22, 2022 18:27
patch of mkdocs-material search plugin to support rdoc

I should really make this into a real plugin when I get time. But for now it will do.

@flavorjones
flavorjones / redos-radar.rb
Created May 9, 2022 12:36
rough script to examine Ruby regexp literals with https://makenowjust-labs.github.io/recheck/
#! /usr/bin/env ruby
# coding: utf-8
# Copyright 2022 Mike Dalessio
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
# associated documentation files (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge, publish, distribute,
# sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
CFLAGS = -std=c89
default: run
benchmark-O0.o: benchmark.c
$(CC) -O0 $(CFLAGS) -c -o benchmark-O0.o benchmark.c
lib-O0.o: lib.c
$(CC) -O0 $(CFLAGS) -c -o lib-O0.o lib.c
@flavorjones
flavorjones / rdeps.rb
Last active July 14, 2021 14:59
Find transitive dependencies of a gem, sort by number of downloads
#! /usr/bin/env ruby
#
# find transitive reverse dependencies of nokogiri with more than a million downloads: "rdeps.rb nokogiri 1000000"
#
require "bundler/inline"
gemfile do
gem "json"
gem "ruby-progressbar"
end
@flavorjones
flavorjones / _README.md
Last active June 19, 2021 16:14
reproduce Ruby memory usage error in `iseq_peephole_optimize`

This gist reproduces a memory usage error in Ruby's iseq_peephole_optimize.

  1. Compile Ruby with ASan (using CFLAGS="-fsanitize=address -ggdb")
  2. Turn off memory leak detection (which is not relevant)export ASAN_OPTIONS=detect_leaks=0
  3. Run ruby ./repro.rb

You should see something like:

before require
@flavorjones
flavorjones / 2021-03-06_stats.md
Last active March 6, 2021 19:26
Nokogiri downloads by architecture

v1.0 45,557 / 2008-10-30

  • ruby: 31,817 (69.84%)
  • x86-mswin32: 13,740 (30.16%)

v1.1 15,989 / 2008-12-21

  • ruby: 8,547 (53.46%)
  • x86-mswin32: 4,616 (28.87%)
  • java: 2,826 (17.67%)

v1.2 40,968 / 2009-02-22