Skip to content

Instantly share code, notes, and snippets.

View mmazzarolo's full-sized avatar
🐌
Busy — I'll be slow to respond!

Matteo Mazzarolo mmazzarolo

🐌
Busy — I'll be slow to respond!
View GitHub Profile
@mmazzarolo
mmazzarolo / watch.js
Created October 19, 2019 21:24
Develop a browser extension with live-reloading using Create React App without ejecting
#!/usr/bin/env node
// A script for developing a browser extension with live-reloading
// using Create React App (no need to eject).
// Run it instead of the "start" script of your app for a nice
// development environment.
// P.S.: Install webpack-extension-reloader before running it.
// Force a "development" environment in watch mode
process.env.BABEL_ENV = "development";
@mmazzarolo
mmazzarolo / charles-command-line-options.md
Last active June 7, 2024 09:55
Charles Proxy Automation

Charles command-line options

Charles supports a few command line options out of the box, documented here.
Unfortunately they seem to operate only as parameters for new Charles sessions, so you won't be able to run commands on a running instance of Charles.

Start a specific Charles session

A Charles session contains all of your recorded information. It is represented by the Session window; by default a new session is automatically created when you start Charles.
Sessions can be saved from File → Save Session (+S).
Once saved, if you want you can start Charles from the saved session by running:

@mmazzarolo
mmazzarolo / useKeyboardPress.ts
Created December 30, 2018 22:09
A React hook for handling keypresses
import { useState, useEffect, useRef } from "react";
interface Parameters {
key: string;
ctrlKey?: boolean;
shiftKey?: boolean;
metaKey?: boolean;
onKeyDown?: (e: KeyboardEvent) => void;
onKeyUp?: (e: KeyboardEvent) => void;
}
@mmazzarolo
mmazzarolo / run-scrcpy.sh
Created December 18, 2018 10:57
Run scrcpy
if pgrep scrcpy; then
osascript -e 'tell application "System Events" to tell process "scrcpy"' \
-e 'set frontmost to true' \
-e 'if windows is not {} then perform action "AXRaise" of item 1 of windows' \
-e 'end tell'
else
/usr/local/bin/scrcpy
fi
@mmazzarolo
mmazzarolo / MainActivity.java
Created December 13, 2018 20:49
Fresco/Picasso comparison on images with a dimension > 2048px
package com.example.matteomazzarolo.imagetest;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
@mmazzarolo
mmazzarolo / big-images-in-android-rn.js
Created December 1, 2018 13:59
Image decoding limit workaround for RN (Android)
export default class CroppedImage extends Component {
state = {
croppedImageSources: []
};
async componentDidMount() {
const crops = 4;
const croppedImageHeight = imHeight / crops;
const croppedImageSources = [];
for (let i = 0; i <= crops; i++) {
@mmazzarolo
mmazzarolo / MyTextInput.tsx
Last active January 20, 2023 10:21
A simple wrapper on the React Native TextInput that fixes its ugly default Android style
import * as React from "react";
import {
NativeSyntheticEvent,
StyleSheet,
TextInput,
TextInputFocusEventData,
TextInputProps
} from "react-native";
interface State {
@mmazzarolo
mmazzarolo / MyTextInput.js
Last active June 15, 2021 11:57
A simple wrapper on the React Native TextInput that fixes its ugly default Android style
import * as React from "react";
import { StyleSheet, TextInput } from "react-native";
const BLUE = "#428AF8";
const LIGHT_GRAY = "#D3D3D3";
class MyTextInput extends React.Component {
state = {
isFocused: false
};
@mmazzarolo
mmazzarolo / App.tsx
Created September 28, 2018 09:25
src/screens/LoginScreen.tsx
import * as React from "react";
import { StyleSheet, Text, View } from "react-native";
class LoginScreen extends React.Component<{}> {
render() {
return (
<View style={styles.container}>
<Text>Welcome to the login screen!</Text>
</View>
);
@mmazzarolo
mmazzarolo / dev.sh
Created June 28, 2018 16:36
React-Native development script
#!/bin/bash
# Starts the metro bundler and runs react-native in a single terminal (à la Expo).
# CTRL + C kills the metro bundler.
# Arguments:
# -p Development platform [ios (default), android].
# -s Starts scrcpy too. Android only. (https://github.com/Genymobile/scrcpy)
COLOR_RED='\033[0;31m'
COLOR_CYAN='\033[0;36m'
COLOR_PURPLE='\033[0;35m'