Skip to content

Instantly share code, notes, and snippets.

View ahmedsayedabdelsalam's full-sized avatar

Ahmed Sayed ahmedsayedabdelsalam

View GitHub Profile
@ahmedsayedabdelsalam
ahmedsayedabdelsalam / set-tenant-header.js
Last active August 16, 2023 17:44
tenancy-livewire
export default function(tenant, headerKey = 'X-Tenant') {
handleLivewireCalls(tenant, headerKey)
handleFetchCalls(tenant, headerKey)
handleXMLHttpCalls(tenant, headerKey)
handleAxiosCalls(tenant, headerKey)
}
function handleLivewireCalls(tenant, headerKey) {
if (! window.Livewire) return;
@ahmedsayedabdelsalam
ahmedsayedabdelsalam / localazy.json
Last active August 8, 2023 08:05
laravel localazy
{
"upload": {
"files": [
{
"type": "php",
"pattern": "lang/en/**.php"
},
{
"group": "existing",
"type": "php",
@ahmedsayedabdelsalam
ahmedsayedabdelsalam / psync
Created February 4, 2022 20:51
command to sync your repos between devices
#!/bin/sh
#####################
##### VARIABLES #####
#####################
SITES_PATH=$SITES
SYNC_REPO='git@github.com:ahmedsayedabdelsalam/project-sync.git'
ORIGIN_NAME='sync'
VERSION='0.1.0'
#!/usr/bin/env php
<?php
function base64UrlEncode($text)
{
return str_replace(
['+', '/', '='],
['-', '_', ''],
base64_encode($text)
);
<?php
namespace App\Http\Traits;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Resources\Json\JsonResource;
trait ApiResponder
{
/**
#! /bin/bash
#####################################################
echo "abdelsalam" >> file.txt
#####################################################
#####################################################
: '
ahmed
sayed
// wiki for onboarding build with laravel
https://www.bookstackapp.com/
// empty password for mysql
https://linuxconfig.org/mysql-allow-empty-password
// find matches
grep -r 'something' /path/to/file.txt
// replace inline in files
<?php
/**
* we have a cart with coupon and we need to calculate the discount amount
*
* Note:
* - the coupon support multiple conditions
* - the included and excluded are optional
*/
// Order Data
@ahmedsayedabdelsalam
ahmedsayedabdelsalam / phpstorm_live_templates.txt
Last active June 27, 2020 05:46
phpstorm live templates
// (querylog) surounds a block of code with laravel qurey log
// https://twitter.com/a7medsayed/status/1276724409974296577
\DB::enableQueryLog();
$SELECTION$
\Log::info('query-log', [\DB::getQueryLog()]);
// (querycount) surounds a block of code with laravel qurey log count
\DB::enableQueryLog();
// add the following command to ~/.zshrc to restore your zsh history inside phpstorm's terminal
export HISTFILE=$HOME/.zsh_history