Skip to content

Instantly share code, notes, and snippets.

View artob's full-sized avatar
⌨️
Coding

Arto Bendiken artob

⌨️
Coding
View GitHub Profile
@bad
bad / rdf-query-each_solution-test-case.rb
Created January 5, 2011 20:28
demonstrates a discrepancy between RDF::Query#each_solution and RDF::Query#solutions.each
require 'rubygems'
require 'rdf'
require 'rdf/rdfxml'
require 'sparql/client'
lmdb = SPARQL::Client::Repository.new 'http://data.linkedmdb.org/sparql'
query = lmdb.client.
select(:movie).
prefix('movie: <http://data.linkedmdb.org/resource/movie/>').
@amacleod
amacleod / zmq_cli.py
Created January 13, 2011 16:56
Test case for uninterruptability of zeromq Python runtime.
#!/usr/bin/python
"""
zmq_cli - 0MQ Server interruptability test case, client module.
"""
import zmq
@postmodern
postmodern / c_parser.rb
Created January 16, 2011 04:24
An ANSI C Parser using the Ruby Parslet library.
#
# A C Parser using the Parslet library.
#
# ANSI C Grammar:
#
# * http://www.lysator.liu.se/c/ANSI-C-grammar-l.html
# * http://www.lysator.liu.se/c/ANSI-C-grammar-y.html
#
require 'parslet'
@dchest
dchest / fossil-add
Created January 16, 2011 13:51
fossil add doesn't ignore files specified in ignore-glob. This uses fossil-extra to add any extra files in repo to fossil (because extra uses ignore-glob).
#!/bin/sh
fossil extra | tr '\n' '\0' | xargs -0 -t fossil add
@taotetek
taotetek / timer_test.py
Created January 29, 2011 16:12
Sending timed signals to multiple processes using twisted and zeromq
import zmq
from twisted.internet.task import LoopingCall
from twisted.internet import reactor
from datetime import datetime
from time import sleep
from multiprocessing import Process
class PulseTransmitter(object):
def __init__(self):
self.context = zmq.Context()
@bhuga
bhuga / sparql-client-refactor.rb
Created February 1, 2011 18:33
Updates to SPARQL client to allow parsing with other tools, if so wished.
require 'sparql/client'
require 'rest_client'
sparql = SPARQL::Client.new("http://dbpedia.org/sparql")
# existing functionality:
p sparql.query("select distinct ?Concept where {[] a ?Concept}").inspect
# now equivalent to:
response = RestClient.post 'http://dbpedia.org/sparql', { :query => "select distinct ?Concept where {[] a ?Concept}" }, :content_type => 'application/x-www-form-urlencoded', :accept => 'application/sparql-results+json'
@Demwunz
Demwunz / gist:813895
Created February 7, 2011 01:28
XSLT HTML5 Boilerplate starter
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:exsl="http://exslt.org/common"
xmlns:func="http://exslt.org/functions"
xmlns:head="http://headjs.com"
extension-element-prefixes="exsl func head">
<xsl:import href="../utilities/page-title.xsl"/>
<xsl:import href="../utilities/navigation.xsl"/>
@emk
emk / gist:825185
Created February 13, 2011 21:55
Designing an RDF.rb query adapter for AllegroGraph

Many thanks to [@bendiken][1] and [@bhuga][2] for helping me get started with RDF.rb! Thanks to their tutorials and test suites, I was able to build a pretty good adapter in about 10 hours. The adapter already implements query_pattern, insert_statements and delete_statements.

My next challenge will be to support AllegroGraph queries. AllegroGraph has two server-side query languages: SPARQL, and a weird-but-powerful [Prolog dialect using Lisp syntax][3]. The Prolog dialect allows me to run [graph algorithms][4] and other [funky][5] [queries][6] on the server:

(select (?person ?name ?email)
  ;; Find everybody within one or two degrees of jsmith.
  (ego-group-member !people:jsmith 2 !foaf:knows ?person)
  (q ?person !foaf:name ?name)
  (q ?person !foaf:mbox ?email))
@bhuga
bhuga / client-assert.rb
Created February 19, 2011 22:08
Demonstrates assertions, server
#!/usr/bin/env ruby
require 'ffi-rzmq'
#IPC_SOCKET = "ipc:///tmp/assert-demo.zmq"
IPC_SOCKET = 'tcp://localhost:5555'
@sender_context = ZMQ::Context.new(2)
send_socket = @sender_context.socket(ZMQ::REQ)
second_send_socket = nil
send_socket.connect(IPC_SOCKET)
@kuon
kuon / gist:838826
Created February 22, 2011 15:23
slickgrid with sproutcore
SGUI.TableView = SC.CollectionView.extend({
columns:[],
options:{},
reloadIfNeeded:function() {
var options = this.get('options');
var content = this.get('content');
var columns = this.get('columns');
function getItem(index) {