Skip to content

Instantly share code, notes, and snippets.

View mamashin's full-sized avatar
🎯
Focusing

Nikolai Mamashin mamashin

🎯
Focusing
View GitHub Profile
@mamashin
mamashin / resize-image-keep-aspect-ratio.py
Created August 9, 2023 15:15 — forked from tomvon/resize-image-keep-aspect-ratio.py
Python script to resize an image while keeping the original aspect ratio.
#Resizes an image and keeps aspect ratio. Set mywidth to the desired with in pixels.
import PIL
from PIL import Image
mywidth = 300
img = Image.open('someimage.jpg')
wpercent = (mywidth/float(img.size[0]))
hsize = int((float(img.size[1])*float(wpercent)))
@mamashin
mamashin / unifi-debian11-install.sh
Created April 5, 2023 10:56 — forked from cloudnull/unifi-debian11-install.sh
Install the latest Unifi Controller on Debian 11
#!/usr/bin/env bash
set -ev
set -o pipefail
# Install dependencies
apt update
apt -y install apt-transport-https ca-certificates wget dirmngr gnupg gnupg2 software-properties-common
# Install old mongo (requried).
@mamashin
mamashin / delete_old_indexes.py
Created March 31, 2023 14:10
Remove Zabbix indexes from Elastic that are older than 1 year (looks like str-2022-02-01)
#!/usr/bin/env python3
from datetime import datetime, timedelta
import requests
import re
ES_HOST = 'http://localhost:9200'
def string_to_date(date_string):
@mamashin
mamashin / my.cnf
Created March 23, 2021 12:48 — forked from fevangelou/my.cnf
Optimized my.cnf configuration for MySQL/MariaSQL (on Ubuntu, CentOS etc. servers)
# === Optimized my.cnf configuration for MySQL/MariaSQL (on Ubuntu, CentOS etc. servers) ===
#
# by Fotis Evangelou, developer of Engintron (engintron.com)
#
# ~ Updated February 2021 ~
#
#
# The settings provided below are a starting point for a 8-16 GB RAM server with 4-8 CPU cores.
# If you have different resources available you should adjust accordingly to save CPU, RAM & disk I/O usage.
#
@mamashin
mamashin / Wait for create dir
Created June 8, 2018 14:28
Wait for create dir
/bin/bash -c 'while [ ! -d /tmp/slurm ]; do /bin/sleep 3; done'
@mamashin
mamashin / gist:afb0e31999b1615428dede37883ef186
Created March 23, 2017 08:15
tcpdump show only HTTP headers
tcpdump -i eth0 -A -s 10240 'tcp port 80 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)' | egrep --line-buffered "^........(GET |HTTP\/|POST |HEAD )|^[A-Za-z0-9-]+: " | sed -r 's/^........(GET |HTTP\/|POST |HEAD )/\n\1/g'
#!/bin/sh
# Alot of these configs have been taken from the various places
# on the web, most from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Set the colours you can use
black='\033[0;30m'
white='\033[0;37m'
red='\033[0;31m'
@mamashin
mamashin / flash_esp8622.sh
Created October 18, 2016 17:29
Blank & flash ESP8266
esptool.py -p /dev/ttyUSB1 -b 115200 chip_id
esptool.py -p /dev/ttyUSB0 -b 115200 write_flash -fs 8m 0x00000 blank1m.bin
esptool.py -p /dev/ttyUSB1 -b 115200 write_flash -fs 8m 0x00000 0x00000_ESP8266_201610061347.bin