Skip to content

Instantly share code, notes, and snippets.

Avatar
🕉️
all good

José Pedro Dias JosePedroDias

🕉️
all good
View GitHub Profile
@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
@JosePedroDias
JosePedroDias / modules.js
Last active Jan 5, 2020
traverse to manipulate JSON
View modules.js
// 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)
View set-operations.js
// s1 contains all elements of s2
function setContains(s1, s2) {
return new Set([...s2].every(x => s1.has(x)));
}
// elements in both s1 and s2
function setIntersection(s1, s2) {
return new Set([...s1].filter(x => s2.has(x)));
}
@JosePedroDias
JosePedroDias / ideas.md
Last active Oct 4, 2019
ldjam 45 ideas
View ideas.md

THEME: Start with nothing

1

  • there's a character with a preset script of directions he will take. We get those as an overlay
  • our job is to make the hero reach somewhere in the initially empty map by adding tiles

social twist:

  • if each set of movements is driven by a seed of a random number generator, we can map different solutions of the same movements to different ending maps.
You can’t perform that action at this time.