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 / index.html
Created August 11, 2017 13:30
Vue V-Model On Custom Component // source https://jsbin.com/wocuwir
<!DOCTYPE html>
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.4.2/vue.js"></script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Vue V-Model On Custom Component</title>
</head>
<body>
@nadyshalaby
nadyshalaby / VueJs-Image-Upload.md
Last active August 23, 2017 22:34
Uploading images through Laravel & VueJs, it's mush simpler and quicker than the normal way of handling the file uploads using vanilla js or jquery lib. also provide file preview.

Here's my code for uploading images through VueJs, it's mush simpler and quicker. also provide file preview.

VueJS Code


<template lang="html">
    <form @submit.prevent="submitAvatar">
        <img :src="image" alt="" />
        <input type="file" id="avatar" @change="updateAvatar" name="...">
@nadyshalaby
nadyshalaby / AppServiceProvider.php
Last active February 1, 2019 17:03
Coding Laravel Blade Directive to minify embedded JS & CSS code e.g. @minify(js) , @endminify using minification package ``` matthiasmullie/minify ```
<?php
namespace App\Providers;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
@nadyshalaby
nadyshalaby / ec2-ftp-tutorial.md
Created March 17, 2019 18:51 — forked from tylermakin/ec2-ftp-tutorial.md
Tutorial for configuring FTP access to an EC2 server
@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
@nadyshalaby
nadyshalaby / iframechange.js
Created November 11, 2020 07:32 — forked from hdodov/iframechange.js
HTML iframe URL change listener for tracking when a new iframe page starts to load
function iframeURLChange(iframe, callback) {
var lastDispatched = null;
var dispatchChange = function () {
var newHref = iframe.contentWindow.location.href;
if (newHref !== lastDispatched) {
callback(newHref);
lastDispatched = newHref;
}
@nadyshalaby
nadyshalaby / gist:a6b0d3e98caf67e4e0c3a6d3741c531a
Created November 18, 2020 08:01 — forked from LuenCC/gist:e8dcf4a38096617799f3002644012af6
Laravel find nearest location in km from lat, long database
private function findNearestLocation(Request $request)
{
$location = DB::table('locations')
->select('name', 'latitude', 'longitude', 'region', DB::raw(sprintf(
'(6371 * acos(cos(radians(%1$.7f)) * cos(radians(latitude)) * cos(radians(longitude) - radians(%2$.7f)) + sin(radians(%1$.7f)) * sin(radians(latitude)))) AS distance',
$request->input('latitude'),
$request->input('longitude')
)))
->having('distance', '<', 50)
->orderBy('distance', 'asc')
@nadyshalaby
nadyshalaby / AuthKey.p8
Last active February 10, 2021 11:54
Django Social Auth AppleID OAuth2 Backend for authenticating users across Flutter APP using package (sign_in_with_apple)[https://pub.dev/packages/sign_in_with_apple]
-----BEGIN PRIVATE KEY-----
MIGTAgohoMGByqGS....
.....etc.
-----END PRIVATE KEY-----
@nadyshalaby
nadyshalaby / .htaccess
Created October 20, 2021 13:06
Laravel .htaccess to enable routing from the base
RewriteEngine on
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]
@nadyshalaby
nadyshalaby / mysqldump.sh
Created January 7, 2022 22:00
Shell script to ease the database backup/restore process (Data Only)
#!/bin/sh
# This script is used to as a seeder for the database.
# It will dump a database data only or populate it.
# Show a drawing of word "MySQL Dumper Script by @nadyshalaby" on the screen.
echo "
_____________________________________
< MySQL Dumper Script by @nadyshalaby >
-------------------------------------