Skip to content

Instantly share code, notes, and snippets.

View flatlinebb's full-sized avatar
🏠
Working from home

flatlinebb

🏠
Working from home
View GitHub Profile
@flatlinebb
flatlinebb / smartcheck.sh
Created November 23, 2018 11:11 — forked from tommybutler/smartcheck.sh
Script to quickly scan the S.M.A.R.T. health status of all your hard drive devices in Linux (at least all the ones from /dev/sda to /dev/sdzz). You need smartctl installed on your system for this script to work, and your hard drives need to have S.M.A.R.T. capabilities (they probably do).
#!/bin/bash
# install the smartctl package first! (apt-get install smartctl)
if sudo true
then
true
else
echo 'Root privileges required'
@flatlinebb
flatlinebb / mpv keyboard shortcuts
Last active January 6, 2024 09:38
mpv keyboard shortcuts
Keyboard Control
LEFT and RIGHT
Seek backward/forward 5 seconds. Shift+arrow does a 1 second exact seek (see --hr-seek).
UP and DOWN
Seek forward/backward 1 minute. Shift+arrow does a 5 second exact seek (see --hr-seek).
Ctrl+LEFT and Ctrl+RIGHT
Seek to the previous/next subtitle. Subject to some restrictions and might not always work; see sub-seek command.
Ctrl+Shift+Left and Ctrl+Shift+Right
Adjust subtitle delay so that the next or previous subtitle is displayed now. This is especially useful to sync subtitles to audio.
[ and ]
@flatlinebb
flatlinebb / system specs in linux
Last active April 22, 2020 19:00
How to view the system specs in linux
How to view the system specs in linux
Open terminal and type sudo dmidecode --type.
Don't click Enter yet! after --type, you can write bios or system, etc. to view the related specs.
For example: sudo dmidecode --type bios will display the BIOS specs.
Complete list of "What can I write after --type" (common parameters are in bold):
Memory
BIOS
System
@flatlinebb
flatlinebb / debian-initial-install.sh
Last active December 23, 2019 02:18
Debian Server Init Script
#!/bin/bash
logfile=/root/$$.log
exec > $logfile 2>&1
# Can be executed remotely with this command:
# curl -L https://gist.githubusercontent.com/flatlinebb/3dea9f4ee2c39ca92ec8bcbd6b0b9a82/raw/f3b63c55d007375bfb4cb10832ff05d6315ce6d8/debian-initial-install.sh | bash
# Get OS details:
lsb_release -a
@flatlinebb
flatlinebb / pulseway-service-check.sh
Last active January 15, 2019 21:21
Checks the Pulseway service and restarts it if not running. Logs to /var/log/pulseway.log
#!/bin/bash
### Pulseway Service Check ###
### Log file location: /var/log/pulseway.log
### Add to crontab for hourly checks at half-past the hour, with no console output:
### 30 * * * * /root/pulseway-service-check.sh > /dev/null 2>&1
### This way, crontab doesn't try to email the result of the job
# Create $variable with the current service status
STATUS=`systemctl show -p SubState --value pulseway`
# For older versions of systemd, skip the "--value"
@flatlinebb
flatlinebb / Misc SMART commands
Last active September 19, 2019 20:45
Enable SMART on all drives. Start short test on all drives. Monitor test on all drives.
To enable SMART on a drive:
for sd in /dev/sd[a-f]; do echo $sd; smartctl --smart=on --offlineauto=on --saveauto=on $sd; done
For drives in USB enclosures, add the -d sat switch:
for sd in /dev/sd[a-z]; do echo $sd; smartctl --smart=on --offlineauto=on --saveauto=on -d sat $sd; done
To get the ERROR rate
for sd in /dev/sd[a-z]; do smartctl -A /dev/sdb | head -7| tail -1; smartctl -A /dev/sdb | grep Error_Rate | grep -v Multi
for sd in /dev/sd[a-e]; do echo $sd; smartctl -a $sd | grep Model ; smartctl -A $sd | head -7| tail -1; smartctl -A $sd | grep Error_Rate | grep -v Multi; done
@flatlinebb
flatlinebb / ipclone.php
Created February 26, 2019 03:37 — forked from otanodesignco/ipclone.php
IP Chicken Clone
<?php
$ip = $_SERVER["REMOTE_ADDR"];
$port = substr($_SERVER["REMOTE_PORT"],0,2);
$browser = $_SERVER["HTTP_USER_AGENT"];
$hostname = gethostbyaddr($ip);
echo $ip;
echo " " . $browser;
echo " " . $hostname;
echo " " . $port;
?>
@flatlinebb
flatlinebb / Documentation.md
Last active March 1, 2019 17:10 — forked from KartikTalwar/Documentation.md
Rsync over SSH - (40MB/s over 1GB NICs)

The fastest remote directory rsync over ssh archival I can muster (40MB/s over 1gb NICs)

This creates an archive that does the following:

rsync (Everyone seems to like -z, but it is much slower for me)

  • a: archive mode - rescursive, preserves owner, preserves permissions, preserves modification times, preserves group, copies symlinks as symlinks, preserves device files.
  • H: preserves hard-links
  • A: preserves ACLs
@flatlinebb
flatlinebb / wget-recursive.txt
Created March 13, 2019 16:09
There is no better utility than wget to recursively download interesting files from the depths of the internet. I will show you why that is the case. From: https://blog.sleeplessbeastie.eu/2017/02/06/how-to-download-files-recursively/
Simply download files recursively. Note, that default maximum depth is set to 5.
$ wget --recursive https://example.org/open-directory/
Download files recursively using defined maximum recursion depth level. It is important to remember that level 0 is equivalent to inf infinite recursion.
$ wget --recursive --level 1 https://example.org/files/presentation/
Download files recursively and specify directory prefix. If not specified then by default files are stored in the current directory.
# PS1 Prompt
tty -s && export PS1="\[\033[38;5;35m\]\t [\[\033[38;5;33m\]\j\[\033[38;5;35m\]] [\h:\[$(tput sgr0)\]\[\033[38;5;33m\]\w\[$(tput setaf 3)\]]\n\\[\033[38;5;35m\]$ \[$(tput sgr0)\]"
# Env
export TERM=xterm-256color
export EDITOR=vim
# Don't add duplicate lines or lines beginning with a space to the history
HISTCONTROL=ignoreboth