Skip to content

Instantly share code, notes, and snippets.

View hamen's full-sized avatar

Ivan Morgillo hamen

View GitHub Profile
// ==UserScript==
// @name Telegram - Jump to first unread message
// @namespace https://ivanmorgillo.com/
// @version 0.1
// @description Kinda Slack shortcut
// @author Ivan Morgillo
// @match https://web.telegram.org/*
// @grant none
// ==/UserScript==
@Target(AnnotationTarget.CLASS)
@Retention(AnnotationRetention.SOURCE)
/**
* Friendly reminder that this might not be the best place to do major changes. Or any changes at all.
* Use the [reason] arg to point your teammates and your future-self to some documentation.
*/
annotation class HereBeDragons(val reason: String)
@hamen
hamen / UriExts.kt
Last active October 14, 2021 13:21
A couple of extensions on String and File to safely convert toUri()
import android.net.Uri
import java.io.File
/**
* Tries to convert a [String] to a [Uri].
* Differently from the "I'm 5 years old" implementation that comes with Android
* that throws a temper tantrum, i.e. exception, if the conversion fails,
* this implementation returns a [null], like an adult would do.
*/
@Suppress("SwallowedException", "TooGenericExceptionCaught")