Skip to content

Instantly share code, notes, and snippets.

all good

José Pedro Dias JosePedroDias

all good
View GitHub Profile
# based on
# mitmproxy -s
# mitmdump -s
from mitmproxy import http
def response(flow):
h = flow.request.headers

Build ODE in Linux

simple approach (can't choose revelant things):

sudo apt add libode-dev

otherwise use premake as explained below

Build ODE in Windows

JosePedroDias /
Last active Dec 27, 2020
Fix Strava GPX

Your GPS device has messed up and the recorded route has a faulty segment?

This code iterates over recorded points, finding biggest distance discrepancy and allowing you to remove it and save an altered XML version leaving out those measurements.

JosePedroDias / fetchFireAndForget.ts
Created Dec 3, 2020
fetch fire and forget in nodejs (I suppose it works in the browser as well)
View fetchFireAndForget.ts
import http from 'http';
import https from 'https';
import fetch, { Response } from 'node-fetch';
import { AbortController } from 'abort-controller';
const DEFAULT_TIMEOUT = 10000;
const httpAgent = new http.Agent({
keepAlive: true,
JosePedroDias / homemadeGet.js
Created Aug 6, 2020
to eventually use in node instead of request
View homemadeGet.js
const http = require('http');
const https = require('https');
const HEADERS = {};
function get(url, body, moreHeaders) {
const prot = url.indexOf('https:') === 0 ? https : http;
return new Promise((resolve, reject) => {
const r = prot.request(
JosePedroDias / debug_cookie_set.js
Created Jul 13, 2020
tampermonkey userscripts for cookies and localStorage
View debug_cookie_set.js
JosePedroDias / jsonl.js
Last active Apr 18, 2020
jsonl as generators
View jsonl.js
const fs = require('fs');
const readline = require('readline');
async function* readJsonlGen(filename) {
const lineReader = readline.createInterface({
input: fs.createReadStream(filename),
let i = 0;
for await (const line of lineReader) {
JosePedroDias / spy.js
Created Mar 2, 2020
spy and spyOnObject
View spy.js
function spy(fn, prot = fn.prototype) {
function proxy() {
const args =;
proxy.called = true;
return fn.apply(this, args);
proxy.prototype = prot;
JosePedroDias / srtize.js
Last active Feb 21, 2020
load SRT file into WebVTT track for a video element in the page
View srtize.js
'use strict';
function parseTime(s) {
let t = 0;
const p = s.split(':');
let ss = p.pop().replace(',', '.');
t += parseFloat(ss);
ss = parseInt( p.pop() || '0', 10);
t += ss * 60;
ss = parseInt( p.pop() || '0', 10);

Keybase proof

I hereby claim:

  • I am josepedrodias on github.
  • I am josepedrodias ( on keybase.
  • I have a public key ASAK1PVQv74qCAcdG8fz1yGPHE1WIExSVThhfHRlFKzhfAo

To claim this, I am signing this object: