Skip to content

Instantly share code, notes, and snippets.

I may be slow to respond.

Lucio Paiva luciopaiva

I may be slow to respond.
View GitHub Profile
luciopaiva / async-experiments.js
Created Jun 10, 2018
Async Javascript experiments
View async-experiments.js
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
* Shows how a timer fails to execute when we block the main thread. See `setIntervalDoesNotWorkWithBlockingWait()` for
* a solution to this.
* @returns {void}
luciopaiva / walksync.js
Last active Oct 29, 2020 — forked from kethinov/walksync.js
List all files in a directory in Node.js recursively in a synchronous fashion
View walksync.js
#!/usr/bin/env node
path = require("path"),
fs = require("fs");
* List all files in a directory recursively in a synchronous fashion
* @param {String} dir
View file-drop-zone.js
class FileDropZone {
* @param {HTMLElement|String} dropZoneElement
constructor (dropZoneElement) {
dropZoneElement = typeof dropZoneElement === "string" ? document.getElementById(dropZoneElement) : dropZoneElement;
dropZoneElement.addEventListener("drop", this.onDrop.bind(this));
dropZoneElement.addEventListener("dragover", event => event.preventDefault());
luciopaiva /
Created Oct 10, 2018
Inspecting changes between commits in git

List files touched:

git diff --stat commit-1 commit-2

List change counts:

git diff --shortstat commit-1 commit-2 | cat

List authors between two commits:

luciopaiva /
Last active May 14, 2022
Android APK hacking how-to

Android APK hacking how-to

Install and configure SDK

  • install Android Studio (google it)

  • configure your shell (considering Linux+Bash):

    export ANDROID_HOME=$HOME/Android/Sdk
    export PATH=$PATH:$ANDROID_HOME/tools

export PATH=$PATH:$ANDROID_HOME/platform-tools

luciopaiva /
Last active Apr 8, 2022
Android APK HTTPS user certificates how-to

Android APK HTTPS user certificates how-to

Starting with Android Nougat, Google changed the way apps handle user certificates:

Apps that target API Level 24 and above no longer trust user or admin-added CAs for secure connections, by default.

This means that certificates issued by applications like [Charles][charles] or [mitmproxy][mitmproxy] are no longer accepted, so these proxies won't work for HTTPS traffic.

This tutorial explains what needs to be done to overcome that restriction and be able to sniff any Android app's HTTPS requests.

View witchcraft-include-directive-example.js
// @include my-script.js
// @include "some other script.js"
/* @include third-script.js */
setup(); // `setup` is defined in `my-script.js`

Plex Media Server on Ubuntu

Install it by following the instructions on the web site.

Troubleshooting Plex not seeing media files

Make sure your directories and files have the right permissions:

find . -type f -exec chmod 644 {} ; find . -type d -exec chmod 755 {} ;


Using HTML templates in Javascript

This is the proper way to have HTML templates and clone them in Javascript.

First add the template to your HTML:

<template id="example-template">

Things I learned while playing with Cordova

  • use Webstorm to develop your app
  • deploy via Webstorm (it has a Cordova configuration template)
  • try your app in Chrome by clicking the Chrome button in Webstorm
  • configure JetBrains IDE plugin in Chrome to allow for cross-origin requests
  • your Android app will complain about cross-origin requests as well
  • you can debug your deployed Android app via Chrome through chrome://inspect
  • if you're previewing your page in Chrome, you may need to disable web security in order to use fetch() pointing to other domains. See this