Skip to content

Instantly share code, notes, and snippets.

View pladaria's full-sized avatar
👾

Pedro Ladaria pladaria

👾
View GitHub Profile
@pladaria
pladaria / use-is-virtual-keyboard-open.ts
Last active April 29, 2024 18:12
Detect if Virtual Keyboard is open in web app using React
const useIsVirtualKeyboardVisible = () => {
const [isVirtualKeyboardVisible, setIsVirtualKeyboardVisible] = React.useState(false);
React.useEffect(() => {
// probably incomplete, good enough for me
const inputTypesThatOpenTheVirtualKeyboard = ['text', 'email', 'password', 'number', 'search'];
const handleFocus = (event: Event) => {
if (
event.target instanceof HTMLTextAreaElement ||
@pladaria
pladaria / tesseract-tsv-to-json.js
Created April 8, 2023 11:33
Tesseract OCR tsv to json converter
const tesseractTsvToJson = (tsvFilename, jsonFilename) => {
console.log(`> tsvToJson ${tsvFilename} => ${jsonFilename}`);
const tsvLines = fs.readFileSync(tsvFilename, 'utf-8').trim().split('\n').reverse();
/** @type {any} */
const json = {pages: []};
// discard header
tsvLines.pop();
@pladaria
pladaria / vitashell-usb-mount-linux.md
Last active January 19, 2023 11:28
How to mount PSVita in linux using VitaShell and a USB cable
  • Linux Mint 20.2 x86_64
  • Kernel 5.4.0-135-generic

Remove exfat-fuse and exfat-utils packages

sudo apt-get remove exfat-fuse exfat-utils

Install exfat-linux.

@pladaria
pladaria / bo-mx4000-sw2.0-notes.md
Last active January 23, 2022 16:02
Bang & Olufsen MX4000 SW 2.0 Notes
@pladaria
pladaria / clean-up-boot-partition-ubuntu.md
Created December 20, 2019 09:45 — forked from ipbastola/clean-up-boot-partition-ubuntu.md
Safest way to clean up boot partition - Ubuntu 14.04LTS-x64, Ubuntu 16.04LTS-x64

Safest way to clean up boot partition - Ubuntu 14.04LTS-x64, Ubuntu 16.04LTS-x64

Reference

Case I: if /boot is not 100% full and apt is working

1. Check the current kernel version

$ uname -r 
@pladaria
pladaria / Logitec-z960-IR-codes.md
Created December 12, 2019 11:35
Logitech Speaker System Z906 remote IR codes
@pladaria
pladaria / fundacion-lectura.md
Last active January 30, 2020 05:52
Saga de la Fundación - Orden de lectura

Saga de la Fundación

Serie de los Robots

  • 1950 Yo, Robot
  • 1954 Bóvedas de Acero
  • 1957 El Sol Desnudo
  • 1983 Los Robots del Amanecer
  • 1985 Robots e Imperio
@pladaria
pladaria / index.js
Created January 30, 2019 09:47
generate-vapid-keys created by pladaria - https://repl.it/@pladaria/generate-vapid-keys
const crypto = require('crypto');
const urlBase64 = require('urlsafe-base64');
function generateVAPIDKeys() {
const curve = crypto.createECDH('prime256v1');
curve.generateKeys();
return {
publicKey: urlBase64.encode(curve.getPublicKey()),
privateKey: urlBase64.encode(curve.getPrivateKey())
@pladaria
pladaria / sentry-webpack-plugin.js
Created November 24, 2017 10:53
Sentry artifacts upload plugin for webpack
/*
* Original file:
* https://github.com/40thieves/webpack-sentry-plugin/blob/master/src/index.js
*/
const request = require('request-promise');
const fs = require('fs');
const crypto = require('crypto');
const {green, yellow, red} = require('colors/safe');
const Queue = require('promise-queue');
@pladaria
pladaria / index.js
Last active April 22, 2017 10:54
requirebin sketch
const RWS = require('reconnecting-websocket');
const rws1 = new RWS('wss://echo.websocket.org');
const rws2 = new RWS('wss://echo.websocket.org', undefined);
rws1.onopen = () => console.log('ws1 connected');
rws2.onopen = () => console.log('ws2 connected');