Skip to content

Instantly share code, notes, and snippets.

View onjin's full-sized avatar

Marek Wywiał onjin

View GitHub Profile
@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 / 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
#############################################################################
# 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 / 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();
#!/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
#!/usr/bin/env python
"""
# nagios configuration
define contact {
contact_name slack
alias Slack
service_notification_period 24x7
host_notification_period 24x7
{
"title": "Syslog",
"services": {
"query": {
"list": {
"0": {
"query": "severity=info",
"alias": "",
"color": "#7EB26D",
"id": 0,
@onjin
onjin / settitle
Created February 19, 2015 08:52
set shell title
#!/bin/bash
echo -ne "\033]0;${1}\007"
import os
import re
import subprocess
from time import sleep
from threading import Thread
import logging
from logging.handlers import RotatingFileHandler
from libqtile.config import Key, Screen, Group, Drag, Click, Match
from libqtile.command import lazy
@onjin
onjin / slackme
Last active June 15, 2018 07:49
Send msgs to slack using incoming webhook
#!/usr/bin/env python
"""
Usage:
using ~/.slackmerc file:
$ slackme some info # with `default` profile
$ slackme --profile alert some info # using `alert` profile
put profile in filename: