Skip to content

Instantly share code, notes, and snippets.

View yeradis's full-sized avatar

Yeradis P. Barbosa Marrero yeradis

View GitHub Profile
@felipecsl
felipecsl / retryIfThrown.kt
Last active April 27, 2023 00:02
Kotlin utility to retry a provided block a limited number of times
/**
* Retries the provided [block] up to [times] times if the block throws an exception of the type
* [exceptionType]. If any other exception type is thrown, the exception is caught and then
* immediately rethrown.
*/
fun retryIfThrown(times: Int, exceptionType: KClass<out Throwable>, block: () -> Unit) {
for (i in 0 until times) {
try {
block()
break

With GitHub Actions, a workflow can publish artifacts, typically logs or binaries. As of early 2020, the life time of an artifact is hard-coded to 90 days (this may change in the future). After 90 days, an artifact is automatically deleted. But, in the meantime, artifacts for a repository may accumulate and generate mega-bytes or even giga-bytes of data files.

It is unclear if there is a size limit for the total accumulated size of artifacts for a public repository. But GitHub cannot reasonably let multi-giga-bytes of artifacts data accumulate without doing anything. So, if your workflows regularly produce large artifacts (such as "nightly build" procedures for instance), it is wise to cleanup and delete older artifacts without waiting for the 90 days limit.

Using the Web page for the "Actions" of a repository, it is possible to browse old workflow runs and manually delete artifacts. But the procedure is slow and tedious. It is fine to delete one selected artifact. It is not for a regular cleanup. We need

@ereli
ereli / hello.go
Last active February 20, 2025 21:54
How to sign macOS and Windows executables using self-signed certificates on a Mac.
package main
import "fmt"
func main() {
fmt.Println("hello world")
}
@goliatone
goliatone / README.md
Last active February 1, 2025 14:55 — forked from colophonemes/create_triggers
Postgres TRIGGER to call NOTIFY with a JSON payload

This TRIGGER function calls PosgreSQL's NOTIFY command with a JSON payload. You can listen for these calls and then send the JSON payload to a message queue (like AMQP/RabbitMQ) or trigger other actions.

Create the trigger with notify_trigger.sql.

When declaring the trigger, supply the column names you want the JSON payload to contain as arguments to the function (see create_triggers.sql)

The payload returns a JSON object:

@mrk-han
mrk-han / change-accessibility-settings-with-adb.md
Last active April 17, 2025 14:22
Enable and Disable Android Accessibility Settings from the Command Line using ADB (Font scale, talkback, color blind)

Using ADB to control Accessbility settings for easier testing with Android Emulators + Real Devices

It's a lot easier to test accessibility on the fly using ADB. This gist attempts to make the days of navigating through the Android device settings UI to change Accessibility settings obsolete.

These ADB commands will hopefully encourage Android developers to test and use their apps with common Accessiblility settings enabled.

Credit to James Nitsch for inspiring this, and for figuring out the put commands to enable these settings.

Font Scale (Font Size -- Testing Dynamic Text)

@drewchapin
drewchapin / update-google-dyndns.sh
Last active April 13, 2024 04:06
A shell script to update the public IP address of a Google DynDNS hostname. Intended to be used on DD-WRT routers.
#!/bin/sh
HOSTNAME="host.yourdomain.com"
USERNAME="username"
PASSWORD="password"
LOG_FILE="/tmp/ddns/ddns.log"
while true; do
@fabiogiolito
fabiogiolito / Layout.swift
Created November 28, 2018 15:06
Swift Layout Extension
import UIKit
extension UIView {
// ----------------------------------------------------------------------
// Make it cleaner to add all your elements as subviews in a single line.
// Example:
// view.addSubviews([coverImage, titleLabel, followButton, …])
func addSubviews(_ views: [UIView]) {
@msievers
msievers / [Spring, JMH] Howto integrate JMH benchmarks with Spring.md
Last active February 24, 2025 04:23
[Spring, JMH] Howto integrate JMH benchmarks with Spring

Motivation

Integrate JMH (Java Microbenchmarking Harness) with Spring (Boot) and make developing and running benchmarks as easy and convinent as writing tests.

Idea

Wrap the necessary JMH boilerplate code within JUnit to benefit from all the existing test infrastructure Spring (Boot) provides. It should be as easy and convinent to write benchmarks as it is to write tests.

TL;DR;

@nicklockwood
nicklockwood / main.swift
Created December 1, 2017 11:04
Thread-safe cache implementation benchmark
var cache = [Int: Int]()
let queue = DispatchQueue(label: "cacheQueue", attributes: .concurrent)
let iterations = 100000
// In the first run, cache is empty so we're writing each time
do {
let start = CFAbsoluteTimeGetCurrent()
for i in 0 ... iterations {
var exists = false
queue.sync {