Skip to content

Instantly share code, notes, and snippets.

View RyadPasha's full-sized avatar
🎯
Focusing

Mohamed Riyad RyadPasha

🎯
Focusing
View GitHub Profile
@RyadPasha
RyadPasha / DeviceModelManager.swift
Created January 4, 2024 19:47
A utility struct for managing device model mappings based on hardware machine identifiers.
//
// DeviceModelManager.swift
// A utility struct for managing device model mappings based on hardware machine identifiers.
//
// @author Mohamed Riyad <m@ryad.dev>
// @link https://RyadPasha.com
// @license MIT
//
import Foundation
@RyadPasha
RyadPasha / MultiSourceTranslator.ts
Last active December 15, 2023 01:55
A class that provides translation capabilities with support for multiple sources, such as file-based translations and database translations.
/**
* MultiSourceTranslator is a class that provides translation capabilities with support for multiple sources, such as
* file-based translations and database translations. It allows you to load translations for multiple languages and
* supports string interpolation using placeholders.
*
* @class MultiSourceTranslator
* @author Mohamed Riyad <m@ryad.dev>
* @link https://RyadPasha.com
* @copyright Copyright (C) 2023 RyadPasha. All rights reserved.
* @license MIT
@RyadPasha
RyadPasha / inspect.ts
Created August 1, 2023 16:02
Printing a circular structure in a JSON-like format
import util from 'util' // In TS
// Or
import { inspect } from 'util' // Directly (TS)
// Or
const util = require('util') // In JS
// Or
const { inspect } = require('util') // Directly (JS)
// Then:
console.log(util.inspect(request)) // Or `console.log(inspect(request))` in case you directly imported it
@RyadPasha
RyadPasha / TimeUtility.ts
Last active July 26, 2023 15:07
TimeUtility is a utility class that provides a set of methods to handle time-related operations.
/**
* TimeUtility is a utility class that provides a set of methods to handle time-related operations.
*
* @class DatabaseManager
* @author Mohamed Riyad <m@ryad.me>
* @link https://RyadPasha.com
* @copyright Copyright (C) 2023 RyadPasha. All rights reserved.
* @license MIT
* @version 1.0.0-2023.07.26
* @see {@link https://momentjs.com/} for more information on Moment.js
@RyadPasha
RyadPasha / Logger.ts
Last active January 3, 2024 22:07
Logger class that wraps 'winston' and provides custom logging capabilities with different log levels.
/**
* Logger class that wraps 'winston' and provides custom
* logging capabilities with different log levels.
*
* @class Logger
* @author Mohamed Riyad <m@ryad.dev>
* @link https://RyadPasha.com
* @copyright Copyright (C) 2024 RyadPasha. All rights reserved.
* @license MIT
* @version 1.0.2-2024.01.03
@RyadPasha
RyadPasha / DatabaseManager.ts
Last active July 20, 2023 05:21
DatabaseManager class that handles multiple database connections using Knex.js.
/**
* DatabaseManager class that handles multiple database connections using Knex.js.
*
* @class DatabaseManager
* @author Mohamed Riyad <m@ryad.me>
* @link https://RyadPasha.com
* @copyright Copyright (C) 2023 RyadPasha. All rights reserved.
* @license MIT
* @version 1.0.0-2023.07.16
* @see {@link https://knexjs.org} for more information on Knex.js
@RyadPasha
RyadPasha / PushTokensValidator.js
Last active November 3, 2023 07:22
A Node.js class for validating * the authenticity of FCM and APN device/push tokens.
/**
* PushTokensValidator: A Node.js class for validating
* the authenticity of FCM and APN device/push tokens.
*
* @class PushTokensValidator
* @author Mohamed Riyad <m@ryad.dev>
* @link https://RyadPasha.com
* @link https://gist.github.com/RyadPasha/297ae21e94fe57eb210e7eba6cf1cc42
* @copyright Copyright (C) 2023 RyadPasha. All rights reserved.
* @license MIT
@RyadPasha
RyadPasha / HuaweiAPI.js
Last active July 11, 2023 12:57
A service class representing the HuaweiAPI to send push notifications and check the risk of a device on Huawei devices.
/**
* A service class representing the HuaweiAPI to send push
* notifications and check the risk of a device on Huawei devices.
*
* @class HuaweiAPI
* @author Mohamed Riyad <m@ryad.me>
* @link https://RyadPasha.com
* @link https://gist.github.com/RyadPasha/8aa30994e08b9ed08183b091f596d7eb
* @copyright Copyright (C) 2023 RyadPasha. All rights reserved.
* @license MIT
@RyadPasha
RyadPasha / parseArguments.js
Last active June 23, 2023 15:59
Parse command-line arguments in Node.js
/**
* Parse command-line arguments in the format:
* ● --arg_name=arg_value
* ● -arg_name=arg_value
* ● arg_name=arg_value
*
* @author Mohamed Riyad <m@ryad.me>
*
* @param {string[]} [args] - The array of command-line arguments.
* @returns {Object} An object containing the parsed arguments.
@RyadPasha
RyadPasha / getRealUserIP.js
Created May 12, 2023 17:19
Retrieve the real IP address of the user making the request.
/**
* Real User IP Grabber
*
* @author Mohamed Riyad <m@ryad.me>
* @link RyadPasha.com
* @copyright Copyright (C) 2022 RyadPasha. All rights reserved.
* @license GNU General Public License v3.0 http://www.gnu.org/copyleft/gpl.html
* @version Release: 1.0
* @since 10 Nov, 2022
*/