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 / elevations.ts
Last active June 1, 2022 15:12
React-Native cross platform elevation definitions
/**
* React-Native cross-platform elevations.
* Based on https://ethercreative.github.io/react-native-shadow-generator/
*
* Usage:
* 1. Import "elevations" from this file
* import { elevations } from "config/elevations";
* 2. Use it. Assuming you need an elevation of 2 (based on the Android
* elevation standard), doing the following will cast the same shadow
* on both platforms:
@mmazzarolo
mmazzarolo / colors.ts
Created December 1, 2019 10:04
Ordinary Puzzles grayscale palette
import tinycolor from "tinycolor2";
import { useColorScheme } from "react-native-appearance";
const primaryColor = "#171520";
const palette = new Array(10).fill(primaryColor).map((color, index) =>
tinycolor(color)
.brighten(index * 10)
.toString()
);
@mmazzarolo
mmazzarolo / SkippableSplash.tsx
Created December 7, 2019 18:56
Skipping the splash screen in Ordinary Puzzles
import React, { FC, useRef } from "react";
import { StyleSheet, Animated, TouchableWithoutFeedback } from "react-native";
import { Text } from "pg-common";
import { useAnimation, useOnMount, scale, delay } from "pg-utils";
import { animations, metrics, colors } from "pg-design";
import { credits } from "pg-config";
const asyncAnimationStart = (anim: Animated.CompositeAnimation) =>
new Promise(resolve => anim.start(resolve));
@mmazzarolo
mmazzarolo / scale.ts
Last active December 23, 2019 14:51
React-Native metrics scaling
import { PixelRatio, Dimensions } from "react-native";
const isTabletLike = () => {
const pixelDensity = PixelRatio.get();
const adjustedWidth = Dimensions.get("screen").width * pixelDensity;
const adjustedHeight = Dimensions.get("screen").height * pixelDensity;
return (
(pixelDensity < 2 && (adjustedWidth >= 1000 || adjustedHeight >= 1000)) ||
(pixelDensity === 2 && (adjustedWidth >= 1920 || adjustedHeight >= 1920))
);
@mmazzarolo
mmazzarolo / disable-people-also-search-for-google.md
Last active January 20, 2025 01:39
Disabling "People also search for" box in Google search results
@mmazzarolo
mmazzarolo / ffmpeg_resize.sh
Created September 6, 2020 13:05
Resize videos keeping the aspect ratio (shows black bar padding where needed)
#!/bin/bash
input="input.mp4"
output="output.mp4"
color="black"
while getopts ":i:o:w:h:c:" opt; do
case $opt in
i) input="$OPTARG"
;;
@mmazzarolo
mmazzarolo / service-workers.md
Last active April 22, 2024 03:40
Service Workers Tips

Service Workers Tips

Reloading a service worker

Reloading a page won't update/remove the previous version of its service worker. To make sure you're using the latest version of your service worker, make sure to check the "Update on reload" toggle in the "Application" ⭢ "Service Workers" section of the Chrome DevTools.

Simulate a network condition

To simulate a network condition (e.g.: offline, 3g, etc...) in a service worker on Chrome, uncheck the "Update on reload" toggle.

@mmazzarolo
mmazzarolo / bump-npm-dep.ts
Last active June 26, 2021 14:52
Bump the version number of an NPM dependency and commits the changes in a new branch
// Just a Deno script that bumps an NPM dependency of the project
// in the current directory.
// Might be helpful if you need to automate the bumping of a
// dependency across multiple repos.
// It:
// - Makes sure you start from a clean state
// - Auto-detects if using yarn or npm
// - Creates, commits, and pushes the changes in a separate branch
import * as Colors from "https://deno.land/std/fmt/colors.ts";
import yargs from "https://deno.land/x/yargs/deno.ts";
@mmazzarolo
mmazzarolo / test.html
Last active October 8, 2021 08:34
Is Chrome enable stylesheets asynchronously?
<html>
<body>
<link
rel="stylesheet"
href="https://unpkg.com/[email protected]/build/pure-min.css"
integrity="sha384-Uu6IeWbM+gzNVXJcM9XV3SohHtmWE+3VGi496jvgX1jyvDTXfdK+rfZc8C1Aehk5"
crossorigin="anonymous"
id="purecss"
/>
<p>Hello world</p>
@mmazzarolo
mmazzarolo / quick-reminder.ts
Last active November 26, 2021 17:31
Deno script to create a reminder from CLI (in Apple's Reminders app)
// Deno CLI script to add reminders to Apple's Reminders app parsing the
// due date with natural language.
// Requires reminders-cli (https://github.com/keith/reminders-cli) to be
// installed in order to run. Uses reminders-cli instead of Applescript/JXA
// because reminders-cli is much faster.
// Uses chrono-node (https://github.com/wanasit/chrono) to parse the date (which
// in my opinion works better than reminders-cli natural lanaguage parser).
//
// Example usage:
// ```