Skip to content

Instantly share code, notes, and snippets.

Avatar

Josip Lazić jlazic

  • Croatia
View GitHub Profile
@jlazic
jlazic / decorators.py
Created May 21, 2016
Add HIT/MISS info to headers with Django cache middleware
View decorators.py
from django.views.decorators.cache import decorator_from_middleware_with_args
from django.middleware.cache import CacheMiddleware
class LocalCacheMiddleware(CacheMiddleware):
def process_request(self, request):
response = super(LocalCacheMiddleware, self).process_request(request)
# Add X-Cache: HIT header if response is returned from cache
if response:
response['X-Cache'] = 'HIT'
@jlazic
jlazic / haconfig.sh
Created Mar 9, 2015
Split monolithic HAProxy configuration
View haconfig.sh
#!/bin/bash
#Requirements: etckeeper, diffcolor
#This script concatenates multiple files of haproxy configuration into
#one file, and than checks if monolithic config contains errors. If everything is
#OK with new config script will write new config to $CURRENTCFG and reload haproxy
#Also, script will commit changes to etckeeper, if you don't use etckeeper you
#should start using it.
#Script assumes following directory structure:
#/etc/haproxy/conf.d/
@jlazic
jlazic / Get-HAProxyStats.ps1
Last active Oct 15, 2020
Monitor HAProxy with PRTG
View Get-HAProxyStats.ps1
# Monitoring HAProxy via CSV stats
# For detailed instructions visit http://lazic.info/josip/post/monitor-haproxy-via-prtg/
# Josip Lazic
param(
[string]$url,
[string]$monitor
);
$templates =@{
You can’t perform that action at this time.