Skip to content

Instantly share code, notes, and snippets.

View dragolabs's full-sized avatar

Vitaly Shishlyannikov dragolabs

View GitHub Profile
@dragolabs
dragolabs / ubuntu-vnc-without-monitor.md
Created April 29, 2020 20:09
Run VNC without connected monitor to ubuntu Desktop

Install Video Dummy Package

sudo apt-get install xserver-xorg-video-dummy

Create Default X Windows Configuration File

Create / Edit xorg.conf file Rename file if already exists for backup

@dragolabs
dragolabs / smbd.conf
Created April 29, 2020 13:10
Samba configuration with Apple Time Machine support
[global]
workgroup = WORKGROUP
min protocol = SMB3_00
server string = %h server (Samba, Ubuntu)
server role = standalone server
log file = /var/log/samba/log.%m

This is how to remove unused kernels

One line command

sudo dpkg --list 'linux-image*' | awk '{ if ($1=="ii") print $2}'| grep -v $(uname -r) | while read -r line; do sudo apt-get -y purge $line; done; sudo apt-get autoremove; sudo update-grub
#!/bin/sh
# install docker
sudo apt-get update
sudo apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
#!/bin/sh
# install pyenv
sudo apt-get update
sudo apt-get install make build-essential libssl-dev zlib1g-dev libbz2-dev \
libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev \
xz-utils tk-dev libffi-dev liblzma-dev python-openssl git
cd ~ || exit
# Set up AWS CLI, we don't use Amazon Linux so we need this
export AWS_REGION=$(curl -s http://169.254.169.254/latest/dynamic/instance-identity/document | grep region | awk -F\" '{print $4}')
mkdir -p /root/.aws
echo -e "[default]\nregion=$AWS_REGION" | tee /root/.aws/config
# Get tags from the API
export FQDN=$(aws ec2 describe-tags --filters "Name=resource-id,Values=$(curl -s http://169.254.169.254/latest/meta-data/instance-id)" "Name=key,Values=fqdn" --output=text | cut -f 5)
# Set hostname
if [ -n "$FQDN" ]; then
@dragolabs
dragolabs / responses.clj
Created April 22, 2019 21:32 — forked from mtnygard/responses.clj
Build Pedestal response maps for every standard HTTP status code.
(defn response
([status body]
{:status status
:headers {}
:body body}))
(defmacro http-status [code sym]
`(def ~sym (partial response ~code)))
(defmacro http-statuses [& pairs]
@dragolabs
dragolabs / diff-text.sh
Created April 10, 2019 16:06
diff text or variables without files
# diff the string "foo" with the string "baz"
diff <(echo foo) <(echo bar)
@dragolabs
dragolabs / pid2docker.sh
Created April 9, 2019 11:57
Find docker container from host PID
#!/bin/bash -e
# Prints the name of the container inside which the process with a PID on the host is.
# https://stackoverflow.com/a/42009937
function getName {
local pid="$1"
if [[ -z "$pid" ]]; then
echo "Missing host PID argument."
exit 1
@dragolabs
dragolabs / nginx-print-servernames.md
Last active January 17, 2019 11:08
Show all server_names from nginx configuration
nginx -T 2>/dev/null | \
sed -r -e 's/[ \t]*$//' -e 's/^[ \t]*//' -e 's/^#.*$//' -e 's/[ \t]*#.*$//' -e '/^$/d' | \
sed -e ':a;N;$!ba;s/\([^;\{\}]\)\n/\1 /g' | \
grep -P 'server_name[ \t]' | grep -v '\$' | \
grep '\.' | \
sed -r -e 's/(\S)[ \t]+(\S)/\1\n\2/g' -e 's/[\t ]//g' -e 's/;//' -e 's/server_name//' | \
sort | uniq | xargs -L1