This file contains hidden or 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
# Requirements: | |
# pip install pdf2image pytesseract Pillow | |
# | |
import os | |
import glob | |
import sys | |
import pytesseract | |
from pdf2image import convert_from_path | |
from PIL import Image |
This file contains hidden or 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 Foundation | |
// needed for Linux | |
#if canImport(FoundationNetworking) | |
import FoundationNetworking | |
#endif | |
// New async await URLSession extensions are available solely on Apple platform | |
// so this polyfill it's necessary, otherwise the code does not compile on Linux | |
extension URLSession { |
This file contains hidden or 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
#!/bin/bash -e | |
# Re-Encode Mp4 Video Files using H.264 and AAC audio, optimized for streaming | |
# Credits: https://superuser.com/a/1551095 | |
# -c:v libx264 selects the video encoder libx264, which is a H.264 encoder. | |
# -preset slow selects the slow x264 encoding preset. Default preset is medium. Use the slowest preset that you have patience for. | |
# -crf 20 selects a CRF value of 20 which will result in a high quality output. Default value is 23. A lower value is a higher quality. Use the highest value that gives an acceptable quality. | |
# -c:a aac selects the audio encoder aac, which is the built-in FFmpeg AAC encoder. | |
# -b:a 160k encodes the audio with a bitrate of 160k. | |
# -vf format=yuv420p chooses YUV 4:2:0 chroma-subsampling which is recommended for H.264 compatibility. |
This file contains hidden or 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 python3 | |
import os | |
import re | |
import pathlib | |
import ffmpeg | |
import time | |
files = pathlib.Path('.').glob('*.mp4') | |
files = sorted(files, key=lambda x: float(re.findall("(\d+)", os.path.basename(x))[0])) |
This file contains hidden or 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
#!/bin/bash -e | |
# Extract Key Frames from a video and print timestamp on each frame (works with ffmpeg version 5.1.2) | |
# | |
# Credits: | |
# - https://jdhao.github.io/2021/12/25/ffmpeg-extract-key-frame-video/ | |
# - https://superuser.com/questions/575854/can-ffmpeg-extract-images-from-a-video-with-timestamps | |
# | |
# First parameter: input video | |
# Second parameter: output directory | |
# Example ./extract-key-frames myvideo.mp4 outdir/ |
This file contains hidden or 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 Foundation | |
extension Sequence where Element: Hashable { | |
func uniqued() -> [Element] { | |
var set = Set<Element>() | |
return filter { set.insert($0).inserted } | |
} | |
} | |
public extension StringProtocol { |
This file contains hidden or 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
#!/bin/bash -e | |
echo "macOS Helper to configure SSH Key to use with GitHub" | |
echo "based off of instructions reported at:" | |
echo "https://docs.github.com/en/github/authenticating-to-github/adding-a-new-ssh-key-to-your-github-account" | |
echo | |
if [[ "$OSTYPE" != "darwin"* ]]; then | |
echo "This script is designed for macOS only..." | |
echo "exiting" |
This file contains hidden or 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 android.os.SystemClock | |
import android.view.View | |
/** | |
* Implements the "throttle first" mechanism for click listeners, to prevent double taps. | |
* | |
* How it works: | |
* - Define a sampling window time (default: 500ms) | |
* - when you click at time T0, the first click gets dispatched and the subsequent ones happening | |
* between T0 and T0 + WindowTime gets ignored |
This file contains hidden or 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
let jsonDecoder: JSONDecoder = { | |
let decoder = JSONDecoder() | |
decoder.dateDecodingStrategy = .custom { decoder in | |
let container = try decoder.singleValueContainer() | |
let string = try container.decode(String.self) | |
let formatter1 = ISO8601DateFormatter() | |
formatter1.formatOptions = [.withInternetDateTime] | |
let formatter2 = ISO8601DateFormatter() | |
formatter2.formatOptions = [.withInternetDateTime, .withFractionalSeconds] | |
guard let date = formatter1.date(from: string) ?? formatter2.date(from: string) else { |
NewerOlder