Skip to content

Instantly share code, notes, and snippets.

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

Nady Shalaby nadyshalaby

🏠
Working from home
View GitHub Profile
@nadyshalaby
nadyshalaby / JsTranslationsServiceProvider.php
Created April 9, 2023 02:00
Laravel blade directive to load laravel lang files using helper like the translation helper that laravel uses `__(key, [])`
<?php
namespace App\Providers;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\ServiceProvider;
class JsTranslationsServiceProvider extends ServiceProvider
{
public function register(): void
@nadyshalaby
nadyshalaby / worktree.md
Last active May 26, 2022 14:25
Git Worktree Most Used Command

Worktree most used commands

To open worktree from current bransh

git worktree add --detach <worktree-path> <branch-name>

To open worktree from remote branch

git worktree add --detach <worktree-path> <remote-name>/<branch-name>

To open worktree from commit

git worktree add --detach

@nadyshalaby
nadyshalaby / Dockerfile
Last active November 11, 2022 01:36
Docker Compose & Dockerfile to build any php application.
FROM php:8.1-apache
RUN apt-get update && apt-get install -y git \
libpng-dev \
zlib1g-dev \
libwebp-dev \
libjpeg62-turbo-dev \
libpng-dev libxpm-dev \
libfreetype6-dev
RUN docker-php-ext-configure gd \
@chjlsch
chjlsch / decode.ts
Created January 6, 2022 21:35
recursively encode and decode querystrings (encode = object to querystring, decode = querystring to object)
export function decode(querystring: string): object {
function parseValue(value: string): any {
if (value === 'TRUE') return true;
if (value === 'FALSE') return false;
return isNaN(Number(value)) ? value : Number(value);
}
function dec(list: any[], isArray = false): object {
let obj: any = isArray ? [] : {};
const axios = require('axios');
const fs = require('fs');
const process = async () => {
const response = await axios.get('https://goo.gl/maps/29XfoqKK5s7UdaSy8');
const expression = /window.APP_INITIALIZATION_STATE=\[\[\[\d+.\d+,(\d+.\d+),(\d+.\d+)/
const [,lat, long] = response.data.match(expression)[0].split('[[[')[1].split(',')
console.log({ lat, long})
return { lat, long};
@nadyshalaby
nadyshalaby / Laravel-Virtual-Host-Apache2.conf
Last active November 5, 2022 20:36
How to setup apache2 virtual host for laravel project
# -----------------( Terminal ) -------------------
cd /path/to/project/directory
sudo usermod -aG www-data $(whoami) # use 'webapp' instead of 'www-data' if you are using AWS
sudo chown -R $(whoami):www-data .
sudo find . -type f -exec chmod 0664 {} \;
sudo find . -type d -exec chmod 0775 {} \;
sudo chmod -R g+s .
sudo vi /etc/apache2/sites-available/example.local.conf
sudo a2ensite example.local.conf
@ffeu
ffeu / main.dart
Created August 3, 2018 00:18
Flutter Main Example with StreamBuilder
import 'dart:async';
import 'package:flutter/material.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(