Skip to content

Instantly share code, notes, and snippets.

View rakshakhegde's full-sized avatar

Rakshak R.Hegde rakshakhegde

View GitHub Profile
# Python 2.7.10 program
# Author = Rakshak R.Hegde
# Using recursion along with memoization
# to make an efficient solution to print the first 'n' fib sequence
# Recursive relation required => f(n) = f(n-1) + f(n-2) where f(x) is the x'th fibonacci number
# Base values f(1) = f(2) = 1
# Advantages:
@rakshakhegde
rakshakhegde / fragment_utility.kt
Last active January 19, 2023 09:26
Handy Idiom: Pass Arguments to Android Fragment using Kotlin + Anko
import android.support.v4.app.Fragment
import org.jetbrains.anko.bundleOf
/**
* Pass arguments to a Fragment without the hassle of
* creating a static newInstance() method for every Fragment.
*
* Declared outside any class to have full access in any
* part of your package.
*
@rakshakhegde
rakshakhegde / SharedPreferencesUtility.kt
Last active October 30, 2017 17:39
Handy Kotlin Android Utility to store key-value pairs in SharedPreferences
/**
* Handy utility to store key-value pairs in SharedPreferences
* without the hassle of 'apply'
*
* Usage (in Activity/Fragment):
* ```
* defaultSharedPreferences.apply("ACCESS_TOKEN" to "accessToken", "NAME" to "name")
* ```
*
* @param pairs Pairs of key and value to store
@rakshakhegde
rakshakhegde / Android Privacy Policy Template
Created February 17, 2017 09:26 — forked from alphamu/Android Privacy Policy Template
A template for creating your own privacy policy for Android apps. Look for "[" and "<!--" to see where you need to edit this app in order to create your own privacy olicy.
<html>
<body>
<h2>Privacy Policy</h2>
<p>[Individual or Company Name] built the [App Name] app as a [open source | free | freemium | ad-supported | commercial] app. This SERVICE is provided by [Individual or company name] [at no cost] and is intended
for use as is.</p>
<p>This page is used to inform website visitors regarding [my|our] policies with the collection, use, and
disclosure of Personal Information if anyone decided to use [my|our] Service.</p>
<p>If you choose to use [my|our] Service, then you agree to the collection and use of information in
relation with this policy. The Personal Information that [I|we] collect are used for providing and
improving the Service. [I|We] will not use or share your information with anyone except as described
@rakshakhegde
rakshakhegde / Dockerfile
Last active March 7, 2017 06:07
Docker cmds for Android
#
# Building Android project from Command Line from barebones Docker Ubuntu
#
FROM ubuntu:latest
MAINTAINER Rakshak Hegde "rakshakhegde@gmail.com"
RUN apt-get update
#
# Setup Android SDK
import time
from selenium import webdriver
import csv
import urllib.request
driver = webdriver.Chrome()
driver.implicitly_wait(5)
base_url = "https://baseurl/login/"
verificationErrors = []
accept_next_alert = True
@rakshakhegde
rakshakhegde / FusedLocationEnabler.kt
Last active May 30, 2017 07:23
If GPS disabled, show dialog to enable GPS and provide location updates: FusedLocationEnabler using Lifecycle from Arch Components
package me.rakshakhegde.locationapp
import android.app.Activity
import android.arch.lifecycle.Lifecycle
import android.arch.lifecycle.LifecycleObserver
import android.arch.lifecycle.OnLifecycleEvent
import android.content.IntentSender
import android.location.Location
import android.os.Bundle
import android.util.Log
package com.example.android_transition_samples.app;
import android.animation.Animator;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.PropertyValuesHolder;
import android.content.Context;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.View;
@rakshakhegde
rakshakhegde / remixer build.gradle
Last active September 10, 2017 13:01
Remixer snippets
compile 'com.github.material-foundation.material-remixer-android:remixer:1.0'
annotationProcessor 'com.github.material-foundation.material-remixer-android:remixer_annotation:1.0'
// These 2 lines can be done in Application class
RemixerInitialization.initRemixer(getApplication());
Remixer.getInstance().setSynchronizationMechanism(new LocalStorage(getApplicationContext()));
RemixerBinder.bind(this); // pass an Activity instance
final FloatingActionButton remixerButton = findViewById(R.id.remixerButton);
RemixerFragment.newInstance().attachToFab(this, remixerButton);
// or attach to button, swipe up gesture or even a phone shake
// https://github.com/material-foundation/material-remixer-android/blob/develop/docs/CONFIGURE_UI.md