Skip to content

Instantly share code, notes, and snippets.

View njh's full-sized avatar

Nicholas Humfrey njh

View GitHub Profile
@njh
njh / redland_parse.php
Created October 17, 2010 16:34
Parse RDF/XML to RDF/PHP using the redland PHP extension
<?php
$URL = 'http://dbpedia.org/resource/London.rdf';
$DATA = file_get_contents('london.rdf');
$FORMAT = "rdfxml";
if (!extension_loaded('redland')) {
throw new Exception("redland extension is not loaded");
}
@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,
@njh
njh / rasqal_world_get_query_language_description.patch
Created February 3, 2011 14:49
Patch to add rasqal_world_get_query_language_description() function to rasqal
diff --git a/src/rasqal.h.in b/src/rasqal.h.in
index 52657ad..8df1027 100644
--- a/src/rasqal.h.in
+++ b/src/rasqal.h.in
@@ -1041,7 +1041,11 @@ rasqal_feature rasqal_feature_from_uri(rasqal_world* world, raptor_uri *uri);
RASQAL_API
int rasqal_feature_value_type(const rasqal_feature feature);
+
; SVR records for Jabber
jabber CNAME hadrian.aelius.com.
_jabber._tcp SRV 5 0 5269 jabber.aelius.com.
_xmpp-server._tcp SRV 5 0 5269 jabber.aelius.com.
_xmpp-client._tcp SRV 5 0 5222 jabber.aelius.com.
; Other SRV records
_http._tcp SRV 0 100 80 www.aelius.com.
// gcc -o float_test float_test.c && ./float_test
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
float f = 0.9;
int i = f * 10.0;
<?xml version="1.0" encoding="utf-8"?>
<rdf:RDF xmlns:rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rdfs = "http://www.w3.org/2000/01/rdf-schema#"
xmlns:owl = "http://www.w3.org/2002/07/owl#"
xmlns:foaf = "http://xmlns.com/foaf/0.1/"
xmlns:sioc = "http://rdfs.org/sioc/ns#"
xmlns:po = "http://purl.org/ontology/po/"
xmlns:pod = "http://purl.org/ontology/pod/"
xmlns:mo = "http://purl.org/ontology/mo/"
xmlns:skos = "http://www.w3.org/2008/05/skos#"
{ "programme" : { "display_titles" : { "subtitle" : "Series 5, Wales Main",
"title" : "Great British Menu"
},
"duration" : 1800,
"formats" : [ { "id" : "PT008",
"inScheme" : "formats",
"key" : "gamesandquizzes",
"label" : "Games & Quizzes",
"prefLabel" : "Games & Quizzes",
"title" : "Games & Quizzes",