Skip to content

Instantly share code, notes, and snippets.

View marciogranzotto's full-sized avatar

Marcio Granzotto Rodrigues marciogranzotto

View GitHub Profile
@hrules6872
hrules6872 / Base64.kt
Last active May 31, 2021 12:41
Base64.kt for Kotlin
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
p-fischer / DialogUtils.java
Last active October 26, 2018 08:58
Create a fullscreen dialog with margins - either in normal or in immersive mode
package com.exmample.utils;
import android.app.Dialog;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.view.Gravity;
import android.view.Window;
import android.view.WindowManager.LayoutParams;
@brunoguerios
brunoguerios / KeyboardController.swift
Last active February 16, 2017 17:30
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.
//
// KeyboardController.swift
//
// Created by Bruno Guerios on 2017-02-13.
//
import Foundation
import UIKit
class KeyboardController: NSObject {
@ZacSweers
ZacSweers / RxJava.md
Last active September 3, 2018 18:52 — forked from cesarferreira/RxJava.md
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

Observable
    .just(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
@suau
suau / shareWithoutFacebook
Created April 7, 2015 11:04
share text to android applications except facebook
public static void shareWithoutFacebook(Context context, String text) {
// get available share intents
List<Intent> targets = new ArrayList<>();
Intent template = new Intent(Intent.ACTION_SEND);
template.setType("text/plain");
List<ResolveInfo> resolveInfos = context.getPackageManager().
queryIntentActivities(template, 0);
// remove facebook which has a broken share intent
for (ResolveInfo resolveInfo : resolveInfos) {
@adamawolf
adamawolf / Apple_mobile_device_types.txt
Last active November 14, 2024 18:34
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
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