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 / 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);