Skip to content

Instantly share code, notes, and snippets.

View fnk0's full-sized avatar

Marcus Gabilheri fnk0

  • Snap
  • Los Angeles, CA
View GitHub Profile
@fnk0
fnk0 / VideoDownloader.java
Last active March 13, 2024 08:48
Example of how to download a video using Okhttp and show a progress bar to the user
class VideoDownloader extends AsyncTask<Void, Long, Boolean> {
@Override
protected void onPreExecute() {
super.onPreExecute();
}
@Override
protected Boolean doInBackground(Void... params) {
{
"meta": { "theme": "onepage" },
"basics": {
"name": "Marcus Gabilheri",
"label": "Senior Android Software Engineer",
"picture": "",
"email": "marcusandreog@gmail.com",
"phone": "+1(405)385-1224",
"website": "",
"summary": "Hi, I'm Marcus and I have fun writing code.",
@fnk0
fnk0 / Hex Color Values - Alpha
Created February 22, 2016 21:58
Hex values for transparency in hex values
100% — FF
95% — F2
90% — E6
85% — D9
80% — CC
75% — BF
70% — B3
65% — A6
60% — 99
55% — 8C
@fnk0
fnk0 / Framework.kt
Created January 14, 2020 19:15
Parent View Model with Contract Interface
import androidx.annotation.MainThread
import androidx.fragment.app.Fragment
import kotlin.reflect.KClass
interface ViewModelContractProvider {
fun <T : Any> provideViewModelContract(clazz: KClass<T>): T
val supportedContracts: Set<KClass<*>>
}
/**
@fnk0
fnk0 / Framework.kt
Created January 14, 2020 19:15
Parent View Model with Contract Interface
import androidx.annotation.MainThread
import androidx.fragment.app.Fragment
import kotlin.reflect.KClass
interface ViewModelContractProvider {
fun <T : Any> provideViewModelContract(clazz: KClass<T>): T
val supportedContracts: Set<KClass<*>>
}
/**
@fnk0
fnk0 / PostFixCalc.java
Created October 28, 2014 02:42
RPN Calculator Java
import java.util.*;
public class PostfixCalc {
// Commands
private static final String QUIT = "quit";
private static final String VAR = "var";
private static final String CLEAR = "clear";
private static ArrayList<String> variableNames = new ArrayList<String>();
@fnk0
fnk0 / CardType.java
Created March 25, 2018 06:14 — forked from gabrielbauman/CardType.java
A Java enum representing credit card types (Visa, Mastercard etc) that can detect card type from a credit card number.
package com.gabrielbauman.gist;
import java.util.regex.Pattern;
public enum CardType {
UNKNOWN,
VISA("^4[0-9]{12}(?:[0-9]{3}){0,2}$"),
MASTERCARD("^(?:5[1-5]|2(?!2([01]|20)|7(2[1-9]|3))[2-7])\\d{14}$"),
AMERICAN_EXPRESS("^3[47][0-9]{13}$"),
@fnk0
fnk0 / PaletteUtils.java
Created October 16, 2016 21:15
Helper class to extract the necessary palette colors from the generate palette
public class PaletteUtils {
public static PaletteColors getPaletteColors(Palette palette) {
PaletteColors colors = new PaletteColors();
//figuring out toolbar palette color in order of preference
if (palette.getDarkVibrantSwatch() != null) {
colors.setToolbarBackgroundColor(palette.getDarkVibrantSwatch().getRgb());
colors.setTextColor(palette.getDarkVibrantSwatch().getBodyTextColor());
colors.setTitleColor(palette.getDarkVibrantSwatch().getTitleTextColor());
@fnk0
fnk0 / UIIMageExtension.swift
Created October 13, 2015 03:32
Simple UIImage Extension to allow a image to scale and rotate based on Orientantion
import Foundation
import UIKit
extension UIImage {
func scaleAndRotateImage(maxSize: CGFloat) -> UIImage {
let imgRef = self.CGImage
let width = CGFloat(CGImageGetWidth(imgRef))
import android.support.annotation.IntRange;
import android.support.annotation.LayoutRes;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import java.util.ArrayList;
import java.util.List;