Skip to content

Instantly share code, notes, and snippets.

View andreabadesso's full-sized avatar

André Abadesso andreabadesso

View GitHub Profile
const websocketMachine = Machine({
id: 'websocket',
initial: 'CONNECTING',
context: {
lastEventId: null,
socket: null,
},
invoke: {
src: 'initializeWebSocket',
onDone: 'CONNECTED',
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
const syncHandler = () => () => {
return () => {};
}
const SyncMachine = Machine({
id: 'sync',
initial: 'idle',
context: {
hasMoreBlocks: false,
},
@andreabadesso
andreabadesso / tx_proposal_initial_sync.js
Last active March 15, 2021 20:01
Tx Proposal Initial Sync Proof-of-Concept
/* eslint-disable */
const fs = require('fs');
const readline = require('readline');
const { once } = require('events');
const WebSocket = require('ws');
const AWS = require('aws-sdk');
const axios = require('axios').default;
const lineByLine = require('n-readlines');
const Promise = require('bluebird');
@andreabadesso
andreabadesso / tmux-cheatsheet.markdown
Created February 8, 2017 16:09 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@andreabadesso
andreabadesso / Before and after image slider.markdown
Created August 1, 2015 14:52
Before and after image slider
import redis
import threading
class Listener(threading.Thread):
def __init__(self, r, channels):
threading.Thread.__init__(self)
self.redis = r
self.pubsub = self.redis.pubsub()
self.pubsub.subscribe(channels)
@andreabadesso
andreabadesso / sign_request.js
Created July 4, 2014 04:57
Sign Google Maps for Business requests with the privateKey using Node.js
var crypto = require('crypto'),
url = require('url'),
URLSafeBase64 = require('urlsafe-base64');
function GenerateSignature(privateKey, query) {
var u = url.parse(query);
var urlToSign = u.path;
var decodedKey = URLSafeBase64.decode(privateKey);
var signature = crypto.createHmac('sha1', decodedKey).update(urlToSign);
var encodedSignature = URLSafeBase64.encode(signature.digest());
@andreabadesso
andreabadesso / codifica.c
Created April 8, 2014 00:43
rodolfobixa
int codifica(void* valores, char *campos) {
char tipo;
int acc = 0;
int i;
int temint = 0;
int ultimoChar = 0;
int padding = 0;
int pad = 0;
for (i=0;i<=strlen(campos);i++) {
@andreabadesso
andreabadesso / codifica.c
Created April 7, 2014 14:58
Trying to access struct members knowing the data format
int codifica(void* valores, char *campos) {
char tipo;
int acc = 0;
int acc2 = 0;
int i;
for (i=0;i<=strlen(campos);i++) {
tipo = campos[i];
// p = *(int*)valores;
// v = (*((int*)valores+1));