Skip to content

Instantly share code, notes, and snippets.

View bblfish's full-sized avatar

Henry Story bblfish

View GitHub Profile
@bblfish
bblfish / WebFetcher
Created January 29, 2012 22:44
Starting to play with writing a RDF client using the async-http-client https://github.com/ning/async-http-client
package org.w3c.readwriteweb.cache
import com.ning.http.client.AsyncHandler.STATE
import com.ning.http.client.AsyncHandler
import com.ning.http.client.AsyncHttpClient
import com.ning.http.client.HttpResponseBodyPart
import com.ning.http.client.HttpResponseHeaders
import com.ning.http.client.HttpResponseStatus
import com.ning.http.client.Response
@bblfish
bblfish / WebFetcher
Created January 30, 2012 12:54
This shows how one should be able to use Jena readers (re issue JENA-203) https://issues.apache.org/jira/browse/JENA-203 but in fact this throws an exception ERROR (WebFetcher.scala:59) : org.xml.sax.SAXParseException; systemId: http://bblfish.net/people
/*
* Copyright (c) 2012 Henry Story (bblfish.net)
* under the MIT licence defined at
* http://www.opensource.org/licenses/mit-license.html
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in the
* Software without restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so, subject to the
@bblfish
bblfish / AsyncJenaParser
Created January 31, 2012 22:23
Work on adapting on Jena's StAX2SAX to non blocking parser
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
@bblfish
bblfish / WebFetcher
Created January 31, 2012 23:07
An test to start fetching content asynchronously using the aalto parser.
/*
* Copyright (c) 2012 Henry Story (bblfish.net)
* under the MIT licence defined at
* http://www.opensource.org/licenses/mit-license.html
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in the
* Software without restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so, subject to the
@bblfish
bblfish / gist:1780147
Created February 9, 2012 14:00
pimp my rdf
package org.w3.rdf
import org.w3.algebraic._
trait Module {
val xsdString = IRI("http://www.w3.org/2001/XMLSchema#string")
val rdfLangString = IRI("http://www.w3.org/1999/02/22-rdf-syntax-ns#langString")
trait GraphInterface extends Iterable[Triple] { self =>
package org.w3.rdf
import org.w3.algebraic._
trait Module {
val xsdString = IRI("http://www.w3.org/2001/XMLSchema#string")
val rdfLangString = IRI("http://www.w3.org/1999/02/22-rdf-syntax-ns#langString")
trait GraphInterface extends Iterable[Triple] { self =>
@bblfish
bblfish / gist:1780802
Created February 9, 2012 16:00
RDF with simple IRI model
package org.w3.rdf
import org.w3.algebraic._
trait Module {
val xsdString = IRI("http://www.w3.org/2001/XMLSchema#string")
val rdfLangString = IRI("http://www.w3.org/1999/02/22-rdf-syntax-ns#langString")
trait GraphInterface extends Iterable[Triple] { self =>
@bblfish
bblfish / gist:1870493
Created February 20, 2012 18:24
Nomo Turtle recurion issue - (see PN_PREFIX_1, PN_PREFIX_2, ...)
/*
* Copyright (c) 2012 Henry Story
* under the Open Source MIT Licence http://www.opensource.org/licenses/MIT
*/
package org.w3.rdf
import nomo._
import nomo.Errors.{TreeError, Single}
import scala.collection.mutable
@bblfish
bblfish / AuthZ test
Created May 29, 2012 22:19
Funcional AuthZ
case class AuthZ[A](act: Action[A])(implicit findGuard: RequestHeader => Guard) extends Action[A] {
def apply(req: Request): Result = {
val guard = findGuard(req)
if (guard.allow(guard.subject(req))) act(req)
else Results.Unauthorized
}
override
@bblfish
bblfish / AuthZ.scala
Created May 30, 2012 11:59
Authorization action
package org.w3.readwriteweb.play.auth
import play.api.mvc._
import javax.security.auth.Subject
import java.security.Principal
import play.api.libs.concurrent.Promise
import java.security.cert.Certificate
/**