Skip to content

Instantly share code, notes, and snippets.

Avatar

Anton Kuzmichev MrYoda

View GitHub Profile
@MrYoda
MrYoda / zombie_detect.sh
Last active Apr 28, 2017
Bash script for Crontab to detect zombie processes and notify about this via Slack Incoming Webhook
View zombie_detect.sh
#!/bin/bash
function post_to_slack () {
SLACK_MESSAGE="$1"
SLACK_URL=https://hooks.slack.com/services/YOUR_WEBHOOK_TOKENS_HERE
case "$2" in
INFO)
SLACK_ICON=':slack:'
;;
@MrYoda
MrYoda / views.py
Last active Aug 10, 2020
Python 3, Django 1.9+: Excel file creation and send on-the-fly with XlsxWriter & BytesIO
View views.py
import xlsxwriter
from io import BytesIO
from django.http import StreamingHttpResponse
from django.views.generic import View
def get_foo_table_data():
"""
Some table data
"""
@MrYoda
MrYoda / couch-gateway.site.ru.conf
Created Mar 15, 2017
Nginx CouchDB proxy without authentication for safe HTTP methods only, with named location and images 404 fallback
View couch-gateway.site.ru.conf
# HTTP server: Enforce HTTPS by HTTP 301
server {
listen 80;
listen [::]:80 ipv6only=on;
server_name couch-gateway.site.ru;
return 301 https://$server_name$request_uri;
}
# SSL server
@MrYoda
MrYoda / gist:498b8c248f6c490f26bd1bc4a81506f8
Created Jan 19, 2017
Nginx "Ping" via HTTP with CORS and without any files and backends
View gist:498b8c248f6c490f26bd1bc4a81506f8
# Ping location
location /ping {
add_header "Allow" "GET, OPTIONS, HEAD" always;
# CORS headers
add_header "Access-Control-Allow-Origin" "*";
add_header "Access-Control-Allow-Methods" "GET, OPTIONS, HEAD";
add_header "Access-Control-Allow-Headers" "Accept,Accept-Encoding,Cache-Control,Content-Type,DNT,If-Modified-Since,Origin,User-Agent,X-Requested-With";
if ( $request_method !~ ^(GET|OPTIONS|HEAD)$ ) {
return 405 "Only GET, OPTIONS, HEAD allowed";