Skip to content

Instantly share code, notes, and snippets.

Varun Barad VarunBarad

Block or report user

Report or block VarunBarad

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
VarunBarad /
Created Mar 3, 2019
Script to create a single-file backup of a git repository
import os
import sys
import re
import shutil
from git import Repo
from zipfile import ZipFile
def create_backup_zip(directory_to_backup):
View MainActivity.kt
// Kotlin
public fun rateApp(rateMeButton: View): Unit {
val packageName = this.packageName
val playStoreAppUri = "market://details?id=$packageName"
val playStoreSiteUri = "$packageName"
try {
val playStoreAppIntent = Intent(Intent.ACTION_VIEW, Uri.parse(playStoreAppUri))
} catch (e: ActivityNotFoundException) {
// Java
public void rateApp(View rateMeButton) {
String packageName = this.getPackageName();
String playStoreAppUri = "market://details?id=" + packageName;
String playStoreSiteUri = "" + packageName;
try {
Intent playStoreAppIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(playStoreAppUri));
} catch (ActivityNotFoundException e) {
VarunBarad /
Last active Feb 15, 2018
Checking network connectivity on Android
public class ConnectivityHelper {
public static boolean isConnectedToNetwork(Context context) {
ConnectivityManager connectivityManager =
(ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
boolean isConnected = false;
if (connectivityManager != null) {
NetworkInfo activeNetwork = connectivityManager.getActiveNetworkInfo();
isConnected = (activeNetwork != null) && (activeNetwork.isConnectedOrConnecting());
You can’t perform that action at this time.