This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import axios from 'axios'; | |
import { IncomingMessage } from 'http'; | |
// browser version would use Uint8Array instead of Buffer and woudln't have stream/IncomingMessage | |
// since Buffer is a sub-class of Uint8Array you could use that in nodejs too, if you don't need any of the Buffer specific methods | |
declare module 'axios' { | |
interface AxiosInstance { | |
request(config: AxiosRequestConfig & { responseType: 'arraybuffer' }): Promise<AxiosResponse<Buffer>>; | |
request(config: AxiosRequestConfig & { responseType: 'text' }): Promise<AxiosResponse<string>>; | |
request(config: AxiosRequestConfig & { responseType: 'stream' }): Promise<AxiosResponse<IncomingMessage>>; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default function omit<T, K extends keyof T>(obj: T, ...keys: K[]): Omit<T, K> { | |
const obj2 = { ...obj }; | |
for (const key of keys) { | |
delete obj2[key]; | |
} | |
return obj2; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright 2021 Mathias Panzenböck | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining a copy | |
# of this software and associated documentation files (the "Software"), to deal | |
# in the Software without restriction, including without limitation the rights | |
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
# copies of the Software, and to permit persons to whom the Software is | |
# furnished to do so, subject to the following conditions: | |
# | |
# The above copyright notice and this permission notice shall be included in all |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argparse | |
from typing import List | |
class SmartFormatter(argparse.HelpFormatter): | |
def _split_lines(self, text: str, width: int) -> List[str]: | |
lines: List[str] = [] | |
for line_str in text.split('\n'): | |
line: List[str] = [] | |
line_len = 0 | |
for word in line_str.split(): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PIL import Image | |
import numpy as np | |
import cv2 | |
def pil2cv(image: Image) -> np.ndarray: | |
mode = image.mode | |
new_image: np.ndarray | |
if mode == '1': | |
new_image = np.array(image, dtype=np.uint8) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:(function() { | |
function screenshot(video) { | |
var canvas = document.createElement('canvas'); | |
canvas.width = video.videoWidth; | |
canvas.height = video.videoHeight; | |
context = canvas.getContext('2d'); | |
var now = new Date(); | |
context.drawImage(video, 0, 0, video.videoWidth, video.videoHeight); | |
var url = canvas.toDataURL('image/png'); | |
var link = document.createElement('a'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
"use strict"; | |
function padd(x) { | |
var x = String(x); | |
return x.length < 2 ? '0' + x : x; | |
} | |
var duration = +document.querySelector("video").duration; | |
var playerData = document.querySelector("ytd-watch-flexy").__data.playerData; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/bash | |
input=/dev/stdin | |
output=/dev/stdout | |
slice= | |
palette="/tmp/mkgif-$$-palette.png" | |
fps=15 | |
width= | |
crop= |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:(()=>{var d=document.documentElement,b=document.body,es=b.querySelectorAll("*"),m=20;for(var i=0;i<es.length;++i){var e=es[i];var s=getComputedStyle(e);if(s.position!=='static'&&s.position!=='relative'){var r=e.getBoundingClientRect();if(r.x<=m&&r.y<=m&&r.right>=window.innerWidth - m&&r.bottom>=window.innerHeight - m){e.remove();}}}var s='\n/**/;position:static!important;overflow:auto!important;width:auto!important;height:auto!important;';d.setAttribute('style',(d.getAttribute('style')||'')+ s);b.setAttribute('style',(b.getAttribute('style')||'')+ s);})();void(0) |