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 / gist:9736377
Created March 24, 2014 08:31
decode genesis block
var g = '020000000000000000000000000000000000000000000000000000000000000000000000da1adfa2ed7ad4d5404e738a0b6edb6146784ab23dbaef7d9336944051049f4e01e82f531d00ffff76dc2686'
[ g.substring(0,8), g.substring(8,72) , g.substring(72,136), g.substring(136,144), g.substring(144,152), g.substring(152, 160) ]
@melvincarvalho
melvincarvalho / gist:11127689
Created April 20, 2014 23:12
Parsing Hex with bitcore
var bitcore = require('bitcore');
require('buffertools').extend();
var Block = bitcore.Block;
var BinaryParser = bitcore.BinaryParser;
var b = new Block();
var buf = new Buffer(block);
buf = buf.fromHex();
var p = new BinaryParser(buf);
b.parse(p);
@melvincarvalho
melvincarvalho / put.js
Created June 6, 2014 11:13
PUT a file to a data space
var https = require('https');
var fs = require("fs");
var options = {
host: 'domain_name',
port: 443,
path: 'path_to_file',
method: 'PUT',
key: fs.readFileSync("path_to_key.key"),
cert: fs.readFileSync("path_to_cert.crt"),
@melvincarvalho
melvincarvalho / gist:00a225c8c5d816a900e4
Created September 25, 2014 12:01
Vanitygen for bitmark
var bitcore = require('bitcore');
// loop here
var password = 'loop here';
var privateKey = bitcore.util.sha256(password);
var key = new bitcore.Key();
key.private = privateKey;
<!DOCTYPE html>
<html>
<head>
<title>User Registration</title>
<script src="bitcorelatest.js"></script>
<script>
// Derive given private key index..
function get_bip32_key(path) {
@melvincarvalho
melvincarvalho / post to ldpc and acl
Created February 1, 2015 10:18
post to ldpc and acl
# init
#LDPC="https://localhost:8888/test/put/"
#LDPC="https://melvin.rww.io/workspace/blog/ch5/"
LDPC=$(git config webid.weblog)
KEYFILE=$(git config webid.keyfile)
WEBID=$(git config user.webid)
NAME=$(git config user.name)
DEPICTION=$(git config user.depiction)
USER_AGENT='User-Agent: Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/39.0.2171.65 Chrome/39.0.2171.65 Safari/537.36'
@melvincarvalho
melvincarvalho / log.js
Last active August 29, 2015 14:14
log gitter to file and ldp
var https = require('https');
var fs = require('fs');
var roomId = process.env.ROOM_ID;
var token = process.env.TOKEN;
var heartbeat = " \n";
console.log('logging room : ' + roomId);
var gitter = {
@melvincarvalho
melvincarvalho / gist:5e3e9ba4a36ecb3fae17
Created February 27, 2015 11:24
taskify data model
// items
if (!todo.items) todo.items = [];
for (var i=0; i<todo.items.length; i++) {
var id = todo.items[i].id.indexOf('http') ? '#' + todo.items[i].id : todo.items[i].id;
str += '\n'+ '<' + id + '> a <http://dig.csail.mit.edu/2010/issues/track#Task> .';
str += '\n'+ '<' + id + '> <http://purl.org/dc/terms/description> "'+ escape(todo.items[i].text) +'".';
str += '\n'+ '<' + id + '> <http://www.w3.org/2002/12/cal/ical#completed> '+ todo.items[i].complete +'.';
str += '\n'+ '<' + id + '> <https://taskify.org/ns/task#urgent> '+ todo.items[i].urgent +'.';
str += '\n'+ '<' + id + '> <https://taskify.org/ns/task#important> '+ todo.items[i].important +'.';
if (!todo.items[i].tags) todo.items[i].tags = [];
$.ajax({
url: 'https://silverbucket.rww.io/profile/card',
contentType: "application/sparql-update",
type: 'PATCH',
data: 'INSERT DATA { <https://silverbucket.rww.io/profile/card#me> <http://xmlns.com/foaf/0.1/knows> <http://melvincarvalho.com/#me> . } ',
success: function(result) {
}
});
@melvincarvalho
melvincarvalho / cert.n3
Last active August 29, 2015 14:17
cert.n3 with private key (domel)
@base <http://www.w3.org/ns/auth/cert> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix wot: <http://xmlns.com/wot/0.1/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix vs: <http://www.w3.org/2003/06/sw-vocab-status/ns#> .
@prefix dc: <http://purl.org/dc/terms/>.