Skip to content

Instantly share code, notes, and snippets.

View D4R4's full-sized avatar

Dara Ardalan D4R4

  • SCALINX
  • Paris, France
View GitHub Profile
@D4R4
D4R4 / .htaccess
Created March 10, 2023 11:53
Here's the htaccess code to allow everything in CSP
<ifModule mod_headers.c>
Header set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" env=HTTPS
Header set X-XSS-Protection "1; mode=block"
Header set X-Content-Type-Options nosniff
Header set X-Frame-Options DENY
Header add Content-Security-Policy "default-src * data: blob: filesystem: about: ws: wss: 'unsafe-inline' 'unsafe-eval' 'unsafe-dynamic'; script-src * data: blob: 'unsafe-inline' 'unsafe-eval'; connect-src * data: blob: 'unsafe-inline'; img-src * data: blob: 'unsafe-inline'; frame-src * data: blob: ; style-src * data: blob: 'unsafe-inline'; font-src * data: blob: 'unsafe-inline';"
</ifModule>
@D4R4
D4R4 / cpu.sh
Created February 25, 2023 10:25
CPU performance metrics and tuning
uname -a
lsb_release -a
lscpu | grep "MHz".
sudo dmidecode -t processor | grep "Speed"
lshw -c cpu | egrep "capacity|size"
sudo lshw -c cpu | egrep "capacity|size"
head /sys/devices/system/cpu/cpu0/cpufreq/scaling_*
yum install -y powertop
powertop
@D4R4
D4R4 / ram_usage.sh
Last active January 14, 2023 09:10
List users by RAM usage
ps aux | awk '{print $6/1024 " MB \t\t" $1 "\t\t" $11}' | sort -n | tail -n 50 | tac
@D4R4
D4R4 / onlyoffice_docker.sh
Created January 14, 2023 09:08
Setup an ONLYOFFICE docker instance to go with Tuleap enterprise
sudo docker run -i -t -d -p 2443:443 \
-e JWT_SECRET=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\
-v /app/onlyoffice/DocumentServer/logs:/var/log/onlyoffice \
-v /app/onlyoffice/DocumentServer/data:/var/www/onlyoffice/Data \
-v /app/onlyoffice/DocumentServer/lib:/var/lib/onlyoffice \
@D4R4
D4R4 / add_sender.ps1
Created November 4, 2022 13:02
Add accepted senders to delivery management section of Exchange office 365 gorups. not available throught the GUI
Set-UnifiedGroup "news-internal@wwww.com" –AcceptMessagesOnlyFrom @{add="communication@wwwww.com"}
Set-UnifiedGroup "news-internal@wwww.com" -AcceptMessagesOnlyFromSendersOrMembers @{add="communication@wwww.com"}
@D4R4
D4R4 / disable_gnome_tracker
Created June 17, 2022 08:37
Kill and disable gnome trackers in rhel
### VERY careful here... point is to surgically remove tracker processes
kill $(ps aux | grep 'tracker' | awk '{print $2}')
echo "Hidden=true" >> /etc/xdg/autostart/tracker-extract.desktop
echo "Hidden=true" >> /etc/xdg/autostart/tracker-miner-apps.desktop
echo "Hidden=true" >> /etc/xdg/autostart/tracker-miner-fs.desktop
echo "Hidden=true" >> /etc/xdg/autostart/tracker-miner-user-guides.desktop
echo "Hidden=true" >> /etc/xdg/autostart/tracker-store.desktop
dbus-launch --exit-with-session gsettings set org.freedesktop.Tracker.Miner.Files crawling-interval -2
@D4R4
D4R4 / mail-on-session.sh
Last active March 4, 2022 17:32
Send email on ssh sessions, useful to put in .bashrc, Requires sendemail package to be installed
UZR=`who | cut -d"(" -f2 | cut -d")" -f1`
if [ "$UZR" != "" ]; then
sendemail -f 'noreply@dest.com' -t 'dest@dest.com' -s '10.10.10.10' -u "Alert: Root Access on `hostname` from $UZR" -m "at `date`" > /dev/null 2>&1
sendemail -f 'noreply@dest.com' -t 'dest@dest.com' -s '10.10.10.10' -u "Alert: Root Access on `hostname` from $UZR" -m "at `date`" > /dev/null 2>&1
fi
@D4R4
D4R4 / loginctl.sh
Created November 15, 2021 10:50
Unlock gnome sessions which sometimes become stuck at login screen
loginctl unlock-session [id], where [id] is the session id you get by typing loginctl list-sessions
@D4R4
D4R4 / 365_exchange_group.ps1
Created October 29, 2021 12:02
Make O365 group created in Teams appear in user's Exchange Groups tab
Set-UnifiedGroup -Identity "SCALINX Digital Team" -HiddenFromExchangeClientsEnabled:$false
@D4R4
D4R4 / recover_stuck_process.sh
Created October 25, 2021 18:20
Recover process with stuck fd call, from superuser.blog
# Find process information
ps aux | grep <name>
strace -p <pid>
ls -l /proc//fd
lrwx-- 1 sanket sanket 64 Feb 5 23:00 0 ->; /dev/pts/19
lrwx-- 1 sanket sanket 64 Feb 5 23:00 1 ->; /dev/pts/19
lrwx-- 1 sanket sanket 64 Feb 5 22:59 2 ->; /dev/pts/19
...
lrwx-- 1 sanket sanket 64 Feb 5 23:00 11 -> socket:[102286]