Skip to content

Instantly share code, notes, and snippets.


Zakari Abdessamad abdes-zakari

View GitHub Profile
View JavaScript: Pluck values from array
const data = [
{ city: 'Madrid', country: 'ES' },
{ city: 'Berlin', country: 'DE' },
{ city: 'Paris', country: 'FR' }
const _data = => i['city']) // ['Madrid', 'Berlin', 'Paris']
abdes-zakari / windows ping port.txt
Last active December 18, 2021 23:38
windows ping port
View windows ping port.txt
// PowerShell cmd
Test-NetConnection -computername -port 443
Test-NetConnection -computername -port 80
Test-NetConnection -computername -port 3306
// CMD terminal
abdes-zakari / mysql_enable_remote_access.sql
Created December 17, 2021 12:24
MySql: Enable access for the remote user
View mysql_enable_remote_access.sql
-- MySql: Enable access for remote user
GRANT ALL PRIVILEGES ON *.* TO 'root'@'' IDENTIFIED BY 'my_password';
flush privileges;
-- or for specfic user and database
GRANT ALL ON fooDatabase.* TO fooUser@'' IDENTIFIED BY 'my_password';
abdes-zakari / get_sym_target.bat
Created December 15, 2021 11:47
Windows: get symbolic link target
View get_sym_target.bat
@echo off
rem Windows: get symbolic link target
rem cmd: get_sym_target.bat <dir> <folder|file>
rem for /f "tokens=2 delims=[]" %%H in ('dir /al %1 ^| findstr /i /c:"%2"') do (
rem echo %%H
rem )
rem cmd: get_sym_target.bat <folder|file> // current directory
for /f "tokens=2 delims=[]" %%H in ('dir /al . ^| findstr /i /c:"%1"') do (
echo %%H
abdes-zakari /
Created December 3, 2021 15:23
Add Git Branch Name to Terminal Prompt on Mac (Big Sur)

Add Git Branch Name to Terminal Prompt on Mac (Big Sur)

Open ~/.zprofile or ~/.zshrc in your favorite editor and add the following content to the bottom. ( if the file ~/.zprofile or ~/.zprofile does not already exist create it)

# Git branch in prompt.
function parse_git_branch() {
    git branch 2> /dev/null | sed -n -e 's/^\* \(.*\)/[\1]/p'
abdes-zakari / Enable_MySQL_Query_Log.sql
Last active December 17, 2021 12:25
Enable MySQL Query Log
View Enable_MySQL_Query_Log.sql
//Enable MySQL Query Log
// To see global variable is enabled or not and location of query log
SHOW VARIABLES like 'general%';
// Set query log on
SET GLOBAL general_log = ON;
abdes-zakari / regex_js.js
Created November 16, 2021 14:33
Javascript Regex Test
View regex_js.js
// Javascript Regex Test example
[0-9]+ => Matches any digit (+) => one or more
\d{4} => Matches 4 digit
n^ =>Matches any string with n at the beginning of it
n$ => Matches any string with n at the end of it
\d{1,} Matches at least 1 or more of Digit
var pattern = /^\/auftrag\/edit\/AB-(\d{4})-([0-9]+)$/;
abdes-zakari /
Created June 2, 2021 07:33
Laravel's Dependency Injection Container in Depth

Laravel's Dependency Injection Container in Depth

Translations: Korean (by Yongwoo Lee)

Laravel has a powerful Inversion of Control (IoC) / Dependency Injection (DI) Container. Unfortunately the official documentation doesn't cover all of the available functionality, so I decided to experiment with it and document it for myself. The following is based on Laravel 5.4.26 - other versions may vary.

Introduction to Dependency Injection

I won't attempt to explain the principles behind DI / IoC here - if you're not familiar with them you might want to read What is Dependency Injection? by Fabien Potencier (creator of the Symfony framework).

abdes-zakari / convertWindowsFiletime.php
Last active May 17, 2021 15:33
PHP: Convert Windows Filetime to Date(UnixTime)
View convertWindowsFiletime.php
// Windows Filetime: a time value is simply a counter of ticks since an defined start of time, called epoch. Not only the "epoch date" differs between various systems, but also the counter resolution, that is how often it is updated.
// Windows uses in most functions the FILETIME structure, which represents the actual time as the number of 100-nanosecond intervals since January 1, 1601 (UTC).
# Example:
// 13228475598575215 microseconds from 1601-01-01T00:00:00Z => convert it to seconds = 13228475598575215/1000000 = 13228475598.575 seconds
// 11644473600 seconds between 1601-01-01T00:00:00Z and 1970-01-01T00:00:00Z
View laravelError
//in web.php:
Route::post('/profile/edit/save', 'AccountUserController@saveProfile')->name('save_profile');
// html code
<form class="profile-data" enctype="multipart/form-data" method="POST" action="{{ route('save_profile') }}">
{{ csrf_field() }}
<input type="hidden" name="id_user" value="{{ $user->id}}">
<div class="row r-avatar">
<div class="col-md-4" style="border:0px solid">
<img src="{{ URL::asset('frontend/img/avatars/')}}/{{ $user->user_avatar}}" alt="Avatar" style="width:100px;height:100px;max-width: none;" class="img-thumbnail img-circle">