Skip to content

Instantly share code, notes, and snippets.

View JosePedroDias's full-sized avatar

José Pedro Dias JosePedroDias

View GitHub Profile
@JosePedroDias
JosePedroDias / README.md
Last active October 28, 2021 16:38
simple interceptor of webgl context calls (for when spector.js is an overkill)

the code should be called right after we obtain the GL context. Don't forget to reset/edit ignoreCommands if you intend to capture some of those.

example usages:

fakeGl.captureOperations(40)
...
fakeGl.ignoreCommands = []
@JosePedroDias
JosePedroDias / loadImageFile.js
Created February 15, 2016 01:01
load image file from input element to blob and canvas
function loadImageFile(inputEl) {
inputEl.addEventListener('change', function () {
inputEl.disabled = true;
var file0 = inputEl.files[0]; // BLOB
var url = URL.createObjectURL(file0);
//console.log('url', url);
var img = new Image;
img.onload = function() {
//ctx.drawImage(img, 20, 20);
}
@JosePedroDias
JosePedroDias / map.geojson
Last active October 16, 2021 09:23
Maratona de Lisboa 2021-10-17
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@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 / 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 / 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 / srtize.js
Last active February 21, 2020 20:13
load SRT file into WebVTT track for a video element in the page
'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);
@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: