Skip to content

Instantly share code, notes, and snippets.

View pgte's full-sized avatar
🏠
Working from home

Pedro Teixeira pgte

🏠
Working from home
View GitHub Profile
@pgte
pgte / peer-star-app.md
Last active June 27, 2018 14:50
peer-star-app
  • 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.

@pgte
pgte / Keybase.md
Created February 6, 2018 15:16
Keybase

Keybase proof

I hereby claim:

  • I am pgte on github.
  • I am pgte (https://keybase.io/pgte) on keybase.
  • I have a public key ASBfSphgzAav1T3NDE4lHUnF6XEjThKMBaMHdr0XUsH-nwo

To claim this, I am signing this object:

function someFn(req, res) {
// do stuff...
}
route('/someRoute', someFn);
@pgte
pgte / http-client-request-observe.js
Last active January 17, 2021 09:27
node request and response life cycle
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 = {
@pgte
pgte / pet_projects.md
Created December 18, 2014 09:58
Pet Projects

Kernelify

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
@pgte
pgte / npm output
Created May 28, 2014 13:18
npm output
npm http PUT https://registry.npmjs.org/nock
npm http 201 https://registry.npmjs.org/nock
npm http GET https://registry.npmjs.org/nock
npm http 200 https://registry.npmjs.org/nock
npm http PUT https://registry.npmjs.org/nock/-/nock-0.32.3.tgz/-rev/288-9c18881d4c96938b50a923918f2b06cb
npm http 502 https://registry.npmjs.org/nock/-/nock-0.32.3.tgz/-rev/288-9c18881d4c96938b50a923918f2b06cb
npm ERR! registry error parsing json
@pgte
pgte / personalized_sync_arch.md
Last active August 29, 2015 14:00
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.

@pgte
pgte / auth.md
Last active December 31, 2015 14:49

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