Skip to content

Instantly share code, notes, and snippets.

View gitanshu's full-sized avatar
💭
Looking for Full time positions starting Feb 2021

Gitanshu Sardana gitanshu

💭
Looking for Full time positions starting Feb 2021
View GitHub Profile
@gitanshu
gitanshu / hello_prefect.py
Last active April 1, 2022 12:46 — forked from ryanjulian/hello_prefect.py
Prefect + dask.distributed Quickstart
import time
from prefect import task, Flow
from prefect.engine.executors import DaskExecutor
from prefect.environments import LocalEnvironment
from prefect.utilities.logging import get_logger
logger = get_logger('dask-example')
executor = DaskExecutor(address='tcp://localhost:8786')
@gitanshu
gitanshu / .gitconfig
Last active May 9, 2017 09:50 — forked from donnfelker/.gitconfig
My .gitconfig
[user]
name = FirstName LastName
email = you@yourdomain.com
[alias]
A = add -A
a = add
aa = add --all
ae = add --edit
ai = add --interactive
amend = commit --amend -C HEAD
package nz.bradcampbell.app.presentation;
import android.content.Context;
import android.support.v4.view.LayoutInflaterFactory;
import android.util.AttributeSet;
import android.view.View;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
@gitanshu
gitanshu / OkHttpStack.java
Created October 23, 2016 06:12 — forked from NightlyNexus/OkHttpStack.java
OkHttp 3 implementation of Volley's HttpStack
/*
* Copyright (C) 2016 Eric Cochran
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@gitanshu
gitanshu / MarginSpan.java
Created October 6, 2016 09:04 — forked from liberorignanese/MarginSpan.java
Android TextInputLayout with credit card mask
package com.liberorignanese.android.gist;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.text.style.ReplacementSpan;
/**
* Created by Libero Rignanese.
*/
@gitanshu
gitanshu / howto.md
Created October 1, 2016 14:56 — forked from neworld/howto.md
How to make faster Android build without sacrificing new api lint check

Original solution sacrifices new api lint check.

Here my solution:

int minSdk = hasProperty('minSdk') ? minSdk.toInteger() : 16

apply plugin: 'com.android.application'

android {
 compileSdkVersion 23
@gitanshu
gitanshu / BroadcastObservable.java
Created August 22, 2016 12:05 — forked from Diolor/BroadcastObservable.java
Retry with Connection
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Looper;
import rx.Observable;
import rx.Scheduler;
@gitanshu
gitanshu / AndroidApplication.java
Created July 22, 2016 03:45 — forked from android10/AndroidApplication.java
Android: how to know if your app is completely hidden
public class AndroidApplication extends MultiDexApplication {
public static final String TAG = AndroidApplication.class.getSimpleName();
@Override
public void onCreate() {
super.onCreate();
registerComponentCallbacks(new ComponentCallback());
}
private class ComponentCallback implements ComponentCallbacks2 {
/**
* Show the activity over the lockscreen and wake up the device. If you launched the app manually
* both of these conditions are already true. If you deployed from the IDE, however, this will
* save you from hundreds of power button presses and pattern swiping per day!
*/
public static void riseAndShine(Activity activity) {
activity.getWindow().addFlags(FLAG_SHOW_WHEN_LOCKED);
PowerManager power = (PowerManager) activity.getSystemService(POWER_SERVICE);
PowerManager.WakeLock lock =