Skip to content

Instantly share code, notes, and snippets.

View abdes-zakari's full-sized avatar

Zakari Abdessamad abdes-zakari

View GitHub Profile
@abdes-zakari
abdes-zakari / extractUrls.js
Last active June 29, 2024 18:42
Extract soundcloud urls from a playlist and create a m3u8 playlist
// Extract soundcloud url from a playlist
//open the soundcloud playlist in the browser and put this in the console of the brwoser
const tracks = document.getElementsByClassName("trackItem__trackTitle");
for (let i = 0; i < tracks.length; i++) {
console.log(tracks[i].href)
}
const data = [
{ city: 'Madrid', country: 'ES' },
{ city: 'Berlin', country: 'DE' },
{ city: 'Paris', country: 'FR' }
];
const _data = data.map(i => i['city']) // ['Madrid', 'Berlin', 'Paris']
@abdes-zakari
abdes-zakari / windows ping port.txt
Last active December 18, 2021 23:38
windows ping port
// PowerShell cmd
Test-NetConnection -computername google.de -port 443
Test-NetConnection -computername 192.168.1.4 -port 80
Test-NetConnection -computername 192.168.1.7 -port 3306
// CMD terminal
@abdes-zakari
abdes-zakari / mysql_enable_remote_access.sql
Created December 17, 2021 12:24
MySql: Enable access for the remote user
-- MySql: Enable access for remote user
GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.1.7' IDENTIFIED BY 'my_password';
flush privileges;
-- or for specfic user and database
GRANT ALL ON fooDatabase.* TO fooUser@'192.168.1.7' IDENTIFIED BY 'my_password';
@abdes-zakari
abdes-zakari / get_sym_target.bat
Created December 15, 2021 11:47
Windows: get symbolic link target
@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
abdes-zakari / mac-git-name-branch.md
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
abdes-zakari / Enable_MySQL_Query_Log.sql
Last active December 17, 2021 12:25
Enable MySQL Query Log
//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
abdes-zakari / regex_js.js
Created November 16, 2021 14:33
Javascript Regex Test
// 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
abdes-zakari / Laravel-Container.md
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
abdes-zakari / convertWindowsFiletime.php
Last active May 17, 2021 15:33
PHP: Convert Windows Filetime to Date(UnixTime)
<?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