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
VarunBarad / git-backup.py
Created Mar 3, 2019
Script to create a single-file backup of a git repository
View git-backup.py
#!/usr/bin/python3
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 = "https://play.google.com/store/apps/details?id=$packageName"
try {
val playStoreAppIntent = Intent(Intent.ACTION_VIEW, Uri.parse(playStoreAppUri))
startActivity(playStoreAppIntent)
} catch (e: ActivityNotFoundException) {
View MainActivity.java
// Java
public void rateApp(View rateMeButton) {
String packageName = this.getPackageName();
String playStoreAppUri = "market://details?id=" + packageName;
String playStoreSiteUri = "https://play.google.com/store/apps/details?id=" + packageName;
try {
Intent playStoreAppIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(playStoreAppUri));
startActivity(playStoreAppIntent);
} catch (ActivityNotFoundException e) {
@VarunBarad
VarunBarad / ConnectivityHelper.java
Last active Feb 15, 2018
Checking network connectivity on Android
View ConnectivityHelper.java
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.