Skip to content

Instantly share code, notes, and snippets.

View Ahed91's full-sized avatar
🛩️
I want to fly

ʿAhed ʿid Ahed91

🛩️
I want to fly
View GitHub Profile
@Ahed91
Ahed91 / Controller.php
Created October 19, 2020 08:48
Madara DataTables (simple alternative to Yajra DataTables)
<?php
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
class HomeController extends Controller
{
// define route Route::post('datatable', 'Controller@datatable')->name('datatable');
@Ahed91
Ahed91 / config.exs
Created March 22, 2020 08:35
phoenix protobuf gist
config :mime, :types, %{
"application/x-protobuf" => ["protobuf"]
}
<?php
namespace App\Jobs;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Support\Facades\Mail;
@Ahed91
Ahed91 / laravelQueueOnce1.conf
Created September 2, 2018 06:48
my setup Laravel queue worker
[program:laravelQueueOnce1]
command=bash -c 'sleep 5 && php artisan queue:work --once --queue=blocked'
directory=/home/ahed/project/laravel/
autostart=true
autorestart=true
redirect_stderr=true
user=ahed ; should use www-data
stdout_logfile=syslog
stderr_logfile=syslog
autostart=true
@Ahed91
Ahed91 / Controller.php
Created July 26, 2018 09:22
select2 with laravel controller
<?php
namespace App\Http\Controllers;
class CityController extends BaseController
{
public function getRegions()
{
$s = request()->get('q', '');
@Ahed91
Ahed91 / app_Providers_AuthServiceProvider.php
Created July 25, 2018 07:27
multi-api example with laravel
<?php
public function boot()
{
Auth::viaRequest('multip-api', function ($request) {
$authorization = $request->header('Authorization');
$role = $request->header('Auth-Role');
if (!in_array($role, ['client', 'employee', 'admin', 'user'])) {
return null;
@Ahed91
Ahed91 / check.php
Created June 19, 2018 11:37
check ios Alamofire api
<?php
//Detect special conditions devices
$IOS = stripos($_SERVER['HTTP_USER_AGENT'],"iOS");
//do something with this information
if( $IOS ){
//browser reported as an iPhone/iPod touch -- do something here
@Ahed91
Ahed91 / resize.php
Created December 28, 2017 11:01
image resizer php with crop and auto padding
<?php
// TODO create uploads/cache folder
public static function resize($path, $w, $h)
{
$path = ltrim($path, '/');
if (!file_exists(public_path($path))) {
$path = "uploads/placeholder.png";
}
@Ahed91
Ahed91 / install_phpmyadmin.bash
Created July 10, 2017 08:43
Install last phpmyadmin on any linux server (Ubuntu, Debian, ....)
cd /var/www/html # web root
mkdir temp_dir
cd temp_dir
wget https://files.phpmyadmin.net/phpMyAdmin/4.7.2/phpMyAdmin-4.7.2-english.tar.xz
tar xf phpMyAdmin-4.7.2-english.tar.xz
uuidgen # this will generate unique uuid copy_it
mv phpMyAdmin-4.7.2-english/ ../uniqe_uuid
cd ..
rm -rf temp_dir/
cd uniqe_uuid/
@Ahed91
Ahed91 / SomeController.php
Created June 20, 2017 09:52
Laravel Pagination with datatables server side
class SomeController extends Controller
{
public function anydata(Request $request)
{
$valid_columns = [
'id',
'user_id',
'sh_name',
'sh_price',
'photo_id',