Skip to content

Instantly share code, notes, and snippets.

View brunneis's full-sized avatar

Rodrigo Martínez brunneis

View GitHub Profile
@brunneis
brunneis / umount-ancoris-devices.sh
Last active February 15, 2018 12:31
Umount all ancoris devices mounted under $PARENT_MOUNT_PATH path
# Umount all loop devices mounted under PARENT_MOUNT_PATH path
PARENT_MOUNT_PATH="/mnt/ancoris"
# loop devices
sudo umount $(df | grep /dev/loop | grep $PARENT_MOUNT_PATH | awk '{print $1}')
# tmpfs
sudo umount $(df | grep tmpfs_ | grep $PARENT_MOUNT_PATH | awk '{print $1}')
@brunneis
brunneis / docker-bidirectional-mount.sh
Last active January 9, 2018 17:25
How to launch a Docker container where both the host and the container can share mounted volumes (i.e., loop devices) in a bound path. Share hotplug volumes with Docker.
#!/bin/bash
docker run -ti -v "$(pwd)"/shared_dir:/mnt/shared_dir:rw,shared --privileged ubuntu
@brunneis
brunneis / recover-html-from-cache-chrome.md
Last active January 18, 2018 19:07
Recover an html file from Chrome's cache

Do not load the target page until proceed

  1. Go to chrome://view-http-cache/
  2. Open the document you want to restore
  3. Copy the buffer from the second block of hex data to a file (input.txt)
  4. Execute the following command:

xxd -r < input.txt > output.html

@brunneis
brunneis / delete-files-containing-string.sh
Created January 18, 2018 19:03
Delete all files containing a string (for files with very long lines)
#!/bin/bash
SEARCH_PATH="."
MAX_CHARS_PER_FILENAME=50
grep -r "string" $SEARCH_PATH | cut -c 1-$MAX_CHARS_PER_FILENAME | cut -d ':' -f 1 | xargs rm
@brunneis
brunneis / deepin-aerospike-python-client-pip.md
Last active November 4, 2019 09:39
Install Aerospike Python client through pip in Deepin Linux 15.5
  1. Temporarily change the following properties at /etc/os-release

    • VERSION_ID="9"
    • ID=debian
  2. Execute pip install aerospike


Other fixes:

@brunneis
brunneis / fix-lightdm-deepin.sh
Last active April 16, 2021 16:48
LightDM won't start (Deepin Linux)
#!/bin/bash
dpkg-reconfigure xserver-xorg
sudo apt-get purge lightdm
sudo apt-get install lightdm-gtk-greeter
sudo apt-get install lightdm
@brunneis
brunneis / overlay2-centos.md
Last active July 8, 2021 14:05
Change storage driver to overlay2 on CentOS
  1. systemctl stop docker
  2. Create the file /etc/docker/daemon.json with the following content:
{
  "storage-driver": "overlay2",
  "storage-opts": ["overlay2.override_kernel_check=true"]
}
  1. systemctl start docker
@brunneis
brunneis / disable-internal-speaker.sh
Last active February 5, 2018 08:03
Disable motherboard's speaker sound (beep)
#!/bin/bash
# Temporary fix
sudo rmmod -v pcspkr
# Permanent fix
echo "blacklist pcspkr" >> /etc/modprobe.d/blacklist.conf
update-initramfs -u
# reboot
@brunneis
brunneis / remove-dangling-volumes.sh
Created February 12, 2018 11:26
Remove dangling Docker volumes
#!/bin/bash
docker volume rm $(docker volume ls -q -f dangling=true)
@brunneis
brunneis / secure-erase.sh
Created February 16, 2018 22:54
Secure erase (overwrite all the blocks on the device with random data three times)
#!/bin/bash
DEVICE_ID=/dev/sdx
shred -v $DEVICE_ID