Skip to content

Instantly share code, notes, and snippets.

Avatar

Eddy Barraud Eddy-Barraud

View GitHub Profile
View routine.sh
#!/bin/bash
#SBATCH --time=10-00:0:0
#SBATCH --ntasks=1
#SBATCH --nodes=1
#SBATCH --cpus-per-task=12
#SBATCH --mem-per-cpu=1024
#SBATCH -J hPSP2
# exit when any command fails
set -e
View Modify resolv.conf wsl2.md

sudo rm /etc/resolv.conf && sudo bash -c 'echo "nameserver 8.8.8.8" > /etc/resolv.conf' && sudo chattr +i /etc/resolv.conf

View Solve-Wifi-Disconnection.md

If you are experiencing disconnections when you resume your always connected laptop/tab after sleep you can do the following :

Firstly, if you are using Windows 10 Home edition, enable gpedit by visiting this post : trevalim.fr/informatique/gpedit-on-windows-10-home/

After that, go inside Policy Plus and enable this rule System/PowerManagement/SleepOptions/Allow network connectivity during connected standby (battery):

rule

Now you are sure that the device won't disconnect during sleep.

On top of that, you can disable hibernation (after long period of sleep) by enabling the "deactivate hibernation" option and specifying a time of 0sec for the delay.

View gpedit-enabler.md

To enable Gpedit on windows 10 HOME run the following :

Copy this inside a bat file :

@echo off 
pushd "%~dp0" 

dir /b %SystemRoot%\servicing\Packages\Microsoft-Windows-GroupPolicy-ClientExtensions-Package~3*.mum >List.txt 
dir /b %SystemRoot%\servicing\Packages\Microsoft-Windows-GroupPolicy-ClientTools-Package~3*.mum >>List.txt 
@Eddy-Barraud
Eddy-Barraud / zstd-extract.sh
Last active Nov 22, 2020
Compress using fast ZSTD and show progress with dialog
View zstd-extract.sh
#!/bin/bash
filePath=$(wslpath "$1")
fileName=$(basename $filePath)
#cd $filePath/..
( pv -n $fileName | tar xf - -I"zstd -T0" ) 2>&1 | dialog --gauge "Progress..." 6 50
View count-occurences-of-each-word.md

cat $file | tr " " "\n" | sort | uniq -c | sort

$file : Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse accumsan lobortis iaculis. Vestibulum eu condimentum sem. Nunc ut ipsum ipsum. Vestibulum venenatis suscipit ligula vel finibus. Donec dictum eros massa, nec congue justo rutrum et. Donec dictum sagittis dui a mollis. Nullam sed ipsum dapibus, tincidunt turpis a, vestibulum mauris. Cras quis dapibus diam. Donec tempus faucibus odio nec fringilla. Praesent feugiat mi libero, at placerat ante semper quis. Vestibulum id cursus eros.
$cat $file | tr " " "\n" | sort | uniq -c | sort
      1 Cras
      1 Lorem
      1 Suspendisse
[..]
      2 dictum
      2 nec
View expose-docker-port.md

To expose a port inside a running docker container, you can create a temporary container connected to the same network. We will use socat to link the desired port to another exposed port.

docker run --rm --net some-network -p [exposed-port]:1234 verb/socat TCP-LISTEN:1234,fork TCP-CONNECT:[container-IP]:[container-port]

Then, for example, you can ssh forward this port to your localhost 80 port: ssh -N -L 80:127.0.0.1:[exposed-port] [server-IP]

View Win-Hidden-Battery-settings.md

This is a registry tweak tip

Windows is hidding a lot of options from the advanced power settings window. You can show options by going inside regedit at : HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\PowerSettings Inside this folder there are a lot of subdirectories. Click on each one you want, 44f3beca-a7c0-460e-9df2-bb8b99e0cba6 for Intel Graphics as an example. You will find a

@Eddy-Barraud
Eddy-Barraud / gethint.php
Last active May 6, 2019
Sample for converting textarea containing links with php & ajax
View gethint.php
<?php
$q = trim($_POST["q"]);
$lines = explode(PHP_EOL, $q);
$result = "";
foreach ($lines as $key => $value) {
$result .= $value . PHP_EOL;
}
echo $result;
exit;
?>