Skip to content

Instantly share code, notes, and snippets.

View patelnwd's full-sized avatar
🏠
Working from home

Mukesh Patel patelnwd

🏠
Working from home
View GitHub Profile
@patelnwd
patelnwd / gir-multiple-profile.md
Created November 5, 2026 05:45
Git-Multiple-Profile

Multiple Git profiles on one machine

Use a separate SSH key and host alias for each account, then set the commit author for each repository. This guide uses personal GitHub and work Bitbucket accounts; the same approach supports two accounts on the same provider.

Commands target Linux with Git, OpenSSH, and Bash or Zsh installed. Replace the example names, emails, account names, and repository paths with your own values. Edit configuration files by merging the examples into their existing contents.

@patelnwd
patelnwd / dev-setup-environment.ps1
Last active October 23, 2025 08:07
Here’s a Windows PowerShell script that installs a full development environment — including Node.js, Nginx, Python, MySQL or PostgreSQL, and VS Code — using winget, the official Windows package manager.
# Requires Windows 10/11 with winget installed
# Run this script as Administrator
Write-Host "🚀 Starting Developer Environment Setup..." -ForegroundColor Cyan
# Ensure Winget is available
if (!(Get-Command winget -ErrorAction SilentlyContinue)) {
Write-Host "⚠️ Winget not found. Please install App Installer from Microsoft Store." -ForegroundColor Red
exit 1
}
@patelnwd
patelnwd / NetworkConnection.php
Last active July 26, 2025 12:21
This utility class provides methods to test network connectivity to remote hosts using a specified port and timeout. It can be used for service availability checks, network diagnostics, and ensuring dependent services are accessible.
<?php
declare(strict_types=1);
namespace App\Library\Utility;
use Cake\Http\Exception\NotFoundException;
/**
* NetworkConnection class for testing connectivity to remote hosts
*
@patelnwd
patelnwd / PascalSnakeCase.ps1
Created June 9, 2023 05:24 — forked from awakecoding/PascalSnakeCase.ps1
PowerShell ConvertTo-PascalCase, ConvertTo-SnakeCase
function ConvertTo-PascalCase
{
[OutputType('System.String')]
param(
[Parameter(Position=0)]
[string] $Value
)
# https://devblogs.microsoft.com/oldnewthing/20190909-00/?p=102844
return [regex]::replace($Value.ToLower(), '(^|_)(.)', { $args[0].Groups[2].Value.ToUpper()})
@patelnwd
patelnwd / delete_older_than.php
Created June 1, 2021 15:49 — forked from tdebatty/delete_older_than.php
A simple PHP function to delete files older than a given age. Very handy to rotate backup or log files, for example...
<?php
/**
* A simple function that uses mtime to delete files older than a given age (in seconds)
* Very handy to rotate backup or log files, for example...
*
* $dir String whhere the files are
* $max_age Int in seconds
* return String[] the list of deleted files
*/
@patelnwd
patelnwd / my.ini
Created May 14, 2021 01:21 — forked from hanjong/my.ini
my.ini for mySQL
# MySQL Server Instance Configuration File
# ----------------------------------------------------------------------
# Generated by the MySQL Server Instance Configuration Wizard
#
#
# Installation Instructions
# ----------------------------------------------------------------------
#
# On Linux you can copy this file to /etc/my.cnf to set global options,
# mysql-data-dir/my.cnf to set server-specific options
Windows Registry Editor Version 5.00
; This will handle right clicking on a file
[HKEY_CLASSES_ROOT\*\shell\Open with VS Code]
@="Edit with VS Code"
"Icon"="C:\\Program Files (x86)\\Microsoft VS Code\\Code.exe,0"
[HKEY_CLASSES_ROOT\*\shell\Open with VS Code\command]
@="\"C:\\Program Files (x86)\\Microsoft VS Code\\Code.exe\" \"%1\""
@patelnwd
patelnwd / color_code_converter.js
Created October 10, 2018 08:40
You can convert Hex to RBG color code and vice versa.
function componentToHex(c) {
var hex = c.toString(16);
return hex.length == 1 ? "0" + hex : hex;
}
function rgbToHex(r, g, b) {
return "#" + componentToHex(r) + componentToHex(g) + componentToHex(b);
}
function hexToRgb(hex) {
@patelnwd
patelnwd / BackgroundProcess.php
Last active August 12, 2020 05:41
A PHP background processing class to execure an process in background.
<?php
/**
* -------------------------------------------------------------------------------------
* Written on - 13-June-2018 14:30:00
* Wtirren By - Mukesh Patel (http://patelworld.in) | (http://facebook.com/patelnwd)
* =====================================================================================
*
* This Class is written for Process Background Process.
* Most of cases we saw we need to execute some process without user interaction,
@patelnwd
patelnwd / percentile_as_excel.php
Last active October 4, 2018 08:40
This function calculates percentile value for given data set and percentile. Similar to MS excel =PERCENTILE(data,k) function.
<?php
function percentile_as_excel($data, $percentile){
if( 0 <= $percentile && $percentile <= 1 ) {
$p = $percentile;
}else {
return "";
}
$count = count($data);
$allindex = ($count-1)*$p;
$intvalindex = intval($allindex);