Skip to content

Instantly share code, notes, and snippets.

Working on a project for the government

Pedro Teixeira pgte

Working on a project for the government
View GitHub Profile
pgte /
Last active Jun 27, 2018
  • Released on June 27th 2018
  • Expires on July 31st 2018

peer-star-app for peer-star app developers

Hello peer-star app developer! 👋

In an effor to make PeerPad scale better for many users editing the same pad, over the last few weeks I've been focused on implementing the topology and protocol described here. This is materializing in the form of a package named peer-star-app.


Keybase proof

I hereby claim:

  • I am pgte on github.
  • I am pgte ( on keybase.
  • I have a public key ASBfSphgzAav1T3NDE4lHUnF6XEjThKMBaMHdr0XUsH-nwo

To claim this, I am signing this object:

View routes.js
function someFn(req, res) {
// do stuff...
route('/someRoute', someFn);
pgte / http-client-request-observe.js
Last active Aug 14, 2017
node request and response life cycle
View http-client-request-observe.js
var https = require('https');
var querystring = require('querystring');
var events = ['socket', 'connection', 'response', 'data', 'end', 'close', 'finish'];
var postData = querystring.stringify({
'msg' : 'Hello World!'
var options = {


Node.js kernel generators.

Sombrero cluster

Have the node. Now need to figure out:

  • DHT-based sharding, Gossip and all that stuff
  • Proxy: Gossip client + reverse HTTP proxy
View npm output
npm http PUT
npm http 201
npm http GET
npm http 200
npm http PUT
npm http 502
npm ERR! registry error parsing json
pgte /
Last active Aug 29, 2015
personalized sync

Personalized Sync

The goal is for each client to have a local personalized copy of the database. This personal local database is a subset of all the existing documents. Clients can share documents or not.

Authenticated session and filters

Each client intiates an authenticated session with the server. On each session, server sets up personalized read and write filters. These filters only propagate changes that the user is allowed / interested in.


I built this service rendered over HTTPS.

We're using the Hawk protocol to authenticate message producers, but since the service will use HTTPS, Hawk is an overkill in my opinion.

Some of the drawbacks of using Hawk in my opinion:

  1. Signs whole message: overkill when you're using TLS
  2. Tries to be stateless on the server-side and implements a sort of message non-repeatability by including a timestamp inside the message. The timestamp has to be equal to the server-side time take or give 1 minute. This imposes time synchronizatin between client and server, which is hard to enforce.

Recipe for customizing a SmartoOS image and cloning it

1. Create base image

1.1. Download and install the base image:

[root@00-0c-29-aa-24-ba ~]# imgadm list
UUID                                  NAME             VERSION  OS       PUBLISHED
9eac5c0c-a941-11e2-a7dc-57a6b041988f  base64           13.1.0   smartos  2013-04-26T15:17:57Z
You can’t perform that action at this time.