This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%%machine example; | |
%%{ | |
cdata_start = '<![CDATA['; | |
cdata_end = ']]>'; | |
cdata := |* | |
# Everything that is not "]]>" (must match consecutive characters) | |
# Sadly this seems to result in "foo]]" being matched for input | |
# "<![CDATA[foo]]>". |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'oga' | |
document = Oga.parse_xml <<-EOF | |
<pricing_information> | |
<cents> | |
10 | |
</cents> | |
<currency> | |
EUR | |
</currency> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<link rel="shortcut icon" href="/favicon2.gif"> | |
<html> | |
<body></body> | |
<body background="/Test_2.gif"></body> | |
<body onload="blink();"> | |
<div align="center"></div> | |
<TITLE>Site Name</TITLE> | |
</body> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From a31eb2863043937881e51cffb544ef9a641a62af Mon Sep 17 00:00:00 2001 | |
From: Yorick Peterse <SNIP> | |
Date: Thu, 12 Mar 2015 11:08:46 +0100 | |
Subject: [PATCH] Added a simple Maybe monad. | |
This is a rather simple implementation of the Maybe monad [1] / Option type [2]. | |
It only provides the absolute bare-minimum instead of providing a fully blown | |
functional programming library. | |
Using this class allows you to turn code such as this: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Starting program: /home/yorickpeterse/.rubies/rbx-git/bin/ruby test.rb | |
[Thread debugging using libthread_db enabled] | |
Using host libthread_db library "/usr/lib/libthread_db.so.1". | |
[New Thread 0x7fffd75ff700 (LWP 350)] | |
[New Thread 0x7fffd71fe700 (LWP 351)] | |
[New Thread 0x7ffff45bc700 (LWP 348)] | |
[New Thread 0x7ffff48f3700 (LWP 347)] | |
[New Thread 0x7ffff49f4700 (LWP 345)] | |
[New Thread 0x7ffff4af5700 (LWP 344)] | |
[New Thread 0x7ffff4bf6700 (LWP 343)] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Text | |
def text=(value) | |
@raw_text = value | |
@text = nil | |
end | |
def text | |
unless @text | |
@text = Entities.decode(@raw_text) | |
@raw_text = nil |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Based on the JSON output as listed at | |
# http://www.w3.org/TR/html5/syntax.html#named-character-references | |
DECODE_MAPPING = { | |
"Á" => [193].pack('U'), | |
"Á" => [193].pack('U'), | |
"á" => [225].pack('U'), | |
"á" => [225].pack('U'), | |
"Ă" => [258].pack('U'), | |
"ă" => [259].pack('U'), | |
"∾" => [8766].pack('U'), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark/ips' | |
module Enumerable | |
def each_cons(num) | |
n = Rubinius::Type.coerce_to_collection_index num | |
raise ArgumentError, "invalid size: #{n}" if n <= 0 | |
return to_enum(:each_cons, num) { | |
if (enum_size = enumerator_size).nil? | |
nil |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git clone [email protected]:YorickPeterse/oga.git | |
git checkout ruby-ll # if this complains, use git checkout -b ruby-ll origin/ruby-ll | |
bundle install | |
gem install oga | |
rake generate fixtures | |
# To benchmark the old parser, open benchmark/benchmark_helper.rb | |
# and replace the require_relative on line 5 with require 'oga' | |
# Then to benchmark it: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Starting program: /home/yorickpeterse/.rubies/rbx-git/bin/ruby -e Rubinius::VariableScope.new.locals | |
warning: Could not load shared library symbols for linux-vdso.so.1. | |
Do you need "set solib-search-path" or "set sysroot"? | |
[Thread debugging using libthread_db enabled] | |
Using host libthread_db library "/usr/lib/libthread_db.so.1". | |
[New Thread 0x7ffff7f8f700 (LWP 15561)] | |
[New Thread 0x7ffff4cf7700 (LWP 15562)] | |
[New Thread 0x7ffff4bf6700 (LWP 15563)] | |
[New Thread 0x7ffff4af5700 (LWP 15564)] | |
[New Thread 0x7ffff49f4700 (LWP 15565)] |