Skip to content

Instantly share code, notes, and snippets.

Avatar
🤔
excuse me, is this facebook

Piotr Dobrowolski Informatic

🤔
excuse me, is this facebook
View GitHub Profile
@Informatic
Informatic / gziplogging.py
Last active Oct 23, 2020
python logging rotating gzipping handler
View gziplogging.py
#
# A quick tip on how to set up rotating logging handler with
# automatic gzipping of rotated files. Tested on python 3.7
#
#
# Testing tip:
# python gziplogging.py
# touch example.log --date='2005/01/01'
# python gziplogging.py
# ls -lah *.log*
View gist:a90116c9402eb11d111790e3b5e88cf1
function render_layout($body) {
?>
<html>
<head></head>
<body><?php call_user_func($body) ?></body>
</html>
<?php
}
View gist:1a3e2b4b21602e5d79cf03d3c896f8e9
request_route {
if($si == "185.236.240.59") {
xlog("Received $rm to $ru - Forwarding to phone\n");
forward();
} else {
xlog("Received $rm to $ru - Forwarding to hscloud\n");
forward("185.236.240.59");
}
}
View gist:94b5248801bbbaacaa9a4f8158a9d076
fields = [
'NAZWA NADAWCY', 'OSOBA KONTAKTOWA NADAWCA',
'TELEFON KONTAKTOWY NADAWCA ', 'ULICA NADAWCA',
'KOD POCZTOWY NADAWCA', 'MIASTO NADAWCA',
'NAZWA ODBIORCA', 'OSOBA KONTAKTOWA ODBIORCA',
'TELEFON KONTAKTOWYODBIORCA', 'ULICA ODBIORCA',
'KOD POCZTOWY ODBIORCA', 'MIASTO ODBIORCA',
'WAGA', 'ILOŚĆ PACZEK', 'NUMKAT', 'NEXT DAY', 'SOBOTA',
View gist:c2442b33ed92ba54cfe3313fb8ab5ef3
def prepare_webrtc(self):
admin_key = app.config['JANUS_STREAMING_ADMIN_KEY']
janus = get_janus()
handle = janus.acquire_plugin('janus.plugin.streaming')
info = janus.plugin_call(handle, {
'request': 'info',
'id': self.webrtc_port,
'secret': admin_key,
})
@Informatic
Informatic / tagify-cookbook
Created Aug 5, 2019
Quickly add git version tags for specified chef cookbook (could easily be adapted to any other piece of infrastructure, eg. npm package.json file, as long as one is able to extract unique version identifier on specified git ref)
View tagify-cookbook
#!/usr/bin/env bash
# Creates local version tags based on cookbook metadata.rb change history
# Usage: bash tagify-cookbook [cookbook_name]
cookbook=${1:-some_cookbook}
git log --pretty=format:"%h" cookbooks/$cookbook/metadata.rb | while read ref; do
tag="$cookbook-$(git show $ref:cookbooks/$cookbook/metadata.rb | grep "^version '" | sed -E "s/.* '(.*)'/\1/g" )"
echo "ref: $ref -> $tag";
View ipmiview.nix
{ stdenv, fetchurl, patchelf, makeWrapper, xorg, gcc, gcc-unwrapped, freetype, fontconfig, liberation_ttf }:
stdenv.mkDerivation rec {
name = "IPMIView-${version}";
version = "2.16.0";
buildVersion = "190528";
src = fetchurl {
url = "https://www.supermicro.com/wftp/utility/IPMIView/Linux/IPMIView_${version}_build.${buildVersion}_bundleJRE_Linux_x64.tar.gz";
sha256 = "0pz4q8vsnv6wqpiy6am333c2cgsdjmxc6w9vm4hi8qyaavfbq0w2";
View chromium-vaapi.nix
{ config, pkgs, lib, ... }:
let
unstableTarball =
fetchTarball
https://github.com/NixOS/nixpkgs/archive/2b822dce2f88906036664dc2c4f6c3540bd941ad.tar.gz;
in
{
nixpkgs.config = {
packageOverrides = pkgs: {
@Informatic
Informatic / janus.py
Last active Mar 24, 2019
Minimal janus-gateway REST API python client
View janus.py
# Reference:
# https://janus.conf.meetecho.com/docs/rest.html
# https://janus.conf.meetecho.com/docs/streaming.html
import requests
import json
import pprint
import random
import string
@Informatic
Informatic / network.nix
Created Jan 20, 2019
NixOS OVH IP Failover virtual machine configuration
View network.nix
{
# [...]
# Assuming failover IP being 1.2.3.4 and host primary IP being 5.6.7.8
networking.interfaces.ens3.ipv4.addresses = [ {
address = "1.2.3.4";
prefixLength = 32;
} ];
networking.interfaces.ens3.ipv4.routes = [ {
address = "5.6.7.254";
You can’t perform that action at this time.