Skip to content

Instantly share code, notes, and snippets.

View bmaddy's full-sized avatar

Brian Maddy bmaddy

View GitHub Profile
bmaddy@foo:~/src/sandbox/2014/fedora_lens[master]$ curl -X GET -H "Content-Type: text/turtle" "http://localhost:8080/rest/node/to/update"
<http://localhost:8080/rest/node/to/update> <http://fedora.info/definitions/v4/rest-api#hasAccessRoles> <http://localhost:8080/rest/node/to/update/fcr:accessroles> .
<http://localhost:8080/rest/node/to/update/fcr:export?format=jcr/xml> <http://www.w3.org/2000/01/rdf-schema#label> "jcr/xml"^^<http://www.w3.org/2001/XMLSchema#string> .
<http://localhost:8080/rest/node/to/update> <http://fedora.info/definitions/v4/rest-api#exportsAs> <http://localhost:8080/rest/node/to/update/fcr:export?format=jcr/xml> ;
<http://fedora.info/definitions/v4/rest-api#hasVersions> <http://localhost:8080/rest/node/to/update/fcr:versions> ;
<http://www.w3.org/ns/ldp#nextPage> <http://localhost:8080/rest/node/to/update?limit=-1&amp;offset=-1> ;
<http://www.w3.org/ns/ldp#firstPage> <http://localhost:8080/rest/node/to/update?limit=-1&amp;offset=0> ;
<http://localhost:8080/rest/node/to/update/fcr:export?format=jcr/xml> <http://www.w3.org/2000/01/rdf-schema#label> "jcr/xml" .
<http://localhost:8080/rest/node/to/update> a <http://www.w3.org/ns/ldp#Container>,
<http://www.w3.org/ns/ldp#Page>,
<http://fedora.info/definitions/v4/rest-api#resource>,
<http://fedora.info/definitions/v4/rest-api#object>;
<http://fedora.info/definitions/v4/repository#baseVersion> <http://localhost:8080/rest/jcr:system/jcr:versionStorage/9b/e0/ec/9be0eca8318518d305dde3151233904638129868/jcr:rootVersion>;
<http://fedora.info/definitions/v4/repository#created> "2014-02-04T01:59:02.242Z";
<http://fedora.info/definitions/v4/repository#createdBy> "bypassAdmin";
<http://fedora.info/definitions/v4/repository#hasParent> <http://localhost:8080/rest/node/to>;
@bmaddy
bmaddy / gist:9004763
Created February 14, 2014 16:57
debugging ldp/faraday
2.0.0p353 :018 > HOST = 'http://localhost:8080'
=> "http://localhost:8080"
2.0.0p353 :019 > client = Ldp::Client.new(HOST)
=> #<Ldp::Client:0x007f8f9f0c5860 @http=#<Faraday::Connection:0x007f8f9f0c5770 @parallel_manager=nil, @headers={"User-Agent"=>"Faraday v0.9.0"}, @params={}, @options=#<Faraday::RequestOptions (empty)>, @ssl=#<Faraday::SSLOptions (empty)>, @default_parallel_manager=nil, @builder=#<Faraday::RackBuilder:0x007f8f9f0c4938 @handlers=[Faraday::Request::UrlEncoded, Faraday::Adapter::NetHttp]>, @url_prefix=#<URI::HTTP:0x007f8f9f0c40c8 URL:http://localhost:8080/>, @proxy=nil>>
2.0.0p353 :020 > resource = Ldp::Resource.new(client, HOST + '/rest/node/to/update')
=> #<Ldp::Resource:0x007f8f9f0e8798 @client=#<Ldp::Client:0x007f8f9f0c5860 @http=#<Faraday::Connection:0x007f8f9f0c5770 @parallel_manager=nil, @headers={"User-Agent"=>"Faraday v0.9.0"}, @params={}, @options=#<Faraday::RequestOptions (empty)>, @ssl=#<Faraday::SSLOptions (empty)>, @default_parallel_manager=nil, @builder=#<Faraday::RackBuil
@bmaddy
bmaddy / gist:7252993
Last active September 14, 2019 02:05
Sieve of Eratosthenes using Clojure's core.async.
(ns async-sieve.core
(:require [clojure.core.async :refer [chan go go-loop <! <!! >! filter<]]))
;; Sieve of Eratosthenes as described here:
;; http://swtch.com/~rsc/thread/
;; Just to clarify, this isn't how core.async should be used, it's just a fun example:
;; "note that async channels are not intended for fine-grained computational parallelism"
;; - Rich Hickey (from http://clojure.com/blog/2013/06/28/clojure-core-async-channels.html)
(defn prime-filter [in primes]
(go
(ns cljs-demo.http
(:require [cljs.nodejs :as node]))
(def http
(node/require "http"))
(defn handler [_ res]
(.writeHead res 200 (js-obj "Content-Type" "text/plain"))
(.end res "Hello World!\n"))
(defproject prov "1.0.0-SNAPSHOT"
:description "FIXME: write description"
:dependencies [[org.cloudhoist/pallet "0.6.7"]
[org.cloudhoist/pallet-crates-all "0.5.0"]
[org.jclouds/jclouds-all "1.0.0"]
; Logging stuff that makes things super slow
;[org.slf4j/slf4j-api "1.6.1"]
;[ch.qos.logback/logback-core "1.0.0"]
;[ch.qos.logback/logback-classic "1.0.0"]
;[org.jclouds.driver/jclouds-jsch "1.0.0"]
(ns prov.core
(:require [pallet.core]
[pallet.utils :as utils]
[pallet.phase :as phase]
[pallet.action.package :as package]
[pallet.compute :as compute]
[pallet.crate.ssh :as ssh]
[pallet.crate.automated-admin-user :as automated-admin-user]))
(def service
@bmaddy
bmaddy / gist:912632
Created April 10, 2011 19:17
Continuation monad in javascript
function M(){};
M.contResult = function(value){
return function(cont){
console.log('in result: ' + value);
return cont(value);
}
}
M.contBind = function(mValue, mFunc){
@bmaddy
bmaddy / gist:822663
Created February 11, 2011 17:01
How does escaping work in Rails 3?
bmaddy@foo:~/src/sandbox/console$ rails c
Loading development environment (Rails 3.0.4)
ruby-1.8.7-p330 :001 > User.count
=> 0
ruby-1.8.7-p330 :002 > User.order("name; delete from users;--").to_sql
=> "SELECT \"users\".* FROM \"users\" ORDER BY name; delete from users;--"
ruby-1.8.7-p330 :003 > User.order("?", "name; delete from users;--").to_sql
=> "SELECT \"users\".* FROM \"users\" ORDER BY ?, name; delete from users;--"
ruby-1.8.7-p330 :004 > User.order(["?", "name; delete from users;--"]).to_sql
=> "SELECT \"users\".* FROM \"users\" ORDER BY ?, name; delete from users;--"