Skip to content

Instantly share code, notes, and snippets.

View artob's full-sized avatar
⌨️
Coding

Arto Bendiken artob

⌨️
Coding
View GitHub Profile
@tmm1
tmm1 / fbr.rb
Created August 8, 2008 22:16
Poor Man's Fiber (API compatible Thread based Fiber implementation for Ruby 1.8) [http://github.com/tmm1/fiber18/tree/master]
# Poor Man's Fiber (API compatible Thread based Fiber implementation for Ruby 1.8)
# (c) 2008 Aman Gupta (tmm1)
unless defined? Fiber
require 'thread'
class FiberError < StandardError; end
class Fiber
def initialize
@jmhodges
jmhodges / bloomnames.rb
Created October 20, 2008 01:18
a ruby implementation of BloomNames
require 'digest/sha1'
# Derived from a python implementation by Joe Gregorio:
# http://bitworking.org/news/380/bloom-filter-resources
# A Bloom Filter for tracking 3,000 'names', where 'names' are any
# strings of any length. Can be used to track less than 3,000 names, or more,
# but going over will increase the false positive rate. This is currently
# tuned for a false positive rate of 1%.
#
@rtomayko
rtomayko / Tests Is Wrong
Created January 28, 2009 20:50
Why "require 'rubygems'" In Your Library/App/Tests Is Wrong
In response to all the responses to:
http://twitter.com/rtomayko/status/1155906157
You should never do this in a source file included with your library,
app, or tests:
require 'rubygems'
The system I use to manage my $LOAD_PATH is not your library/app/tests
@jwage
jwage / SplClassLoader.php
Last active April 9, 2024 21:04
Add MIT license.
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
@tmm1
tmm1 / iterator.rb
Created October 30, 2009 08:28
simple eventmachine async iterator
module EventMachine
# A simple iterator for concurrent asynchronous work.
#
# Unlike ruby's built-in iterators, the end of the current iteration cycle is signaled manually,
# instead of happening automatically after the yielded block finishes executing. For example:
#
# (0..10).each{ |num| }
#
# becomes:
#
@jeetsukumaran
jeetsukumaran / custom_iterator.cpp
Created February 18, 2010 02:33
Sample C++/STL custom iterator
// Sample custom iterator.
// By perfectly.insane (http://www.dreamincode.net/forums/index.php?showuser=76558)
// From: http://www.dreamincode.net/forums/index.php?showtopic=58468
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <cassert>
@datagraph
datagraph / Grammar.scala
Created April 2, 2010 23:12
A parser combinator SPARQL grammar for Scala (work-in-progress).
/*
* A parser combinator SPARQL grammar for Scala.
* Written in November 2009 by Arto Bendiken <http://ar.to/>
*
* This is free and unencumbered software released into the public domain.
* For more information, please refer to <http://unlicense.org/>
*/
package org.datagraph.sparql
import java.io.FileReader
#!/usr/bin/env ruby
require 'rubygems'
require 'sinatra'
require 'spira'
require 'rack/linkeddata'
use Rack::LinkedData::ContentNegotiation, :default => 'text/turtle'
include RDF
#!/usr/bin/env ruby
require 'rubygems'
require 'rack/test'
require 'erb'
require 'rdf/json'
require 'rdf/rdfxml'
require 'rdf/ntriples'
require 'rdf/rdfa'
#!/usr/bin/env ruby
require 'rdf'
require 'rdf/raptor'
repo = RDF::Repository.new
count = 0
while true
repo.load("test.ttl")