Skip to content

Instantly share code, notes, and snippets.

View gandharva's full-sized avatar
🧑‍💻
building measure.sh

gandharva kumar gandharva

🧑‍💻
building measure.sh
View GitHub Profile
@gandharva
gandharva / Authentication.java
Last active June 22, 2016 15:59
This demo shows a scenario where a secured resource is being accessed and the token has expired. The authenticator of the rest client detects the scenario, gets the new access token using refresh token and continues with the call
package io.leftshift.app.model;
import com.activeandroid.Model;
import com.activeandroid.annotation.Column;
import com.activeandroid.annotation.Table;
import com.activeandroid.query.Delete;
import com.activeandroid.query.Select;
@Table(name = "Authentication")
public class Authentication extends Model {
retrofitService.getAccessToken()
/* AuthenticationResponse is the return type of retrofitService.getAccessToken()
* Observable<ResponseBody> is the return type of retrofitService.getRecords(), I'm using retrofit response body here
*/
.flatMap(new Func1<AuthenticationResponse, Observable<ResponseBody>>() {
@Override
public Observable<ResponseBody> call(AuthenticationResponse authenticationResponse) {
String accessToken = authenticationResponse.getData().getAccessToken();
String refreshToken = authenticationResponse.getData().getRefreshToken();
Authentication.saveDetails(accessToken, refreshToken);
@gandharva
gandharva / TrackNPullAllBranches.sh
Created December 17, 2015 06:15
Script to track, fetch and pull all remote branches
#!/bin/bash
//Get all branches from remote and track them locally
for remote in `git branch -r`; do git branch --track ${remote#origin/} $remote; done
//Fetch all branches
git fetch --all
//Pull all branches
git pull --all
@gandharva
gandharva / pushout.sh
Last active August 29, 2015 14:21 — forked from detj/pushout.sh
#!/bin/sh
# The MIT License (MIT)
# Copyright (c) 2014 Debjeet Biswas
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="CircularProgressView">
<attr name="cpv__backgroundColor" format="color" />
<attr name="cpv__backgroundColorPressed" format="color" />
<attr name="cpv__animationTime" format="float" />
<attr name="cpv__insideRadius" format="dimension" />
<attr name="cpv__progressWidth" format="dimension" />
</declare-styleable>
</resources>
package com.doomonafireball.samples.android.widget;
import com.doomonafireball.samples.android.R;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
@gandharva
gandharva / .gitignore
Created April 23, 2014 08:38
.gitignore file to be included while developing in android studio
.DS_Store
# built application files
*.apk
*.ap_
# files for the dex VM
*.dex
# Java class files
package io.leftshift.app;
import com.crashlytics.android.Crashlytics;
import timber.log.Timber;
/**
* A logging implementation which reports 'info', 'warning', and 'error' logs to Crashlytics.
*/
public class CrashlyticsTree extends Timber.HollowTree {
@Override public void v(String message, Object... args) {
package io.leftshift.utilities;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.HashMap;
import java.util.Map;
import org.apache.http.HttpResponse;
@gandharva
gandharva / README
Created January 7, 2014 14:19 — forked from MarsVard/README
put card.xml in your drawables directory, put colors.xml in your values directory or add the colors to your colors.xml file.
set the background of a view to card,
as you can see in card.xml the drawable handles the card margin, so you don't have to add a margin to your view
``` xml
<View
android:layout_width="fill_parent"