Skip to content

Instantly share code, notes, and snippets.


Marcio Granzotto Rodrigues marciogranzotto

View GitHub Profile
hrules6872 / Base64.kt
Last active May 31, 2021
Base64.kt for Kotlin
View Base64.kt
fun String.encodeBase64ToString(): String = String(this.toByteArray().encodeBase64())
fun String.encodeBase64ToByteArray(): ByteArray = this.toByteArray().encodeBase64()
fun ByteArray.encodeBase64ToString(): String = String(this.encodeBase64())
fun String.decodeBase64(): String = String(this.toByteArray().decodeBase64())
fun String.decodeBase64ToByteArray(): ByteArray = this.toByteArray().decodeBase64()
fun ByteArray.decodeBase64ToString(): String = String(this.decodeBase64())
fun ByteArray.encodeBase64(): ByteArray {
val table = (CharRange('A', 'Z') + CharRange('a', 'z') + CharRange('0', '9') + '+' + '/').toCharArray()
p-fischer /
Last active Oct 26, 2018
Create a fullscreen dialog with margins - either in normal or in immersive mode
package com.exmample.utils;
import android.content.Context;
import android.view.Gravity;
import android.view.Window;
import android.view.WindowManager.LayoutParams;
brunoguerios / KeyboardController.swift
Last active Feb 16, 2017
KeyboardController handles the most common case of UI update required when the keyboard is presented on iOS, which is updating the bottom constraint to match the top of the keyboard frame. Simply create an instance of the KeyboardController in your view controller by providing the view controller itself and it's view bottom constraint as input.
View KeyboardController.swift
// KeyboardController.swift
// Created by Bruno Guerios on 2017-02-13.
import Foundation
import UIKit
class KeyboardController: NSObject {
ZacSweers /
Last active Sep 3, 2018 — forked from cesarferreira/
Party tricks with RxJava, RxAndroid & Retrolambda

View Click

Instead of the verbose setOnClickListener:

RxView.clicks(submitButton).subscribe(o -> log("submit button clicked!"));

Filter even numbers

    .just(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
suau / shareWithoutFacebook
Created Apr 7, 2015
share text to android applications except facebook
View shareWithoutFacebook
public static void shareWithoutFacebook(Context context, String text) {
// get available share intents
List<Intent> targets = new ArrayList<>();
Intent template = new Intent(Intent.ACTION_SEND);
List<ResolveInfo> resolveInfos = context.getPackageManager().
queryIntentActivities(template, 0);
// remove facebook which has a broken share intent
for (ResolveInfo resolveInfo : resolveInfos) {
adamawolf / Apple_mobile_device_types.txt
Last active Sep 27, 2022
List of Apple's mobile device codes types a.k.a. machine ids (e.g. `iPhone1,1`, `Watch1,1`, etc.) and their matching product names
View Apple_mobile_device_types.txt
i386 : iPhone Simulator
x86_64 : iPhone Simulator
arm64 : iPhone Simulator
iPhone1,1 : iPhone
iPhone1,2 : iPhone 3G
iPhone2,1 : iPhone 3GS
iPhone3,1 : iPhone 4
iPhone3,2 : iPhone 4 GSM Rev A
iPhone3,3 : iPhone 4 CDMA
iPhone4,1 : iPhone 4S