Skip to content

Instantly share code, notes, and snippets.

View PhillipMwaniki's full-sized avatar
Who's checking ...

Phillip Mwaniki Nzuli PhillipMwaniki

Who's checking ...
View GitHub Profile
PhillipMwaniki / LatitudeRule.php
Created October 10, 2023 08:26
Laravel Longitude and Latitude Validation Rules
namespace App\Rules;
use Closure;
use Illuminate\Contracts\Validation\ValidationRule;
class LatitudeRule implements ValidationRule
PhillipMwaniki / axios.js
Created October 5, 2023 16:14
Using axios to redirect 401 error
(response) => {
return response;
(error) => {
if (error.response && error.response.status === 401) {
// Use router.push() to navigate to the login screen
router.push('/login'); // Adjust the route as needed
// Throw an exception to stop further execution
return Promise.reject('Unauthorized');
PhillipMwaniki / boundingbox.php
Last active September 27, 2023 16:23
Get coordinates for a bounding box by providing center coordinates and a distance
* This function was inspired by this mysql tutorial
* @param float $latitude
* @param float $longitude
* @param int $bearing 0 = north, 180 = south, 90 = east, 270 = west
* @param int $distance m = miles or km = kilometer
* @param string $distance_unit
PhillipMwaniki /
Created September 21, 2022 13:18
This is a bash script that gets the last tag increment major, minor or patch version and pushes it to your vcs provider
# This is a bash script that gets the last tag increment major, minor or patch version and pushes it to your vcs provider
declare -a valid_versions=('major' 'minor' 'patch')
CURTAG=`git fetch --tags && git tag -l --sort=-creatordate | head -1`
IFS='.' read -a vers <<< "$CURTAG"
PhillipMwaniki / fix-git-line-endings
Created August 6, 2018 09:24 — forked from ajdruff/fix-git-line-endings
Forces all line endings to LF in your git repo.
# Use this with or without the .gitattributes snippet with this Gist
# create a file, paste this in and run it.
# Why do you want this ? Because Git will see diffs between files shared between Linux and Windows due to differences in line ending handling ( Windows uses CRLF and Unix LF)
# This Gist normalizes handling by forcing everything to use Unix style.
# Fix Line Endings - Force All Line Endings to LF and Not Windows Default CR or CRLF
PhillipMwaniki / countries.sql
Created July 23, 2018 09:48 — forked from adhipg/countries.sql
Sql dump of all the Countries, Country Codes, Phone codes.
`iso` char(2) NOT NULL,
`name` varchar(80) NOT NULL,
`nicename` varchar(80) NOT NULL,
`iso3` char(3) DEFAULT NULL,
`numcode` smallint(6) DEFAULT NULL,
`phonecode` int(5) NOT NULL,
package tech.caveman;
import com.mongodb.MongoClient;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoDatabase;
import org.bson.Document;
import java.util.ArrayList;
import java.util.List;
PhillipMwaniki / CountryPhoneCodes.json
Created December 19, 2016 09:50
A json list of countries and their corresponding dial/phone codes.
"name": "Afghanistan",
"dial_code": "+93",
"code": "AF"
"name": "Aland Islands",
"dial_code": "+358",
"code": "AX"
PhillipMwaniki / kenyanMobilePhoneRegEx.txt
Created December 4, 2016 17:26 — forked from morrismukiri/kenyanMobilePhoneRegEx.txt
Kenyan phone number regular expression
PhillipMwaniki / Validator.php
Created January 5, 2016 15:48
Validator Service for Laravel 4.2
namespace Acme\Services;
use Validator as V;
use models;
class Validator {
protected $errors;