Skip to content

Instantly share code, notes, and snippets.

View pedropalhari's full-sized avatar

Pedro Palhari pedropalhari

View GitHub Profile
@pedropalhari
pedropalhari / whatsapp_web_speedup_audio.js
Last active August 2, 2023 14:35
Whatsapp Web Speedup audio
// ==UserScript==
// @name Whatsapp Audio Speedup
// @namespace https://palhari.dev
// @version 0.1
// @description try to take over the world!
// @author Pedro Palhari
// @match https://web.whatsapp.com/*
// @grant none
// ==/UserScript==
@pedropalhari
pedropalhari / get_blob_from_img.js
Created October 30, 2020 12:51
Get blob from <img /> using Canvas. In that way you can append it to a FormData and make a POST with it.
//let img = document.querySelector("img");
async function imgSourceToBlob(img) {
let canvas = document.createElement('canvas');
canvas.width = img.width;
canvas.height = img.height;
let ctx = canvas.getContext('2d');
ctx.drawImage(img, 0, 0);
@pedropalhari
pedropalhari / mod.js
Created January 5, 2021 15:14
Streaming and static video serving with Deno & Oak
import {
Application,
Router,
send,
} from "https://deno.land/x/[email protected]/mod.ts";
const app = new Application();
const router = new Router();
// ==UserScript==
// @name [GITHUB] Create branch from issue
// @namespace http://tampermonkey.net/
// @version 1.0
// @description Creates a branch using the issue. Adds a button to the interface.
// @author Pedro Palhari
// @match https://github.com/*/*/issues/*
// @grant none
// ==/UserScript==
@pedropalhari
pedropalhari / .bashrc
Created May 5, 2021 18:01
Node.js with Typescript without the massive ts-node overhead
#export NODE_PATH=/home/pedro/.nvm/versions/node/v14.16.0/lib/node_modules
export NODE_PATH=
alias tnode="node -r @swc-node/register"
@pedropalhari
pedropalhari / afetch.ts
Last active May 24, 2021 15:14
A(uthorized) Fetch used for fast prototyping. We need only `{ error: boolean; message: string }` if there's an error on the API.
// a(uthorized)fetch
function getAccessToken() {
return localStorage.getItem("@project/accessToken");
}
function setAccessToken(token: string) {
localStorage.setItem("@project/accessToken", token);
}
@pedropalhari
pedropalhari / bash.js
Created May 26, 2021 03:59
bash helper for linux shell scripts
const { execSync } = require("child_process");
function bash(template, ...substitutions) {
let command = String.raw(template, substitutions);
let out = execSync(command);
return out.toString();
}
{
"application/vnd.lotus-1-2-3": [".123"],
"text/vnd.in3d.3dml": [".3dml"],
"video/3gpp2": [".3g2"],
"video/3gpp": [".3gp"],
"application/octet-stream": [
".a",
".bin",
".bpk",
".deploy",
@pedropalhari
pedropalhari / sane-next.json
Created July 2, 2021 09:56
Two commands that MUST be there on every Next.js project I do
{
"dev": "concurrently -c green.bold,blue.bold -n NEXT,TSC \"npm run dev-next\" \"npm run dev-tsc\"",
"dev-next": "next dev",
"dev-tsc": "tsc --noEmit --watch --preserveWatchOutput",
"build": "rimraf ./.next && next build && next export"
}
@pedropalhari
pedropalhari / nexus-utils.ts
Last active January 28, 2022 18:10
Nexus GraphQL `commonType` utility. To define fields to be shared.
import { InputDefinitionBlock, OutputDefinitionBlock } from "nexus/dist/blocks";
type TType<T extends string> =
| InputDefinitionBlock<T>
| OutputDefinitionBlock<T>;
// Type for the definition.
type CommonTypeDefinitionFunction = <T extends string>(
t: InputDefinitionBlock<T>
) => void;