Skip to content

Instantly share code, notes, and snippets.

View artob's full-sized avatar
⌨️
Coding

Arto Bendiken artob

⌨️
Coding
View GitHub Profile
@artob
artob / bgp-query.rb
Created October 22, 2010 23:09
RDF.rb 0.3.0 BGP query example
#!/usr/bin/env ruby1.9
require 'rdf'
require 'rdf/ntriples'
RDF::Repository.load('http://rdf.rubyforge.org/doap.nt') do |rdf|
bgp = RDF::Query.new do
self << [:person, RDF.type, RDF::FOAF.Person]
self << [:person, RDF::FOAF.name, :name]
self << [:person, RDF::FOAF.mbox, :email]
end
@shripadk
shripadk / gist:652819
Created October 29, 2010 03:10
Express authentication using Redis for session store and Couchdb for database (in coffeescript!)
###
Module dependencies
###
require.paths.unshift "#{__dirname}/lib/support/express-csrf/"
require.paths.unshift "#{__dirname}/lib/support/node_hash/lib/"
express = require 'express'
app = module.exports = express.createServer()
RedisStore = require 'connect-redis'
@altamic
altamic / readme.ext
Created November 5, 2010 23:41
how to make extension libraries for Ruby
.\" README.EXT - -*- Text -*- created at: Mon Aug 7 16:45:54 JST 1995
This document explains how to make extension libraries for Ruby.
1. Basic knowledge
In C, variables have types and data do not have types. In contrast,
Ruby variables do not have a static type, and data themselves have
types, so data will need to be converted between the languages.
@igrigorik
igrigorik / webapp.rb
Created November 13, 2010 21:28
Inspired by @JEG2's talk at Rubyconf... Any ruby object, as a webapp! 'Cause we can. :-)
require 'rubygems'
require 'rack'
class Object
def webapp
class << self
define_method :call do |env|
func, *attrs = env['PATH_INFO'].split('/').reject(&:empty?)
[200, {}, send(func, *attrs)]
end
@bhuga
bhuga / RDF.rb encoding error when fetching remote files
Created November 14, 2010 00:25
Local copy of the file works, fetching directly over remote fails. Something wrong with standard library?
root@ip-10-251-122-82:/home/lavender/spocq/src/test/rspec/tests/data-r2/i18n# curl http://tmp.datagraph.org.s3.amazonaws.com/import/33f361f0-d1b2-012d-f3cf-0023df827da6 > curl
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
113 795 113 795 0 0 47522 0 --:--:-- --:--:-- --:--:-- 56785
root@ip-10-251-122-82:/home/lavender/spocq/src/test/rspec/tests/data-r2/i18n# diff curl normalization-01.ttl
root@ip-10-251-122-82:/home/lavender/spocq/src/test/rspec/tests/data-r2/i18n# ls -al curl normalization-01.ttl
-rw-r--r-- 1 root root 795 2010-11-14 00:21 curl
-rw-r--r-- 1 lavender lavender 795 2010-10-29 05:46 normalization-01.ttl
root@ip-10-251-122-82:/home/lavender/spocq/src/test/rspec/tests/data-r2/i18n# irb1.9
[INFO] (src/control.rl:207) Setting up control socket in at ipc://run/control
[INFO] (src/handler.c:202) MAX allowing limits.handler_targets=128
[INFO] (src/handler.c:275) Binding handler PUSH socket tcp://127.0.0.1:9997 with identity: test
[INFO] (src/handler.c:297) Binding listener SUB socket tcp://127.0.0.1:9996 subscribed to: test
^C[INFO] (src/mongrel2.c:83) SHUTDOWN REQUESTED: GRACEFUL (SIGINT again to EXIT NOW)
[ERROR] (src/task/net.c:241: errno: Bad file descriptor) Failed calling accept on socket that was ready.
[INFO] (src/mongrel2.c:312) Shutdown requested, goodbye.
[ERROR] (src/handler.c:169: errno: Resource temporarily unavailable) Receive on handler socket failed.
[INFO] (src/mongrel2.c:252) Waiting for connections to die: -1
[INFO] (src/mongrel2.c:261) Removing pid file ./run/mongrel2.pid
@bad
bad / query-test-case.rb
Created December 5, 2010 15:40
test case demonstrating that Spira w/SPARQL::Client repository makes excessive CONSTRUCT queries
require 'rubygems'
require 'ruby-debug'
require 'spira'
require 'rdf/rdfxml'
require 'sparql/client'
class Actor
include Spira::Resource
@lxneng
lxneng / gist:741932
Created December 15, 2010 13:21
install PostgreSQL 9 in Mac OSX via Homebrew
install PostgreSQL 9 in Mac OSX via Homebrew
Mac OS X Snow Leopard
System Version: Mac OS X 10.6.5
Kernel Version: Darwin 10.5.0
Install notes for PostgreSQL 9.0.1 install using Homebrew:
sh-3.2# brew install postgresql
@dustinsenos
dustinsenos / asshat.js
Created December 17, 2010 00:30
Add support for the <asshat> element in HTML
/*
After embedding the following JavaScript within your <head> element you can semantically
mark those who are asshats. The <asshat></asshat> tag is often used to replace <cite>
when quoting sources. The script will work in all flavours of IE and modern browsers.
Now where is my </sarcasm> tag?
This is free and unencumbered software released into the public domain.
%w[address_1 city state zip_code].each do |attr|
validates_presence_of attr, unless: ->(org) { org.send(attr).nil? }
end