This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=Redis In-Memory Data Store | |
After=network.target | |
[Service] | |
User=redis | |
Group=redis | |
ExecStart=/usr/local/bin/redis-server /db/redis.conf | |
ExecStop=/usr/local/bin/redis-cli shutdown | |
Restart=always |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
sysctl vm.overcommit_memory=1 | |
sysctl -w net.core.somaxconn=65535 | |
echo never > /sys/kernel/mm/transparent_hugepage/enabled | |
echo never > /sys/kernel/mm/transparent_hugepage/defrag | |
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=/etc/rc.local Compatibility | |
ConditionPathExists=/etc/rc.local | |
[Service] | |
Type=forking | |
ExecStart=/etc/rc.local start | |
TimeoutSec=0 | |
StandardOutput=tty | |
RemainAfterExit=yes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
################################## MODULES ##################################### | |
loadmodule /db/modules/libredis-roaring.so | |
loadmodule /db/modules/rejson.so | |
loadmodule /db/modules/redisearch.so | |
################################## NETWORK ##################################### | |
bind 127.0.0.1 | |
protected-mode yes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#make directories | |
mkdir /git | |
mkdir /db | |
mkdir /db/modules | |
mkdir /downloads | |
#update packages, install gcc and redis | |
add-apt-repository ppa:chris-lea/redis-server -y && \ | |
apt-get update && \ | |
apt-get upgrade -y && \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Example extension of RotatingFileHandler that LZMA compresses the rotated files | |
Other examples I found didn't actually respect maxBackups, this does | |
- AG | |
""" | |
import codecs | |
import glob | |
import logging.handlers | |
import os |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import yaml | |
import logging.config | |
import logging | |
import coloredlogs | |
def setup_logging(default_path='logging.yaml', default_level=logging.INFO, env_key='LOG_CFG'): | |
""" | |
| **@author:** Prathyush SP | |
| Logging Setup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from cachetools import cached | |
from cachetools.keys import hashkey | |
from random import randint | |
@cached(cache={}, key=lambda db_handle, query: hashkey(query)) | |
@cached(cache={}, key=lambda db_handle, query: hashkey(query)) | |
def find_object(db_handle, query): | |
saved = query | |
query = 5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Enumerate and export a bunch of structured or scalar objects from a Python module to YaML | |
This enumerates everything in the module in the globals namespace automatically, skipping | |
a few things (like things starting with `__`) | |
Useful when you have a ton of constants (including some that are lists, tuples, dicts, etc) in a | |
Python module and you want to put them into YaML to maintain separately from the Python code. It's | |
not a difficult task, but it becomes painful when there are 10-20 (or more) different objects. This | |
just automates it |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# WARNING: YOU WILL LOSE THE FILE IF YOU SCREW UP BE CAREFUL | |
# If UNSAFE is set to YES, no backup will occur; you better not screw up! | |
# grep args or pattern because your file will be gone :> | |
# | |
# - AG | |
set -Eu | |
declare -r UNSAFE=YES |