Skip to content

Instantly share code, notes, and snippets.

View abdumu's full-sized avatar
💭
are we even real? or just entities in a simulated environment ,,,

Abdulrahman ☕️ abdumu

💭
are we even real? or just entities in a simulated environment ,,,
View GitHub Profile
@abdumu
abdumu / maintanance.php
Last active October 19, 2017 17:54
Arabic maintenance page + htaccess redirect except your IP
<?php
#modifed version of https://gist.github.com/pitch-gist/2999707
//by twitter/abdu1m
#htaccess:
// RewriteCond %{REQUEST_URI} !/maintenance.php$
// RewriteCond %{HTTP:X-FORWARDED-FOR} !=151.254.68.111 #this is your ip
// RewriteRule $ /maintenance.php [R=302,L]
?>
<!doctype html>
@abdumu
abdumu / Laravel.Collection.mdiff.php
Created November 1, 2017 19:53
Laravel multidimensional Collection diff function as a macro (you can add it at AppServiceProvider.php boot method)
<?php
/*
* Get the diff between two collections
*
* @param Illuminate\Support\Collection|array $items
*
* @return static
*/
Collection::macro('mdiff', function($items){
@abdumu
abdumu / laravel-voyager-admin-rtl.css
Last active September 19, 2021 12:45
A custom css file to convert Laravel voyager admin panel to RTL
@import url(//fonts.googleapis.com/earlyaccess/notokufiarabic.css);
body{
direction: rtl;
font-family: 'Noto Kufi Arabic', sans-serif;
text-align:right;
}
h1, h2, h3, h4, h5, h6{
font-family: 'Noto Kufi Arabic', sans-serif;
@abdumu
abdumu / pipleline.php
Created November 25, 2017 03:08
How Laravel middleware system work
<?php
//the middleware
$middleware1 = function ($request, $carry) {
echo "first middleware \n";
return $carry($request);
};
@abdumu
abdumu / Collection.loop.php
Last active December 23, 2017 02:55
[Laravel] Improved version of Collection->map as a macro (you can add it at AppServiceProvider.php boot method)
<?php
/*
* Improved version of Collection->map method
*
* @param callable $callback
*
* @return Illuminate\Support\Collection
*/
Illuminate\Support\Collection::macro('loop', function(callable $callback){
@abdumu
abdumu / Laravel.Collection.drop.php
Created December 23, 2017 04:11
[Laravel] Drop first or last items from a collection
<?php
/**
* drop the first or last {$limit} items.
*
* @param int $limit
* @return Illuminate\Support\Collection
*/
Illuminate\Support\Collection::macro('drop', function(int $limit){
if ($limit < 0) {
return $this->slice(0, $limit);
@abdumu
abdumu / .post-merge
Created February 25, 2018 02:44
git hook (.git/hooks/.post-merge) to run a command after `git pull` for laravel by @Abdu1M
##
# git hook to run a command after `git pull` for laravel by @abdu1m
##
# source: https://gist.github.com/sindresorhus/7996717
changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"
check_run() {
echo "$changed_files" | grep --quiet "$1" && eval "$2"
}
@abdumu
abdumu / Cacheable.php
Created March 4, 2018 11:42
Cacheable Trait for Laravel Model Class for methods, request any method after adding the trait with 'Cached' as methodNameCached()
<?php
namespace App;
use Illuminate\Support\Facades\Cache;
trait Cacheable
{
public function __call($methodName, $arguments)
@abdumu
abdumu / howTo.txt
Last active January 8, 2020 09:18
"This connection is not private" + "Valet" + "iOS Simulator"
-1- edit ~/.composer/vendor/laravel/valet/cli/stubs/openssl.conf
Change:
basicConstraints = CA:FALSE
To:
basicConstraints = CA:TRUE,pathlen:0
save file.
@abdumu
abdumu / slugify.js
Last active July 23, 2023 21:24
Javascript function to generate a slug that `respect` Arabic.
function slugify(text) {
return text.toString().toLowerCase()
.replace(/\s+/g, '-')
.replace(/[^\w\u0621-\u064A0-9-]+/g, '')
.replace(/\-\-+/g, '-')
.replace(/^-+/, '').replace(/-+$/, '');
}