Skip to content

Instantly share code, notes, and snippets.


Mike Dalessio flavorjones

View GitHub Profile
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="">
View Dockerfile
FROM ruby:2-alpine3.10
RUN apk add build-base imagemagick6-dev bash
flavorjones / Makefile
Last active Jan 18, 2019
View Makefile
CFLAGS=$(shell pkg-config libxml-2.0 --cflags)
LDFLAGS=$(shell pkg-config libxml-2.0 --libs)
foo: foo.o
$(CC) -o foo foo.o $(LDFLAGS)
foo.o: foo.c
$(CC) $(CFLAGS) -c -o foo.o foo.c