Skip to content

Instantly share code, notes, and snippets.

View dlongley's full-sized avatar

Dave Longley dlongley

View GitHub Profile
@dlongley
dlongley / transform.js
Created November 15, 2019 16:23
Convert native types
const jsonld = require('jsonld');
const input = {
"@context": {
"@vocab": "http://vocab.example/"
},
"age": {
"@value": "27",
"@type": "http://www.w3.org/2001/XMLSchema#integer"
}
{
'@context': 'https://w3id.org/veres-one/v1',
id: did,
// implicitly has a type of LinkedDataObjectCapability itself
authentication: [{
type: 'RsaSignatureAuthentication2018',
publicKey: {
// this key can be used to authenticate as DID entity
id: did + '#authn-key-1',
type: 'RsaSigningKey2018',
@dlongley
dlongley / keybase.md
Last active January 6, 2016 19:23
keybase.md

Keybase proof

I hereby claim:

  • I am dlongley on github.
  • I am dlongley (https://keybase.io/dlongley) on keybase.
  • I have a public key whose fingerprint is 6A91 B5D1 77F3 6E62 6F07 1E06 CC8A 9C73 4ED9 30CF

To claim this, I am signing this object:

@dlongley
dlongley / gist:8827309
Last active August 29, 2015 13:56
Web Identity Assertion Format
{
"id": "http://example.com/identity/dave.longley"
"assertion": [{
"id": "http://example.net/assertions/bar",
"type": "Passport",
"endorsement": {
"id": "http://example.com/identity/dave.longley",
"name": "Dave Longley",
"governmentId": "38940954909823"
},
Change this:
function payswarm_hash($obj) {
// SHA-1 hash JSON
$options = array('format' => 'application/nquads');
return 'urn:sha256:' . hash('sha256', jsonld_normalize($obj, $options));
}
To this:
/* Begin node.js Style */
playground.performAction = function(input, callback) {
var processor = new jsonld.JsonLdProcessor();
if(playground.activeTab === 'tab-compacted') {
processor.compact(input, function(err, compacted) {
if(err) {
return callback(err);
}
{
"@context": {
"@vocab": "http://schema.org/",
"id": "@id",
"ref": "@id",
"type": "@type"
},
"@graph": [
{
"type": "http://schema.org/Event",
{
"@context": {
"@vocab": "http://schema.org/",
"id": "@id",
"ref": "@id",
"type": "@type"
}
}