Skip to content

Instantly share code, notes, and snippets.

Avatar
🕉️
all good

José Pedro Dias JosePedroDias

🕉️
all good
View GitHub Profile
View index.md

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
JosePedroDias / README.md
Last active Dec 27, 2020
Fix Strava GPX
View README.md

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
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
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(
url,
@JosePedroDias
JosePedroDias / debug_cookie_set.js
Created Jul 13, 2020
tampermonkey userscripts for cookies and localStorage
View debug_cookie_set.js
@JosePedroDias
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
JosePedroDias / spy.js
Created Mar 2, 2020
spy and spyOnObject
View spy.js
function spy(fn, prot = fn.prototype) {
function proxy() {
const args = Array.prototype.slice.call(arguments);
proxy.calls.push(args);
proxy.called = true;
return fn.apply(this, args);
}
proxy.prototype = prot;
@JosePedroDias
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);
View keybase.md

Keybase proof

I hereby claim:

  • I am josepedrodias on github.
  • I am josepedrodias (https://keybase.io/josepedrodias) on keybase.
  • I have a public key ASAK1PVQv74qCAcdG8fz1yGPHE1WIExSVThhfHRlFKzhfAo

To claim this, I am signing this object:

View photo_trace_with_gimp.md
  • image > scale image > 200%
  • filters > edge detect > difference of gaussians > 9 / 1
  • colors > desaturate
  • colors > levels > push left bottom point rightwards, manipulate rightmost line to accentuate trace width wo/ much noise added