Skip to content

Instantly share code, notes, and snippets.

View njh's full-sized avatar

Nicholas Humfrey njh

View GitHub Profile
#!/usr/bin/env ruby
require 'rubygems'
require 'rack/test'
require 'erb'
require 'rdf/json'
require 'rdf/rdfxml'
require 'rdf/ntriples'
require 'rdf/rdfa'
#!/usr/bin/env ruby
require 'rubygems'
require 'rdf'
require 'rdf/ntriples'
require 'rdf/rdfxml'
graph = RDF::Graph.new
diff --git a/src/rdf_init.c b/src/rdf_init.c
index 1509f1c..d2edac1 100644
--- a/src/rdf_init.c
+++ b/src/rdf_init.c
@@ -306,6 +306,45 @@ librdf_world_open(librdf_world *world)
/**
+ * librdf_world_set_rasqal:
+ * @world: librdf_world object
<?xml version="1.0" encoding="utf-8"?>
<rdf:RDF
xmlns:mo="http://purl.org/ontology/mo/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:foaf="http://xmlns.com/foaf/0.1/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
>
<mo:Record>
<dc:title>Only Revolutions</dc:title>
diff --git a/src/raptor_uri.c b/src/raptor_uri.c
index f147bb9..cda374d 100644
--- a/src/raptor_uri.c
+++ b/src/raptor_uri.c
@@ -466,8 +466,11 @@ raptor_uri_compare(raptor_uri* uri1, raptor_uri* uri2)
if(uri1 == uri2)
return 0;
- if(uri1 && uri2)
- return strcmp((const char*)uri1->string, (const char*)uri2->string);
@njh
njh / build-minimal-php.pl
Last active September 23, 2015 19:07
Given a URL to a tarball, build a PHP CLI binary, with minimal dependancies.
#!/usr/bin/env perl
#
# Script to build a minimal version of PHP
#
# https://gist.github.com/njh/601712
#
use File::Basename;
use strict;
@njh
njh / rapper_parse.php
Created October 18, 2010 08:13
Parse RDF/XML to RDF/PHP using the rapper command line tool
<?php
$URL = 'http://dbpedia.org/resource/London.rdf';
$DATA = file_get_contents('london.rdf');
$FORMAT = "rdfxml";
$start = microtime(true);
// Open a pipe to the rapper command
def extract_pronunciation(string)
result = string.dup
regexes = {
%r[\(IPA: ["\[/].*?["\]/]\) ] => '',
%r[\(pronounced ["\[/].*?["\]/]\) ] => '',
# for when pronounciation is mixed in with birthdate, e.g. (pronounced /bəˈɹɛlɪs/; born December 7, 1979)
%r[pronounced ["\[/].*?["\]/]\; ] => '',
}
for regex in regexes.keys
if result =~ regex
@njh
njh / twolame-float-patch.patch
Created January 2, 2011 13:06
Patch to using floats for internal buffers in twolame
diff -Naur twolame/libtwolame/common.h twolame-patched/libtwolame/common.h
--- twolame/libtwolame/common.h Thu Jul 26 12:10:05 2007
+++ twolame-patched/libtwolame/common.h Wed Jul 25 15:08:05 2007
@@ -79,7 +79,8 @@
#define HAN_SIZE 512
#define SCALE_BLOCK 12
#define SCALE_RANGE 64
-#define SCALE 32768
+#define SCALE 1
+#define DOWN_SCALE (1.0 / 32768.0)
diff --git a/src/rdf_serializer_raptor.c b/src/rdf_serializer_raptor.c
index 849e378..f41e4e8 100644
--- a/src/rdf_serializer_raptor.c
+++ b/src/rdf_serializer_raptor.c
@@ -169,7 +169,8 @@ librdf_serializer_raptor_set_namespace(void* context,
static int
librdf_serializer_raptor_serialize_statement(raptor_serializer *rserializer,
- librdf_statement* statement)
+ librdf_statement* statement,