Skip to content

Instantly share code, notes, and snippets.

View JosePedroDias's full-sized avatar

José Pedro Dias JosePedroDias

View GitHub Profile
@JosePedroDias
JosePedroDias / index.md
Last active February 7, 2021 16:30
build ODE

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 December 27, 2020 19:20
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
JosePedroDias / fetchFireAndForget.ts
Created December 3, 2020 16:24
fetch fire and forget in nodejs (I suppose it works in the browser as well)
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 August 6, 2020 16:19
to eventually use in node instead of request
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 July 13, 2020 18:02
tampermonkey userscripts for cookies and localStorage
@JosePedroDias
JosePedroDias / jsonl.js
Last active April 18, 2020 15:24
jsonl as generators
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 March 2, 2020 22:10
spy and spyOnObject
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 / keybase.md
Created February 15, 2020 02:55
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:

@JosePedroDias
JosePedroDias / photo_trace_with_gimp.md
Created February 9, 2020 14:25
photo trace with gimp
  • 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
@JosePedroDias
JosePedroDias / modules.js
Last active January 5, 2020 13:37
traverse to manipulate JSON
// yarn list --json > modules.json
const fs = require('fs');
const O = require('./modules.json');
function visit(o) {
if (typeof o === 'object' && o !== null) {
if (o instanceof Array) {
// change array (noop)