Skip to content

Instantly share code, notes, and snippets.

View luciopaiva's full-sized avatar
🐌
I may be slow to respond

Lucio Paiva luciopaiva

🐌
I may be slow to respond
View GitHub Profile
@luciopaiva
luciopaiva / async-experiments.js
Created June 10, 2018 00:02
Async Javascript experiments
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
luciopaiva / walksync.js
Last active October 29, 2020 20:24 — forked from kethinov/walksync.js
List all files in a directory in Node.js recursively in a synchronous fashion
#!/usr/bin/env node
const
path = require("path"),
fs = require("fs");
/**
* List all files in a directory recursively in a synchronous fashion
*
* @param {String} dir
@luciopaiva
luciopaiva / file-drop-zone.js
Last active September 7, 2018 00:30
File drop zone
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
luciopaiva / changes-between-commits.md
Created October 10, 2018 16:14
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
luciopaiva / android-apk-hacking-how-to.md
Last active April 18, 2024 07:46
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
luciopaiva / android-apk-user-certificates.md
Last active April 18, 2024 07:46
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.

// @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">
    <div class="example">

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