Skip to content

Instantly share code, notes, and snippets.

@vazhnov
vazhnov / remove_oldest_files.sh
Last active February 2, 2022 06:22
Remove oldest .tgz files, if free space less than 50GB
#!/usr/bin/env bash
# set -o nounset
set -o errexit
shopt -s dotglob
# Remove oldest .tgz files, if free space less than 50GB
#
# License: CC0 1.0 or newer
# https://creativecommons.org/publicdomain/zero/1.0/
#
@luckydev
luckydev / gist:b2a6ebe793aeacf50ff15331fb3b519d
Last active October 22, 2022 14:03
Increate max no of open files limit in Ubuntu 16.04/18.04 for Nginx
# maximum capability of system
user@ubuntu:~$ cat /proc/sys/fs/file-max
708444
# available limit
user@ubuntu:~$ ulimit -n
1024
# To increase the available limit to say 200000
user@ubuntu:~$ sudo vim /etc/sysctl.conf
@v-jacob
v-jacob / Mailhog Bash Script (systemd)
Last active January 9, 2023 08:51
Mailhog setup with systemd
#!/usr/bin/env bash
echo ">>> Installing Mailhog"
# Download binary from github
wget --quiet -O ~/mailhog https://github.com/mailhog/MailHog/releases/download/v1.0.0/MailHog_linux_amd64
# Make it executable
chmod +x ~/mailhog
@lachesis
lachesis / letsencrypt_notes.sh
Last active December 13, 2023 11:02
Set up LetsEncrypt using acme.sh without root
# How to use "acme.sh" to set up Lets Encrypt without root permissions
# See https://github.com/Neilpang/acme.sh for more
# This assumes that your website has a webroot at "/var/www/<domain>"
# I'll use the domain "EXAMPLE.com" as an example
# When this is done, there will be an "acme" user that handles issuing,
# updating, and installing certificates. This account will have the following
# (fairly minimal) permissions:
# - Host files at http://EXAMPLE.com/.well-known/acme-challenge
@zerog2k
zerog2k / user_main.c
Last active June 27, 2023 17:50
acurite 5n1 weather station decode over 433 mhz ask rx module on esp8266
/*
// acurite 5n1 weather station (VN1TXC)
// decoding over 433MHz ASK superhet RX module
// on ESP8266 SDK
//
// Jens Jensen, 2015
//
// todo: emit wx packets as json
// todo: add webserver code
*/
@cltnschlosser
cltnschlosser / ctc_timer_interrupts.py
Last active August 29, 2015 14:16
Provide a frequency and this will provide the arduino code needed to create a timer interrupt
def OCR(freq, prescaler):
return (16000000 / (prescaler * freq)) - 1
def HZ(ocr, prescaler):
return (16000000 / (prescaler * (ocr+1)))
def checkBit(data, bit):
return bool(data & (1<<bit))
def checkTimerValid(li):
@bradmontgomery
bradmontgomery / dummy-web-server.py
Last active April 15, 2024 14:27
a minimal http server in python. Responds to GET, HEAD, POST requests, but will fail on anything else.
#!/usr/bin/env python
"""
Very simple HTTP server in python (Updated for Python 3.7)
Usage:
./dummy-web-server.py -h
./dummy-web-server.py -l localhost -p 8000
Send a GET request: