Skip to content

Instantly share code, notes, and snippets.

View warpr's full-sized avatar
🎧
Programming

Kuno Woudt warpr

🎧
Programming
View GitHub Profile
@warpr
warpr / README.md
Created January 3, 2015 19:09
wald-query example

example

Here is a basic example which asks wikidata for some information about Britney Spears' Blackout album:

var wq = query.connect('ldf:http://data.wikidataldf.com/wikidata', ns);

var result = wq.query("wikidata:Q192755", {

id: "@id",

_ = require('underscore');
var commonPrefix = function(l) {
return _(l).reduce(function (memo, item) {
if (!memo) {
return item;
}
var prefix = [];
### Keybase proof
I hereby claim:
* I am warpr on github.
* I am kuno (https://keybase.io/kuno) on keybase.
* I have a public key whose fingerprint is CD8B DEB7 DB1D F510 E63F E870 E5DF CA41 E61D 71C9
To claim this, I am signing this object:
@warpr
warpr / error.hs
Created September 16, 2013 17:05
import System.Exit( exitWith, ExitCode(..) )
exit = exitWith ExitSuccess
die = exitWith $ ExitFailure 1
readSomething :: String -> Either String String
readSomething s = Right (s ++ " -> 200 OK")
readSomethingElse :: String -> Either String String
readSomethingElse s = Left (s ++ " -> 404 NOT FOUND")
@warpr
warpr / t.hs
Created September 1, 2013 19:40
{-# LANGUAGE OverloadedStrings #-}
import Control.Monad.Exception.Synchronous
import Data.Conduit
import qualified Control.Exception as E
import Network.HTTP.Types.Status
import Network.HTTP.Conduit
import qualified Data.ByteString.Lazy as L
import qualified Network (withSocketsDo)
import Control.Exception as E
var _ = require('underscore');
var couchdb = require('couchdb-api');
var server = couchdb.srv();
var db = server.db("databank-test");
var docs = [
{ _id: "kuno", name: "Kuno" },
{ _id: "warp", name: "Warp" },
{ _id: "pak-sang-soo", name: "박 상수" }
mb_test=# vacuum analyze;
ERROR: function musicbrainz_unaccent(character varying) does not exist
LINE 1: SELECT regexp_replace(upper(substr(musicbrainz_unaccent(txt)...
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
QUERY: SELECT regexp_replace(upper(substr(musicbrainz_unaccent(txt), 1, 6)), '[^A-Z ]', '_', 'g')
CONTEXT: PL/pgSQL function "page_index" line 8 at assignment
mb_test=#
request body: {
"artist.begin-date.day" : 13,
"artist.begin-date.month" : 11,
"artist.begin-date.year" : 1982,
"artist.ended" : 0,
"artist.name" : "倖田 來未",
"artist.sort-name" : "Koda Kumi",
"editor" : 1
}
17:38 warp@bullet-bill:~/code/musicbrainz-data (master)$ psql -U root musicbrainz_nes --command='DROP SCHEMA musicbrainz CASCADE;' > /dev/null
NOTICE: drop cascades to 144 other objects
DETAIL: drop cascades to type musicbrainz.comment
drop cascades to type musicbrainz.cover_art_presence
drop cascades to type musicbrainz.ipi
drop cascades to type musicbrainz.isrc_t
drop cascades to type musicbrainz.iswc_t
drop cascades to type musicbrainz.label_code
drop cascades to type musicbrainz.locale
drop cascades to type musicbrainz.natural_integer
14:58 warp@bullet-bill:~/code/musicbrainz-data-service (master)$ cabal configure --enable-tests
Resolving dependencies...
Configuring musicbrainz-data-service-0.1.0.0...
Warning: This package indirectly depends on multiple versions of the same
package. This is highly likely to cause a compile failure.
package regex-base-0.93.2 requires mtl-2.0.1.0
package snap-server-0.9.2.4 requires mtl-2.1.2
package snap-core-0.9.2.2 requires mtl-2.1.2
package snap-0.9.2.2 requires mtl-2.1.2
package parsec-3.1.3 requires mtl-2.1.2