Skip to content

Instantly share code, notes, and snippets.

View dajobe's full-sized avatar

Dave Beckett dajobe

View GitHub Profile
{$C3000}
program bubble(input, output);
{ Program : bubble
Input : 1) Number of data items (maximum 500)
2) The data items Operation : Sorts the data using a bubble sort, the number of comparisons
and data accesses being counted.
Output : The number of comparisons and accesses and the sorted data in ascending order. Bugs : 1) The program does not check for invalid data type on input
so entering an invalid integer will cause a fatal crash.
}
@dajobe
dajobe / literarymachine-crash.php
Created February 3, 2012 17:50
literarymachine reported crash
<?php
$rdfString = "<foo> <bar> <baz> .";
$storage = librdf_new_storage(librdf_php_get_world(), "memory", null, null);
$model = librdf_new_model(librdf_php_get_world(), $storage, null);
$parser = librdf_new_parser(librdf_php_get_world(), "ntriples", null, null);
$base_uri = librdf_new_uri(librdf_php_get_world(), "http://www.w3.org/1999/02/22-rdf-syntax-ns#");
librdf_parser_parse_string_into_model($parser, $rdfString, $base_uri, $model);
librdf_free_parser($parser);
librdf_new_uri(librdf_php_get_world(), "http://example/1");
librdf_new_node(librdf_php_get_world());
#!/bin/sh
ROOT=$HOME/working-dir
cd $ROOT
URL='http://SOURCE-URL/'
DIR='DEST-DIR/'
pavuk \
-mode sync \
@dajobe
dajobe / digg-oauth-register.py
Created December 28, 2011 23:13
Digg OAuth flow example in python
#! /usr/bin/env python
#
# Go through the Digg OAuth flow for an application and user
# to get back Digg OAuth access token + access token secret
#
# This code is in the Public Domain
#
try:
from cgi import parse_qs
$ utils/roqet
Rasqal RDF query utility 0.9.29 GIT 4c2eadf209c7ec13e5ec2e2835a5baef3b7a1503
Rasqal home page: http://librdf.org/rasqal/
Copyright (C) 2003-2011 David Beckett - http://www.dajobe.org/
Copyright (C) 2003-2005 University of Bristol - http://www.bristol.ac.uk/
License: LGPL 2.1 or newer, GPL 2 or newer, Apache 2.0 or newer.
See http://librdf.org/rasqal/LICENSE.html for full terms.
Try `roqet --help' for more information.
@dajobe
dajobe / example8.c.patch
Created November 5, 2011 21:03
Test that TSV can be generated from librdf
diff --git a/examples/example8.c b/examples/example8.c
index 408da74..62108da 100644
--- a/examples/example8.c
+++ b/examples/example8.c
@@ -96,8 +96,9 @@ main(int argc, char *argv[])
if(librdf_query_results_is_bindings(results) ||
librdf_query_results_is_boolean(results)) {
- string = librdf_query_results_to_counted_string2(results, format,
- NULL, NULL, NULL, &length);
==92495== Invalid write of size 4
==92495== at 0x2B0846: initstate (in /usr/lib/libSystem.B.dylib)
==92495== by 0x55B71: rasqal_random_init (in /Users/dajobe/dev/redland/rasqal/src/.libs/librasqal.3.dylib)
==92495== by 0x216DB: rasqal_evaluation_context_set_rand_seed (in /Users/dajobe/dev/redland/rasqal/src/.libs/librasqal.3.dylib)
==92495== by 0x29FD1: rasqal_query_prepare (in /Users/dajobe/dev/redland/rasqal/src/.libs/librasqal.3.dylib)
==92495== by 0x10000170C: main (in .libs/rasqal_limit_test)
==92495== Address 0x1000a7d30 is 32 bytes inside a block of size 288 free'd
==92495== at 0xD4AE: free (vg_replace_malloc.c:430)
==92495== by 0x21605: rasqal_free_evaluation_context (in /Users/dajobe/dev/redland/rasqal/src/.libs/librasqal.3.dylib)
==92495== by 0x2841A: rasqal_free_query (in /Users/dajobe/dev/redland/rasqal/src/.libs/librasqal.3.dylib)
@dajobe
dajobe / rasqal-parsing.c
Created September 12, 2011 17:17
4store reported query issue C test
/*
gcc -g -Wall -o rasqal-parsing rasqal-parsing.c `pkg-config rasqal --cflags --libs`
When this sequence of queries is parsed inside 4store this error is seen:
parser error: syntax error, unexpected $end, expecting integer literal on line 1 parser error: rasqal_new_typed_literal failed on line 1
*/
#include <rasqal.h>
@dajobe
dajobe / gist:1211781
Created September 12, 2011 17:05
4store reported query issue
# Query 1
SELECT (?o as ?o2) WHERE { ?s ?p ?o } ORDER BY ?o
# Query 2
SELECT ?s WHERE { ?s ?p ?o } LIMIT 1
# Error seen:
# parser error: syntax error, unexpected $end, expecting integer literal on line 1 parser error: rasqal_new_typed_literal failed on line 1
@dajobe
dajobe / gist:1008454
Created June 4, 2011 22:50
rasqal_expression variable binding ambiguity
; Current API cannot distinguish these since (variable, binding expr) are in same
; structure identified globally by variable name.
1.
SELECT ((1+1) AS ?foo)
WHERE { ... }
GROUP BY ?foo
2.