Skip to content

Instantly share code, notes, and snippets.

View MrYoda's full-sized avatar

Anton Kuzmichev MrYoda

  • Russia, Moscow
View GitHub Profile
@MrYoda
MrYoda / gist:498b8c248f6c490f26bd1bc4a81506f8
Created January 19, 2017 13:15
Nginx "Ping" via HTTP with CORS and without any files and backends
# 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";
@MrYoda
MrYoda / couch-gateway.site.ru.conf
Created March 15, 2017 09:39
Nginx CouchDB proxy without authentication for safe HTTP methods only, with named location and images 404 fallback
# 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 / views.py
Last active June 16, 2023 05:03
Python 3, Django 1.9+: Excel file creation and send on-the-fly with XlsxWriter & BytesIO
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 / zombie_detect.sh
Last active April 28, 2017 13:25
Bash script for Crontab to detect zombie processes and notify about this via Slack Incoming Webhook
#!/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:'
;;