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
#!/bin/bash
# Made by st0rmis
# Get the last tag, increment major, minor or patch version and push it
declare -a valid_versions=('major' 'minor' 'patch')
CURTAG=`git fetch --tags && git tag -l --sort=-creatordate | head -1`
CURTAG="${CURTAG/v/}"
IFS='.' read -a vers <<< "$CURTAG"
@PhillipMwaniki
PhillipMwaniki / LatitudeRule.php
Created October 10, 2023 08:26
Laravel Longitude and Latitude Validation Rules
<?php
namespace App\Rules;
use Closure;
use Illuminate\Contracts\Validation\ValidationRule;
class LatitudeRule implements ValidationRule
{
/**
@PhillipMwaniki
PhillipMwaniki / axios.js
Created October 5, 2023 16:14
Using axios to redirect 401 error
axios.interceptors.response.use(
(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
PhillipMwaniki / boundingbox.php
Last active September 27, 2023 16:23
Get coordinates for a bounding box by providing center coordinates and a distance
<?php
/**
* This function was inspired by this mysql tutorial https://www.youtube.com/watch?v=QgnCB8X_sN4
* @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
PhillipMwaniki / tags.sh
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
#!/bin/bash
# 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`
CURTAG="${CURTAG/v/}"
IFS='.' read -a vers <<< "$CURTAG"
@PhillipMwaniki
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 fixle.sh 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
PhillipMwaniki / countries.sql
Created July 23, 2018 09:48 — forked from adhipg/countries.sql
Sql dump of all the Countries, Country Codes, Phone codes.
CREATE TABLE IF NOT EXISTS `country` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`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,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
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
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
PhillipMwaniki / kenyanMobilePhoneRegEx.txt
Created December 4, 2016 17:26 — forked from morrismukiri/kenyanMobilePhoneRegEx.txt
Kenyan phone number regular expression
/(0|\+?254)7([0-3|7])(\d){7}/