Skip to content

Instantly share code, notes, and snippets.

View aritraroy's full-sized avatar

Aritra Roy aritraroy

View GitHub Profile
@aritraroy
aritraroy / git-aliases.md
Created April 4, 2016 16:06 — forked from mwhite/git-aliases.md
The Ultimate Git Alias Setup

The Ultimate Git Alias Setup

If you use git on the command-line, you'll eventually find yourself wanting aliases for your most commonly-used commands. It's incredibly useful to be able to explore your repos with only a few keystrokes that eventually get hardcoded into muscle memory.

Some people don't add aliases because they don't want to have to adjust to not having them on a remote server. Personally, I find that having aliases doesn't mean I that forget the underlying commands, and aliases provide such a massive improvement to my workflow that it would be crazy not to have them.

The simplest way to add an alias for a specific git command is to use a standard bash alias.

# .bashrc
@aritraroy
aritraroy / Foreground.java
Last active April 7, 2016 05:39 — forked from steveliles/Foreground.java
Class for detecting and eventing whether an Android app is currently foreground or background (requires API level 14+)
package com.sjl.util;
import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import java.util.List;
@aritraroy
aritraroy / IconizedMenu.java
Created June 28, 2016 18:45 — forked from mediavrog/IconizedMenu.java
Android Compatibility popup menu with icons (requires support library v7)
package com.vuzz.snapdish.ui;
import android.content.Context;
import android.support.v7.internal.view.SupportMenuInflater;
import android.support.v7.internal.view.menu.MenuBuilder;
import android.support.v7.internal.view.menu.MenuPopupHelper;
import android.support.v7.internal.view.menu.MenuPresenter;
import android.support.v7.internal.view.menu.SubMenuBuilder;
import android.view.Menu;
import android.view.MenuInflater;
@aritraroy
aritraroy / EachDirectoryPath.md
Created January 9, 2017 13:18 — forked from granoeste/EachDirectoryPath.md
[Android] How to get the each directory path.

System directories

Method Result
Environment.getDataDirectory() /data
Environment.getDownloadCacheDirectory() /cache
Environment.getRootDirectory() /system

External storage directories

public class Order {
private String id;
private String origin;
private double price;
public Order(String id, String origin, double price) {
this.id = id;
this.origin = origin;
@Test
public void login_successIfUserNameAndPasswordIsValid() {
// Arrange
String username = "username";
String password = "password";
when(userRepository.isUsernameValid(username)).thenReturn(true);
when(userRepository.isPasswordValid(password)).thenReturn(true);
// Act
@aritraroy
aritraroy / Singleton.java
Last active November 16, 2018 05:22
A Perfect Singleton Design Pattern Implementation
import java.io.Serializable;
/**
* The perfect implementation of Singleton design pattern
* Properly solves all the below mentioned problems in Singleton pattern
* <p>
* 1) Attack using Reflection API
* 2) Problems from serialization/deserialization of your object
* 3) Problems from cloning your object
* 4) Uncertainty in a multi-threaded environment
@aritraroy
aritraroy / LeakSlackUploadService.java
Created December 23, 2018 15:11 — forked from pyricau/LeakSlackUploadService.java
Sending Leak Traces to a Slack Channel (and HipChat, see the comments)
import android.util.Log;
import com.squareup.leakcanary.AnalysisResult;
import com.squareup.leakcanary.DisplayLeakService;
import com.squareup.leakcanary.HeapDump;
import retrofit.RestAdapter;
import retrofit.RetrofitError;
import retrofit.http.Multipart;
import retrofit.http.POST;
import retrofit.http.Part;
import retrofit.mime.TypedFile;
@aritraroy
aritraroy / GammaEvaluator.java
Created October 15, 2016 19:56 — forked from FrancoisBlavoet/GammaEvaluator.java
Correct color interpolation
import android.animation.TypeEvaluator;
import android.animation.ValueAnimator;
import static java.lang.Math.pow;
public class GammaEvaluator implements TypeEvaluator {
private static final GammaEvaluator sInstance = new GammaEvaluator();
/**