Skip to content

Instantly share code, notes, and snippets.

View flavorjones's full-sized avatar

Mike Dalessio flavorjones

View GitHub Profile
@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>
@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
@flavorjones
flavorjones / Makefile
Last active January 18, 2019 00:40
nokogiri-1861-exponential-search-time
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
@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 / gist:cc1b82365d1d29f6fb3f
Created January 13, 2015 15:55
Here's what happens when I try to remove libxml2 from my system ...
$ sudo apt-get remove libxml2
Reading package lists... Done
Building dependency tree
Reading state information... Done
<snip>
The following packages will be REMOVED:
adobe-flashplugin apturl avahi-daemon avahi-utils banshee baobab bind9-host
bluez-gstreamer brasero brasero-cdrkit caribou cinnamon cinnamon-bluetooth
cinnamon-control-center cinnamon-screensaver cinnamon-session
cinnamon-settings-daemon cmake colord default-jre dnsutils dropbox emacs24
@flavorjones
flavorjones / gist:3450791
Created August 24, 2012 13:54
lua script for redirecting mysql access via mysqlproxy
local tok = require("proxy.tokenizer")
function read_query(packet)
if (string.byte(packet) == proxy.COM_QUERY) then
local replacement_tokens = {}
local tokens = tok.tokenize(packet:sub(2))
local modified_p = false
print("-----")
print(packet:sub(2))
print(tok.normalize(tokens))
@flavorjones
flavorjones / pomodoro.rb
Created August 24, 2011 16:30
Toggle "Pomodoro Mode" under Gnome (using keyboard typing break)
#! /usr/bin/env ruby
#
# Script to turn "pomodoro mode" on/off in Gnome.
#
# Gnome has a little-known feature to put a timer around "typing
# breaks". This script makes it easy to turn on and off from the
# command line (or gnome-do, or what-have-you).
#
current_value = %x{gconftool --get /desktop/gnome/typing_break/enabled}.chomp