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
#!/usr/bin/env python | |
# encoding: utf-8 | |
import sys | |
import os | |
import fcntl | |
import shlex | |
from time import sleep | |
from subprocess import Popen, PIPE |
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
/** | |
@file magic_buffer.c | |
Пример использования библиотеки libmagic. | |
Ниже показано как собирать и тестировать файл: | |
$> gcc magic_buffer.c -lmagic -I/usr/include/magic -Wall -o magic_buffer | |
$>./magic_buffer "asas" 2> errr | |
text/plain | |
$>./magic_buffer "<?xml version="1.0" encoding="utf-8"?><x>абырвалг</x>" | |
application/xml | |
$>./magic_buffer "<?xml" |
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 http://harkablog.com/inside-the-django-orm-aggregates.html | |
with a couple of fixes. | |
Usage: MyModel.objects.all().annotate(new_attribute=Concat('related__attribute', separator=':') | |
""" | |
from django.db.models import Aggregate | |
from django.db.models.sql.aggregates import Aggregate as SQLAggregate |
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
# -*- coding: utf8 -*- | |
# | |
# Graphite log simple parser. | |
# It parse functions and its arguments using python ast-tree. | |
# | |
# For each log line like: | |
# { | |
# 192.168.14.20 [23/Jul/2015:15:44:11 +0100] | |
# "GET /render?from=-4hours&noCache=True&hideLegend=False |
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
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
# http://stackoverflow.com/questions/5574702/how-to-print-to-stderr-in-python | |
from __future__ import print_function | |
import sys | |
def eprint(*args, **kwargs): | |
print(*args, file=sys.stderr, **kwargs) | |
import errno |
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 http://harkablog.com/inside-the-django-orm-aggregates.html | |
with a couple of fixes. | |
Usage: MyModel.objects.all().annotate(new_attribute=GroupConcat('related__attribute', separator=':') | |
""" | |
from django.db.models import Aggregate | |
from django.db.models.sql.aggregates import Aggregate as SQLAggregate |