Skip to content

Instantly share code, notes, and snippets.

View NAbdulla1's full-sized avatar

Md. Abdulla Al Mamun NAbdulla1

  • Rangpur, Bangladesh
View GitHub Profile
@NAbdulla1
NAbdulla1 / generate-correct-xdebug.ini-on-wsl2.sh
Last active September 3, 2021 19:38
After configuring the xdebug on wsl2 according to the official guide in PhpStorm website have to write the following script to generate xdebug.ini with correct HOST_IP. I execute this script every time I reboot pc.
#!/bin/bash
lin_ip4=$(ip -4 address show label eth0 | grep inet | sed 's/^.*inet //' | sed 's/\/.*$//')
touch /tmp/foo
f=/tmp/foo
/mnt/c/Windows/System32/ipconfig.exe | sed 's/.$//' > $f
a=$(cat $f | grep -n WSL | sed 's/:.*$//')
b=$(cat $f | wc -l)
c=$(( $b - $a ))
win_ip4=$(cat $f | tail -n $c | grep IPv4 | head -n 1 | sed 's/^.* : //')
echo $win_ip4 #above code is from here: https://www.reddit.com/r/bashonubuntuonwindows/comments/i4m90o/how_to_know_ip_address_of_windows_within_ubuntu/
@NAbdulla1
NAbdulla1 / launch.json
Last active August 13, 2021 06:11
Setup wsl2 and vscode on windows to use xdebug as php debugger. vscode will connect to wsl2 via remote connection. the xdebug.ini file is located at `/etc/php/7.4/mods-available/xdebug.ini`. (7.4 is php version. it can differ, and the tested xdebug version is 2.9.2). the `launch.json` must be in `.vscode` folder of the project in the project root
{
"version": "0.2.0",
"configurations": [
{
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"port": 9000,
"ignore": [
"**/vendor/**/*.php"
@NAbdulla1
NAbdulla1 / axios example.js
Last active June 24, 2021 13:31
JS http rest client fetch and axios
axios.get('http://httpbin.org/status/400')
.then(function (success) {
// response code is 2xx
console.log('success:', success.data);
console.log('success:', success.status);
console.log('success:', success.headers);
})
.catch(function (error) {
//render the error for better UX
if (error.response) {