This file contains hidden or 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 bash | |
| # | |
| # getopts_long -- POSIX shell getopts with GNU-style long option support | |
| # | |
| # Copyright 2005-2009 Stephane Chazelas <[email protected]> | |
| # | |
| # Permission to use, copy, modify, distribute, and sell this software and | |
| # its documentation for any purpose is hereby granted without fee, provided | |
| # that the above copyright notice appear in all copies and that both that |
This file contains hidden or 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 | |
| # https://en.wikipedia.org/wiki/Percent-encoding | |
| # https://stackoverflow.com/questions/38015239/url-encoding-a-string-in-shell-script-in-a-portable-way | |
| # https://www.gnu.org/software/gettext/manual/html_node/The-LANGUAGE-variable.html#The-LANGUAGE-variable | |
| # "The variable LANGUAGE is ignored if the locale is set to ‘C’" | |
| # Not entirely sure why this is done to be honest | |
| LANG=C; |
This file contains hidden or 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 |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |