Skip to content

Instantly share code, notes, and snippets.

View melvincarvalho's full-sized avatar
💭
I may be slow to respond.

Melvin Carvalho melvincarvalho

💭
I may be slow to respond.
View GitHub Profile
@melvincarvalho
melvincarvalho / clip.js
Created November 8, 2015 20:04
clip.js
$rdf = require('rdflib');
var CHAT = $rdf.Namespace("https://ns.rww.io/chat#");
var CURR = $rdf.Namespace("https://w3id.org/cc#");
var DCT = $rdf.Namespace("http://purl.org/dc/terms/");
var FACE = $rdf.Namespace("https://graph.facebook.com/schema/~/");
var FOAF = $rdf.Namespace("http://xmlns.com/foaf/0.1/");
var LIKE = $rdf.Namespace("http://ontologi.es/like#");
var LDP = $rdf.Namespace("http://www.w3.org/ns/ldp#");
var MBLOG = $rdf.Namespace("http://www.w3.org/ns/mblog#");
@melvincarvalho
melvincarvalho / webfinger-diff.txt
Created November 11, 2015 01:22
webfinger differences
Differences between JRD and RDF data models:
1. Each document can have at most one subject per document.
2. Although the subject is optional in JRD, bnodes are not explicitly covered.
3. There are three named objects associated with a subject, links (analogous to predicate / URI pairs) and properties (analagous to predicate / literal pairs), aliases (much like owl : sameAs)
4. The literals are restricted to string and null (RDF uses the xsd types)
@melvincarvalho
melvincarvalho / webcredit.ttl
Created November 15, 2015 15:55
webcredit.ttl
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
<#this>
a <https://w3id.org/cc#Credit> ;
<https://w3id.org/cc#amount> 100 ;
<https://w3id.org/cc#currency> <https://w3id.org/cc#bit> ;
<https://w3id.org/cc#destination> <http://melvincarvalho.com/#me> ;
<https://w3id.org/cc#source> <https://workbot.databox.me/profile/card#me> .
@melvincarvalho
melvincarvalho / signup.js
Created November 27, 2015 14:51
signup.js
var leftPosition, topPosition;
var width = 1024;
var height = 600; //Allow for borders.
leftPosition = (window.screen.width / 2) - ((width / 2) + 10); //Allow for title and status bars.
topPosition = (window.screen.height / 2) - ((height / 2) + 50);
window.open(https://solid.github.io/solid-idps/?origin="+encodeURIComponent(window.location.href), "Solid signup", "resizable,scrollbars,status,width="+width+",height="+height+",left="+ leftPosition + ",top=" + topPosition);
@melvincarvalho
melvincarvalho / createpost.js
Created November 27, 2015 22:03
createpost.js
/**
* create a post in turtle
* @param {string} webid the creator
* @param {string} message the message to send
* @param {string} application application that created it
* @param {string} img img for that post
* @return {string} the message in turtle
*/
function createPost(webid, message, application, img) {
var turtle;
.dump | grep -v "BEGIN TRANSACTION;" | grep -v "PRAGMA" | grep -v "COMMIT;" | perl -pe 's/INSERT INTO \"(.*)\" VALUES/INSERT INTO `\1` VALUES/' | mysql inartes
for post in $(for i in $(rdf ls $TIME/) ; do rdf ls $i ; done) ; do curl -X PATCH -H "Content-type: application/sparql-update" -d "INSERT DATA { <#this> <http://www.w3.org/ns/solid/terms#timeline> <$TIME/> }" $post ; sleep 1 ; done
/**
* init RDF knowledge base
*/
$scope.initRDF = function() {
var PROXY = "https://databox.me/,proxy?uri={uri}";
//var AUTH_PROXY = "https://rww.io/auth-proxy?uri=";
var TIMEOUT = 60000;
$rdf.Fetcher.crossSiteProxyTemplate=PROXY;
a = __scope.easy.sort(function(a,b){ return a<b ? -1 : 1; })
str = '' ; for (var i=1; i<=2000; i++) { if(a.indexOf(i) === -1) str += (i + ' ' + __scope.getPair(i).cs + ' ' + __scope.getPair(i).en + '\n' ); } ; console.log(str);
@melvincarvalho
melvincarvalho / hook.json
Created February 7, 2016 20:07
hook.json twtxt
{
"post_tweet_hook": "sleep 1 ; curl -H \"Content-Type: text/plain; charset=UTF-8\" --cert $CERT --key $CERT -X PUT --data-binary @/home/melvin/twtxt.txt https://melvin.databox.me/Public/twtxt/twtxt.txt",
"user": "melvincarvalho",
"twtfile": "/home/melvin/twtxt.txt",
"limit_timeline": "20",
"following": [
{
"user": "twtxt",
"uri": "https://buckket.org/twtxt_news.txt"
}