Skip to content

Instantly share code, notes, and snippets.

View pedrox-hs's full-sized avatar

Pedro Silva pedrox-hs

View GitHub Profile
#!/bin/bash
set -xeo pipefail
# https://trac.ffmpeg.org/wiki/Scaling
# https://askubuntu.com/questions/506670/how-to-do-i-convert-an-webm-video-to-a-animated-gif-on-the-command-line
# https://superuser.com/questions/1049606/reduce-generated-gif-size-using-ffmpeg
# https://superuser.com/a/1107201
@pedrox-hs
pedrox-hs / settings.json
Created October 12, 2022 22:34
My VS Code configs
{
"workbench.colorTheme": "Darcula Theme from IntelliJ",
"files.autoSave": "afterDelay",
"editor.minimap.enabled": false,
"editor.renderWhitespace": "all",
"editor.codeActionsOnSave": {
"source.fixAll": true,
"source.organizeImports": true
},
"xmlTools.splitAttributesOnFormat": true,
@pedrox-hs
pedrox-hs / Makefile
Last active September 18, 2025 21:50
My Makefiles
# https://stackoverflow.com/a/36226832
SHELL := env PATH="$(PATH):$(PWD)/bin" /bin/bash
# Define environment variables
ENV_FILES := $(wildcard .env.default .env)
ifneq ($(ENV_FILES),)
include $(ENV_FILES)
export $(shell grep -he '^[^\#;]' $(ENV_FILES) | sed 's/=.*//' | sort | uniq)
endif
main() {
check_args
resize_android
resize_ios
}
resize_android() {
if [[ -z "$ANDROID_FILE_NAME" ]]; then
return
fi
@pedrox-hs
pedrox-hs / Activity.kt
Last active September 21, 2020 21:10
Kotlin Extensions for Android
import android.app.Activity
fun <T> Activity.argument(key: String, default: T? = null) =
argument(key) { default }
fun <T> Activity.argument(key: String, default: () -> T? = { null }) = lazy {
intent.extras?.getValueOrDefault(key, default)
}
@pedrox-hs
pedrox-hs / unzip.sh
Created May 7, 2020 07:10
Unzip remote file.zip (can be used to checkout GIST)
wget -qO- https://url.to/file.zip | jar xvf /dev/stdin
@pedrox-hs
pedrox-hs / jobs
Last active May 7, 2020 07:12
Background jobs
$ ^Z # (CTRL+Z) stop job
$ bg # continue job in background
$ jobs # show all running jobs
$ disown -h %1 # keep job #1 running when exit terminal
$ disown -a # keep all jobs running when exit terminal
@pedrox-hs
pedrox-hs / BaseActivity.kt
Created July 24, 2019 15:30
Change Android App Locale at runtime
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.os.Build
import android.annotation.TargetApi
import android.content.Context
import java.util.*
class BaseActivity : AppCompatActivity() {
@pedrox-hs
pedrox-hs / Date.kt
Created July 24, 2019 15:02
Elapsed time Kotlin extension
import android.content.Context
import java.util.*
fun Date.formatElapsedTime(context: Context, to: Calendar) =
when (val elapsedDays = elapsedDays(to)) {
0 -> {
val elapsedHours = elapsedHours(to)
val elapsedMinutes = elapsedMinutes(to)
when {
@pedrox-hs
pedrox-hs / i3-config
Last active December 8, 2018 20:48
I3 configuration
# This file has been auto-generated by i3-config-wizard(1).
# It will not be overwritten, so edit it as you like.
#
# Should you change your keyboard layout some time, delete
# this file and re-run i3-config-wizard(1).
#
# i3 config file (v4)
#
# Please see https://i3wm.org/docs/userguide.html for a complete reference!