Skip to content

Instantly share code, notes, and snippets.

View onjin's full-sized avatar

Marek Wywiał onjin

View GitHub Profile
@onjin
onjin / settitle
Created February 19, 2015 08:52
set shell title
#!/bin/bash
echo -ne "\033]0;${1}\007"
{
"title": "Syslog",
"services": {
"query": {
"list": {
"0": {
"query": "severity=info",
"alias": "",
"color": "#7EB26D",
"id": 0,
#!/usr/bin/env python
"""
# nagios configuration
define contact {
contact_name slack
alias Slack
service_notification_period 24x7
host_notification_period 24x7
#!/usr/bin/env python
# encoding: utf-8
"""
$ ./export_confulence_space.py -l http://wiki.some.com -u username -p password -s SPACEKEY
$ ./export_confulence_space.py -l http://wiki.some.com -u username -p password -a # all spaces available for given user
"""
import os
@onjin
onjin / auto_notify.sql
Last active December 14, 2015 11:14
pubsub using postgres listen/notify
CREATE OR REPLACE FUNCTION object_notify() RETURNS trigger AS $$
DECLARE
BEGIN
PERFORM pg_notify('object_updated',CAST(NEW.id AS text));
RETURN NEW;
END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER object_post_insert_notify AFTER UPDATE ON objects FOR EACH ROW EXECUTE PROCEDURE object_notify();
#############################################################################
# Configuration file for Let's Encrypt ACME Challenge location
# This file is already included in listen_xxx.conf files.
# Do NOT include it separately!
#############################################################################
#
# This config enables to access /.well-known/acme-challenge/xxxxxxxxxxx
# on all our sites (HTTP), including all subdomains.
# This is required by ACME Challenge (webroot authentication).
# You can check that this location is working by placing ping.txt here:
@onjin
onjin / list_all_nginx_virtual_hosts.sh
Created February 23, 2016 08:06
list all running nginx virtual hosts on docker created using https://github.com/jwilder/nginx-proxy
# list all running nginx virtual hosts on docker created using
# `https://github.com/jwilder/nginx-proxy`
docker inspect --format '{{ index (index .Config.Env) 1 }}' $(docker ps -q) | grep VIRTUAL_HOST | cut -d\= -f 2
@onjin
onjin / money.py
Created July 20, 2016 11:43 — forked from justanr/money.py
Example of a small value object representing money.
import decimal
from functools import total_ordering
from numbers import Real
class Context(object):
def __init__(self, **kwargs):
self.context = decimal.Context(**kwargs)
def __enter__(self):
with decimal.localcontext(self.context) as c:
@onjin
onjin / _core.py
Created July 21, 2016 06:33 — forked from justanr/_core.py
Clean Architecture In Python
from abc import ABC, ABCMeta, abstractmethod
from collections import namedtuple
from itertools import count
PayloadFactory = namedtuple('PayloadFactory', [
'good', 'created', 'queued', 'unchanged', 'requires_auth',
'permission_denied', 'not_found', 'invalid', 'error'
])
"""
@onjin
onjin / secrets.py
Created August 4, 2016 07:43
python 3.6 secrets module
"""Generate cryptographically strong pseudo-random numbers suitable for
managing secrets such as account authentication, tokens, and similar.
See PEP 506 for more information.
https://www.python.org/dev/peps/pep-0506/
"""
__all__ = ['choice', 'randbelow', 'randbits', 'SystemRandom',
'token_bytes', 'token_hex', 'token_urlsafe',