This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import parsePhoneNumber from "libphonenumber-js"; | |
/** | |
* The available formatting properties for formatting a phone number. | |
*/ | |
type FormatPhoneNumberProperty = "NATIONAL" | "INTERNATIONAL" | "RFC3966"; | |
/** | |
* Represents the arguments for formatting a phone number. | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Represents the arguments for formatting a currency display name with internationalization. | |
*/ | |
export interface I18nFormatDisplayNamesArgs { | |
/** | |
* The locale to use for formatting the display name. Defaults to "en-US". | |
*/ | |
locale?: keyof typeof Intl.Locale; | |
/** | |
* The currency code for which to retrieve the display name. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Represents the arguments for formatting a date with internationalization. | |
*/ | |
export interface I18nFormatDateArgs { | |
/** | |
* The locale to use for formatting the date. Defaults to "en-US". | |
*/ | |
locale?: keyof typeof Intl.Locale; | |
/** | |
* The string representation of the date to be formatted. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const getObjectFitData = (obj, container, cover=true) => { | |
let result = {}; | |
const ratioX = container.width / obj.width; | |
const ratioY = container.height / obj.height; | |
const ratioFit = cover ? Math.max(ratioX, ratioY) : Math.min(ratioX, ratioY); | |
result.ratio = Math.ceil(ratioFit * 100) / 100; | |
result.width = Math.ceil(obj.width * result.ratio); | |
result.height = Math.ceil(obj.height * result.ratio); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Creates a poster from a given mp4 frame. | |
# 1. Get FFmpeg (https://evermeet.cx/ffmpeg/) and install it | |
# 2. Place this script within your mp4 folder | |
# 3. Make it executable: chmod +x path/to/poster.command | |
# 4. Execute it by doubleclicking this file | |
dir=$(dirname $(realpath -s $0)) | |
echo "Enter filename without extension (i.e. my-awesome-video)." | |
read name | |
echo "Enter timestamp (HH:MM:SS.MM) of frame to create poster from." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { execSync } = require('child_process') | |
const { createHash } = require('crypto') | |
const invertColor = require('invert-color') | |
const fs = require('fs') | |
const path = require('path') | |
/** | |
* Returns numeronym string | |
* @param str | |
* @returns {*} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
shopt -s nullglob nocaseglob extglob | |
for file in src/assets/videos/*.mp4; do | |
name="${file%%.*}" | |
if [ -f "$name-1280x720-1500k.webm" ]; then | |
echo "$name-1280x720-1500k.webm exists" | |
else | |
ffmpeg \ | |
-i "$file" -vn -acodec libvorbis -ab 128k -dash 1 "$name-audio.webm" && \ | |
ffmpeg \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
quality=80 | |
shopt -s nullglob nocaseglob extglob | |
for file in src/assets/img/**/*.@(jpg|jpeg|png); do | |
if [ -f "${file%.*}.webp" ]; then | |
echo "${file%.*}.webp exists" | |
else | |
cwebp -q $quality "$file" -o "${file%.*}.webp" | |
fi | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ffmpeg -i source.mp4 -vcodec h264 -b:v 1000k -acodec mp3 target.mp4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ffmpeg -i source.mp4 -c:v libtheora -q:v 7 -c:a libvorbis -q:a 4 target.ogv |