Skip to content

Instantly share code, notes, and snippets.

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

Mahmoud Ahmed (محمود أحمد) m5lil

🏠
Working from home
View GitHub Profile
@m5lil
m5lil / redirect.md
Last active January 14, 2019 20:21
redirect to public folder

Method 1

index.php in public_html

<?php
$uri = urldecode(
    parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)
);
if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) {
    return false;
}
@m5lil
m5lil / translate.php
Created January 11, 2019 00:58
scans your project resources/view/ and app/ folder to find lang(...) and __(...) functions, then it create keys based on first parameter value and insert into json translation files
<?php
namespace Translator\Command;
use Illuminate\Console\Command;
class Translator extends Command
{
/**
* @var string
@m5lil
m5lil / Controller.md
Created January 5, 2019 15:40
arabic pdf invoice
//install laravel-dompdf Package and arutil/ar-ph 

public function pdf($id)
{
  $data = Invoice::find($id);
  $pdf = \PDF::loadView('invoice', ['data' => $data]);
  return $pdf->stream('invoice.pdf');
}
rsync -av -e ssh SOURCE/ USERNAME@NEW_SERVER.COM:/PATH/TO/DESTINATION/
mysqldump --allow-keywords --opt -uMySQL_USERNAME -pPASSWORD DATABASE | ssh USER@DOMAIN "mysql -uMySQL_USERNAME -pPASSWORD DATABASE"
# Apache Server Configs v3.0.0 | MIT License
# https://github.com/h5bp/server-configs-apache
# (!) Using `.htaccess` files slows down Apache, therefore, if you have
# access to the main server configuration file (which is usually called
# `httpd.conf`), you should add this logic there.
#
# https://httpd.apache.org/docs/current/howto/htaccess.html
# ######################################################################
@m5lil
m5lil / eloquent-cheatsheet.php
Last active October 7, 2018 00:20 — forked from hassansin/eloquent-cheatsheet.php
Laravel 5 Eloquent CheatSheet #laravel #eloquent
Model::
/*Select*/
select('col1','col2')
->select(array('col1','col2'))
->select(DB::raw('businesses.*, COUNT(reviews.id) as no_of_ratings, IFNULL(sum(reviews.score),0) as rating'))
->addSelect('col3','col4')
->distinct() // distinct select
/*From*/
@m5lil
m5lil / deploy.sh
Created March 2, 2018 23:01
A shell script for setting up Laravel Production environment on Ubuntu 16 system.
#!/usr/bin/env bash
export DEBIAN_FRONTEND=noninteractive
# Check if user is root
[ $(id -u) != "0" ] && { echo "${CFAILURE}Error: You must be root to run this script${CEND}"; exit 1; }
# Configure
MYSQL_ROOT_PASSWORD="123qweasdzxc"
MYSQL_NORMAL_USER="m5lil"
@m5lil
m5lil / README.md
Created February 20, 2018 09:24 — forked from hofmannsven/README.md
My simply MySQL Command Line Cheatsheet
@m5lil
m5lil / DB.sql
Last active June 27, 2020 14:40 — forked from msurguy/DB.sql
[Nested drobdown Select input debend on another] Dynamic dropdown in Laravel, let's say you have multiple drop downs (selects), you click on one and the contents of the other need to be dynamically changed. One solution is to dynamically load JSON from the API and change the dropdown dynamically depending on the user choice.
CREATE TABLE `makers` (
`id` int(10) unsigned NOT NULL,
`name` varchar(255) NOT NULL,
`description` varchar(255) NOT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
# Configure Windows
Set-WindowsExplorerOptions -EnableShowHiddenFilesFoldersDrives -EnableShowProtectedOSFiles -EnableShowFileExtensions -EnableShowFullPathInTitleBar
Update-ExecutionPolicy Unrestricted
cinst -y Microsoft-Hyper-V-All -source windowsFeatures
# Packages
cinst -y cmder -pre
cinst -y hyper