Skip to content

Instantly share code, notes, and snippets.

View flavorjones's full-sized avatar

Mike Dalessio flavorjones

View GitHub Profile
@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

@flavorjones
flavorjones / foo.rb
Created November 5, 2020 11:37
Nokogiri::XML::Node serialization
#! /usr/bin/env ruby
# related to https://groups.google.com/g/nokogiri-talk/c/XoKIzgbcBpU/m/9o3tbD6WCQAJ
require "nokogiri"
html = <<~EOF
<html>
<body>
<div>123 Fake St.<br>City, State&nbsp;65432</div>
@flavorjones
flavorjones / _output.txt
Created June 7, 2016 15:10
benchmark nokogiri vs rexml
# parsing a document 6731 bytes long
Warming up --------------------------------------
nokogiri 488.000 i/100ms
rexml 21.000 i/100ms
Calculating -------------------------------------
nokogiri 6.150k (±23.4%) i/s - 28.792k in 5.067345s
rexml 208.195 (± 5.3%) i/s - 1.050k in 5.056578s
Comparison:
nokogiri: 6150.3 i/s
@flavorjones
flavorjones / .gitignore
Last active October 10, 2020 19:37
Reproduce parse failure in `xmlParseCharData`
ok.xml
fail.xml
run-me.o
run-me
@flavorjones
flavorjones / foo.rb
Created August 29, 2020 16:16
nokogiri support 2020-08-29
#! /usr/bin/env ruby
require 'nokogiri'
input = <<EOF
<title> The journey </title>
</head>
<body>
<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.
#! /usr/bin/env ruby
require "nokogiri"
xml = <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<name>Document.kml</name>
<Placemark>
define session-ruby
source ~/.gdb/session-ruby
end
@flavorjones
flavorjones / README.markdown
Created August 19, 2009 05:46
Comparison of Loofah against other Ruby HTML sanitization libraries

Overview of the Benchmark

The following benchmark output was generated from the codes at http://github.com/flavorjones/loofah/tree/master/benchmark

These results show the performance of Loofah scrubbing methods against comparable methods from other common open-source libraries:

  • ActionView sanitize() and strip_tags()
  • Sanitize sanitize()
@flavorjones
flavorjones / Dockerfile
Last active February 2, 2020 03:41
nokogiri-1959
FROM ruby:2-alpine3.10
RUN apk add build-base imagemagick6-dev bash
WORKDIR /app