Skip to content

Instantly share code, notes, and snippets.

View artob's full-sized avatar
⌨️
Coding

Arto Bendiken artob

⌨️
Coding
View GitHub Profile
@artob
artob / assembler.rb
Created July 26, 2009 15:35
Simple JVM assembler based on the BiteScript gem for JRuby.
# Simple JVM assembler using the BiteScript gem for JRuby.
# @see http://kenai.com/projects/jvmscript
require 'rubygems'
require 'bitescript'
class JVM
class Assembler
attr_reader :options
def self.compile(name, options = {}, &block)
@artob
artob / openpgp_spec.log
Created August 1, 2009 15:38
OpenPGP.rb specs
OpenPGP::Message at <http://ar.to/pgp.txt>
when dearmored
should return a binary string of 1,939 bytes
should have the CRC24 checksum of 0x3B1080
when parsed
should return a sequence of packets
should contain a public key packet
should contain a public subkey packet
should contain three user ID packets
@artob
artob / lockmem.c
Created November 19, 2009 18:06
lockmem.c: grabs and locks a specified amount of memory
/**
* lockmem.c: grabs and locks a specified amount of memory
*
* Written by Arto Bendiken <http://ar.to/>
* Compile using "gcc -o lockmem lockmem.c"
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
class Item
include Spira::Resource(SIOC.Item)
property :title, DC.title, String
property :content, SIOC.content, String
property :created, DC.created, DateTime
property :creator, SIOC.has_creator, UserAccount
property :item, SIOC.about, self
property :has_reply, SIOC.has_reply, self
property :reply_of, SIOC.reply_of, self # IFP of :has_reply
module RDF::Raptor
##
# RDF/XML support.
module RDFXML
##
# RDF/XML format specification.
class Format < RDF::Raptor::Format
content_type 'application/rdf+xml', :extension => :rdf
content_encoding 'utf-8'
rapper_format :rdfxml
@artob
artob / rdf_context.md
Created April 2, 2010 04:14
RDF.rb <-> RdfContext mapping (work-in-progress)

RDF.rb === RdfContext

This is a quick overview and mapping between RDF.rb and RdfContext, two RDF libraries for Ruby, to serve as an aid in determining whether the projects would benefit from aligning goals and direction.

An experimental fork of RdfContext that attempts some integration between the two object models:

@artob
artob / grammar.rb
Created August 19, 2010 17:11
Possible syntax for parser combinators in Ruby.
module SXP
module Grammar extend Parallax::Grammar
LPAREN = char('(')
RPAREN = char(')')
INTEGER = term(/^([+-]?\d+)/) { |s| s.to_i }
STRING = term(/^"([^"]+)"/) { |s| s }
SYMBOL = term(/^([\w\d_-]+)/) { |s| s.to_sym }
Atom = INTEGER | STRING | SYMBOL
List = LPAREN << +Atom >> RPAREN
@artob
artob / rspec-lisp.rb
Created August 23, 2010 16:21
Simple Ruby interface for evaluating Common Lisp code, for use with RSpec.
#!/usr/bin/env ruby -rubygems
#
# Simple Ruby interface for evaluating Common Lisp code, for use with RSpec.
# Written in August 2010 by Arto Bendiken <http://ar.to/>
#
# This is free and unencumbered software released into the public domain.
require 'open4' # `sudo gem install open4`
require 'sxp' # `sudo gem install sxp`
@artob
artob / dawg_r2_spec.rb
Created October 17, 2010 12:22
DAWG test suite runner for SPARQL::Grammar::Parser
require File.join(File.dirname(__FILE__), 'spec_helper')
DAWG = RDF::Vocabulary.new('http://www.w3.org/2001/sw/DataAccess/tests/test-dawg#')
MF = RDF::Vocabulary.new('http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#')
QT = RDF::Vocabulary.new('http://www.w3.org/2001/sw/DataAccess/tests/test-query#')
RS = RDF::Vocabulary.new('http://www.w3.org/2001/sw/DataAccess/tests/result-set#')
describe SPARQL::Grammar::Parser do
file = File.expand_path('./spec/dawg-test-suite/data-r2/manifest-syntax.ttl')
url = RDF::URI("file://#{file}")
@artob
artob / bgp-query.rb
Created October 22, 2010 23:09
RDF.rb 0.3.0 BGP query example
#!/usr/bin/env ruby1.9
require 'rdf'
require 'rdf/ntriples'
RDF::Repository.load('http://rdf.rubyforge.org/doap.nt') do |rdf|
bgp = RDF::Query.new do
self << [:person, RDF.type, RDF::FOAF.Person]
self << [:person, RDF::FOAF.name, :name]
self << [:person, RDF::FOAF.mbox, :email]
end