Skip to content

Instantly share code, notes, and snippets.

View heyalexej's full-sized avatar

Alexej heyalexej

  • rather hard to pin down
View GitHub Profile

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@heyalexej
heyalexej / permissions.sh
Last active September 12, 2018 16:27
Fix WordPress File Permission
#!/bin/bash -ex
#
# configures wordpress file permissions based on recommendations
# from http://codex.wordpress.org/Hardening_WordPress#File_permissions
#
# script is aware of .git directories by default. edit if you need to consider
# other folders as well.
#
# you will find a log file in /tmp/ in case you fucked up.
@heyalexej
heyalexej / dpkgdump.sh
Created April 27, 2014 22:08
Log Of All Installed .deb Packages
#!/bin/bash -e
# dpkgdump.sh
# creates text file with a list of all packages installed by date
TMP0=`mktemp "${TMPDIR:-/tmp}"/dpkgdump.col.XXXXXXXXXX`
TMP1=`mktemp "${TMPDIR:-/tmp}"/dpkgdump.res.XXXXXXXXXX`
# next append current log
find /var/log -maxdepth 1 -type f -regex ".*\dpkg\.log\.[0-9].gz$" | xargs zcat > $TMP0
@heyalexej
heyalexej / zipuproot.sh
Created May 3, 2014 12:44
zips up your entire machine from root, considers excludes
#!/bin/sh
DATE=`date +%Y-%m-%d-d%`
ARCH=`uname -m`
HOSTNAME=`uname -n`
ROOTFS_TYPE=`df -T / | awk '{print $2}' | grep -v "Type"`
BACKUP_PATH=`pwd`
STAGE5NAME="backup-${ARCH}-${ROOTFS_TYPE}-${HOSTNAME}-${DATE}.tar.gz"
cd /;
I've noticed on several occasions that even people who work on a computer a lot don't know about the Shell (a.k.a Terminal) on their machines.
The Shell is an incredibly powerful tool that can help you with a lot of tasks and operations in your everyday life. It can drastically improve your productivity, you can manage servers from it, crunch huge amounts of data (searching, sorting, filtering, replacing), it allows you to automate annoying tasks and so much more.
I experience a lot of confusion and insecurities about it's use. It's not remotely as scary as people perceive it to be. And that's where I want to help.
They say learning through experience is the best way to go about it. I want to invite you to an interactive workshop to play with the command line and learn some basics to get your way around it. Afterwards you will be able to incorporate it's use into your workflow.
This session is not for hackers and developers only. I invite everyone who is curious about it and wants to feel like a ninja.
@heyalexej
heyalexej / backup-website.sh
Last active July 19, 2016 13:21
Back up WordPress + MySql + logs + Apache configs
#!/bin/bash
set -e
# VARIABLES
current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
project=`uname -n`
backup_dir=`mktemp -d "${TMPDIR:-/tmp}"/${project}.backup.XXXX`
today=`date +'%Y-%m-%d'`
at="at `echo $(date)`"
backup_log=/var/log/backup-website.log
vim updater.bash
bash updater.bash
vim updater.bash
apt-cache search gem
sudo gem install -V lolcat
cowthink heyhey
sudo apt-get install fortune
fortune
man fortune
fortune -o
@heyalexej
heyalexej / cidr-to-ip.py
Created June 20, 2014 06:18
Quick and dirty solution to translate IPv4 and IPv6 CIDR blocks into a list of IPs for further digestion.
#!/usr/bin/env python3
# Translates IPv4/6 CIDR blocks into a list of IPs and writes
# them into a text file. Requires netaddr (pip install netaddr).
import netaddr
ip_list = netaddr.IPNetwork('192.168.1.0/21')
with open('ips-from-cidr.txt', 'w') as f:
for ip in ip_list: