Skip to content

Instantly share code, notes, and snippets.


Mike Dalessio flavorjones

View GitHub Profile
flavorjones / redos-radar.rb
Created May 9, 2022
rough script to examine Ruby regexp literals with
View redos-radar.rb
#! /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:
View Makefile
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 / rdeps.rb
Last active Jul 14, 2021
Find transitive dependencies of a gem, sort by number of downloads
View rdeps.rb
#! /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"
flavorjones /
Last active Jun 19, 2021
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 /
Last active Mar 6, 2021
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

flavorjones / foo.rb
Created Nov 5, 2020
Nokogiri::XML::Node serialization
View foo.rb
#! /usr/bin/env ruby
# related to
require "nokogiri"
html = <<~EOF
<div>123 Fake St.<br>City, State&nbsp;65432</div>
flavorjones / .gitignore
Last active Oct 10, 2020
Reproduce parse failure in `xmlParseCharData`
View .gitignore
flavorjones / foo.rb
Created Aug 29, 2020
nokogiri support 2020-08-29
View foo.rb
#! /usr/bin/env ruby
require 'nokogiri'
input = <<EOF
<title> The journey </title>
<h1> The <index class = "estimate"> Trip </index> </h1>
<p> Our scavenger hunt consists of several stages, starting with the <index class = "treasure"> crossing </index> & mdash; how do we actually get to those islands. The nice thing about an intellectual quest is that we can be in all kinds of places at the same time. If we ever want to revisit a previous episode, all we have to do is click there, and even though we haven't finished a particular stage yet, we can already look ahead to the next. We can also keep in touch with fellow travelers who are in completely different places in the world of thought.
View process_kml.rb
#! /usr/bin/env ruby
require "nokogiri"
xml = <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="">