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:6967844
Created October 13, 2013 21:57
tx from table
s='';i=0; $('tr:gt(3)').each(function() { rows = ($(this).find('td')); s+=( '<#t_' + i++ + '> a <https://w3id.org/commerce#Transfer> ; <http://purl.org/dc/terms/created> "' + rows[1].textContent + '" ; <http://xmlns.com/ns/foaf/0.1/name> "' + rows[2].textContent + '" ; <https://w3id.org/commerce#amount> ' + rows[3].textContent + ' ; <http://www.w3.org/2000/01/rdf-schema#comment> "' + rows[4].textContent + '" .\n') ; }) ; console.log(s);
@melvincarvalho
melvincarvalho / gist:7163697
Created October 26, 2013 00:02
bitcoin blocks
bitcoind --daemon
wget http://stedolan.github.io/jq/download/linux64/jq
export BLOCK=00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048 ; for ((;;)) do BLOCK=`bitcoind getblock $BLOCK | ./jq -r '.nextblockhash'` ; echo $BLOCK ; done
@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 = [];