Skip to content

Instantly share code, notes, and snippets.

View ahmedrowaihi's full-sized avatar
🦖
doing thing..

Ahmed Rowaihi ahmedrowaihi

🦖
doing thing..
View GitHub Profile
@ahmedrowaihi
ahmedrowaihi / mysql-makefile
Created April 28, 2024 11:15
a small script to export-import fresh mysql data ( could be used for moving dbs )
# Define variables
EC2_INSTANCE_IP = <EC2_instance_IP>
RDS_INSTANCE_IP = <RDS_instance_IP>
USERNAME = <username>
PASSWORD = <password>
DATABASE_NAME = <database_name>
DUMP_FILE = dump.sql
# Define the export and import commands
export:
# ################################################################################
# # Install AWS CLI
RUN apk add --no-cache python3 py3-pip
RUN pip3 install --break-system-packages --upgrade pip
RUN pip3 install --break-system-packages awscli
ARG AWS_REGION
ARG AWS_ACCESS_KEY_ID
ARG AWS_SECRET_ACCESS_KEY
ARG AWS_BUCKET
@echo off
setlocal enabledelayedexpansion
rem Define arrays for paths and targets
set "Dirs[0]=PATH_TO_IMAGE_DIRECTORY"
set "Dirs[1]=PATH_TO_LOGOS_DIRECTORY"
set "Dirs[2]=PATH_TO_SVG_DIRECTORY"
set "Dirs[3]=PATH_TO_IMG_DIRECTORY"
set "Targets[0]=TAEGET_IMAGE_DIRECTORY"
@ahmedrowaihi
ahmedrowaihi / Fill AOU Survey
Created August 17, 2023 09:56
This small code snippet is to fill out the survey form | تخطي الاستبيان
// Github: ahmedrowaihi
// HOW TO USE:
// OPEN THE browser console
// Press [CTRL + SHIFT + I]
// THEN COPY PASTE THE CODE BELLOW TO THE CONSOLE AND HIT [ENTER]
const elements = Array.from(document.all).filter(element => element.id.endsWith('rbAnswer'));
elements.forEach(element => {
const radioButtons = element.querySelectorAll('input[type="radio"]');
export function indecator() {
const spinner = ['-', '\\', '|', '/']
let i = 0
let interval
return {
stop(string) {
if (interval) clearInterval(interval)
if (string) process.stdout.write(`${string}\n`)
@ahmedrowaihi
ahmedrowaihi / Binlog_filter.js
Created May 16, 2023 23:27
MySQL binlog filter
const fs = require("fs");
const binlogFile = "allbinglog.sql"; // bin log file name
const db = ""; // db name
const table = ""; // table
const outputFile = "output.sql";
const pattern = new RegExp(
function mysqlInsertToEloquent(model, raw, excludeKey = [], excludeValue = []) {
const tableName = raw.match(/(?<=INSERT INTO `)(.*?)(?=`)/)[0];
const columns = raw.match(/(?<=\()(.+?)(?=\))/)[0].split(",").map(c => c.trim().replace(/`/g, ''));
const values = raw.match(/(?<=VALUES \()(.*?)(?=\);?$)/)[0].split("),(");
let record = '';
values.forEach(val => {
const modelData = {};
const vals = val.split(",");
@ahmedrowaihi
ahmedrowaihi / AppDelegate.mm
Last active April 27, 2023 02:48
Native Side Set React Native I18nManager before the JS Bundle Kicks Off
// Modify "didFinishLaunchingWithOptions" method in IOS AppDelegate.mm
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Ahmed Rowihi: Native Side I18n hack :D
// set React Native I18nManager before the JS Bundle Kicks Off!
NSString *value = [[NSUserDefaults standardUserDefaults] stringForKey:@"@user_language"];
BOOL isRTL = [value isEqualToString:@"ar"] || [[[NSLocale preferredLanguages] objectAtIndex:0] hasPrefix:@"ar_"];
if (isRTL) {
NSLocale *locale = [[NSLocale alloc] initWithLocaleIdentifier:@"ar"];
@ahmedrowaihi
ahmedrowaihi / SaudiNumRegExp.js
Created January 9, 2023 00:46
A regex of saudi number pattern
/** A regex of saudi number pattern
* numbers will be accepted must match following formats:
* 9665xxxxxxxx, 009665xxxxxxxx, 05xxxxxxxx, +9665xxxxxxxx
* ^(\+966|966|00966|0)5 means that the number can start with +9665 or 9665 or 009665 or 05
* \d{8}$, means there should be 8 digits, and $ means the end of the string.
* All together: ^(\+966|966|00966|0)5\d{8}$
*/
const SaudiNumRegExp = /^(\+966|966|00966|0)5\d{8}$/;
export default SaudiNumRegExp;