Skip to content

Instantly share code, notes, and snippets.

View pkavoo's full-sized avatar

Polycarp Kavoo pkavoo

  • Nairobi, Kenya
View GitHub Profile
https://gist.github.com/pkavoo/a6a80d96d8f54f592827dbde96fc08bd
@pkavoo
pkavoo / .txt
Created December 6, 2025 12:39
ssh_configuration
1. Generate a New SSH Key Pair
Open your terminal (or Git Bash on Windows) and run the following command. The ed25519 algorithm is the recommended standard for security.
Bash
ssh-keygen -t ed25519 -C "[email protected]"
Replace "[email protected]" with the email address associated with your GitHub account.
Prompt 1 (File location): Press Enter to accept the default location (usually ~/.ssh/id_ed25519). If you already have a key, it's best to enter a new name (e.g., ~/.ssh/github_id_ed25519).
Prompt 2 (Passphrase): Enter a secure passphrase to protect your private key (recommended for extra security). You will be prompted to enter this passphrase when you use the key. Press Enter twice if you do not want a passphrase.
This creates two files in the .ssh directory:
id_ed25519: Your private key (keep this secret and safe).
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.InputMismatchException;
// Account class representing a bank account
class Account {
private int accountNumber;
private String accountHolder;
private double balance;
@pkavoo
pkavoo / isGPSEnabled
Created April 2, 2020 21:39
Method for checking if GPS is enabled
public boolean isGPSEnabled(Context mContext) {
LocationManager locationManager = (LocationManager) mContext.getSystemService(Context.LOCATION_SERVICE);
return locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
}
@pkavoo
pkavoo / isInterenetConnected
Last active April 2, 2020 21:38
Method for checking if internet is turned on
public static boolean isInternetConnected(Context ctx) {
ConnectivityManager connectivityMgr = (ConnectivityManager) ctx
.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo wifi = connectivityMgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
NetworkInfo mobile = connectivityMgr.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
// Check if wifi or mobile network is available or not. If any of them is
// available or connected then it will return true, otherwise false;
if (wifi != null) {
if (wifi.isConnected()) {
return true;
@pkavoo
pkavoo / Draw Route Method
Created April 2, 2020 21:36
Here you can change the minimum time or distance to get new locations and draw on map
private LocationManager locationManager;
private android.location.LocationListener myLocationListener;
public void checkLocation() {
String serviceString = Context.LOCATION_SERVICE;
locationManager = (LocationManager) getSystemService(serviceString);
if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
@pkavoo
pkavoo / twitter crawler.txt
Created November 6, 2019 23:46 — forked from vickyqian/twitter crawler.txt
A Python script to download all the tweets of a hashtag into a csv
import tweepy
import csv
import pandas as pd
####input your credentials here
consumer_key = ''
consumer_secret = ''
access_token = ''
access_token_secret = ''
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
@pkavoo
pkavoo / LatLngInterpolator.java
Last active July 6, 2019 09:31
interpolation is a method of constructing new data points within the range of a discrete set of known data points. This class loops through lat lng data and creates a data set
import com.google.android.gms.maps.model.LatLng;
import static java.lang.Math.asin;
import static java.lang.Math.atan2;
import static java.lang.Math.cos;
import static java.lang.Math.pow;
import static java.lang.Math.sin;
import static java.lang.Math.sqrt;
@pkavoo
pkavoo / MarkerAnimation.java
Last active July 6, 2019 09:30
Marker animation class
import android.os.Handler;
import android.os.SystemClock;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.animation.Interpolator;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
@pkavoo
pkavoo / MainActivity.java
Last active July 6, 2019 09:26
Java code for activity_main.xml layout file with fragment
import android.Manifest;
import android.content.pm.PackageManager;
import android.location.Location;
import android.os.Build;
import android.os.Bundle;
import android.os.Looper;
import android.view.View;
import android.widget.Toast;
import androidx.annotation.NonNull;