Skip to content

Instantly share code, notes, and snippets.

@piotr-dobrogost
piotr-dobrogost / custom-log-filtering-and-formatting.py
Created January 21, 2019 14:31 — forked from acdha/custom-log-filtering-and-formatting.py
Example of how to filter or apply custom formatting using Python's logging library
#!/usr/bin/env python
# encoding: utf-8
from pprint import pformat, pprint
import logging
class PasswordMaskingFilter(logging.Filter):
"""Demonstrate how to filter sensitive data:"""
@piotr-dobrogost
piotr-dobrogost / angularjs_directive_attribute_explanation.md
Created January 16, 2019 08:24 — forked from CMCDragonkai/angularjs_directive_attribute_explanation.md
JS: AngularJS Directive Attribute Binding Explanation

AngularJS Directive Attribute Binding Explanation

When using directives, you often need to pass parameters to the directive. This can be done in several ways. The first 3 can be used whether scope is true or false. This is still a WIP, so validate for yourself.

  1. Raw Attribute Strings

    <div my-directive="some string" another-param="another string"></div>
@piotr-dobrogost
piotr-dobrogost / dropbox
Created October 18, 2017 20:35 — forked from thisismitch/dropbox
Dropbox systemd and init files (CentOS 7)
#!/bin/sh
# To configure, add line with DROPBOX_USERS="user1 user2" to /etc/sysconfig/dropbox
# Probably should use a dropbox group in /etc/groups instead.
# Source function library.
. /etc/rc.d/init.d/functions
prog=dropboxd
lockfile=${LOCKFILE-/var/lock/subsys/$prog}
@piotr-dobrogost
piotr-dobrogost / mine
Created July 18, 2017 09:35
Set of scripts to manage ethereum miner ethminer.
#!/bin/bash
export DISPLAY=:0
sudo nvidia-smi -pl 108
tmux \
set-option -g remain-on-exit on \; \
new-session -A -s ethminer "mining-oc && ethminer -SP 2 -U -S daggerhashimoto.eu.nicehash.com:3353 -O <address>:<miner>" \; \
split-window "mining-stats" \; \
@piotr-dobrogost
piotr-dobrogost / tmux.cheat
Created June 28, 2017 06:21 — forked from afair/tmux.cheat
Tmux Quick Reference & Cheat sheet - 2 column format for less scrolling!
========================================== ==========================================
TMUX COMMAND WINDOW (TAB)
========================================== ==========================================
List tmux ls List ^b w
New -s <session> Create ^b c
Attach att -t <session> Rename ^b , <name>
Rename rename-session -t <old> <new> Last ^b l (lower-L)
Kill kill-session -t <session> Close ^b &
File "/opt/pycharm/pycharm-2016.1.2/helpers/pydev/pydevd.py", line 1531, in <module>
globals = debugger.run(setup['file'], None, None, is_module)
File "/opt/pycharm/pycharm-2016.1.2/helpers/pydev/pydevd.py", line 938, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "/opt/pycharm/pycharm-2016.1.2/helpers/pycharm/pycharm_load_entry_point.py", line 12, in <module>
sys.exit(f())
File "/home/piotr/.virtualenvs/kotti/lib/python2.7/site-packages/pyramid/scripts/pserve.py", line 60, in main
return command.run()
File "/home/piotr/.virtualenvs/kotti/lib/python2.7/site-packages/pyramid/scripts/pserve.py", line 367, in run
global_conf=vars)
@piotr-dobrogost
piotr-dobrogost / gist:225f9a4ac9a1a647b24698454dc7a48a
Created April 11, 2016 12:46
Normalize python package's version
pip install packaging > /dev/null && python -c 'import sys,packaging.version; print(str(packaging.version.parse(sys.argv[1])))' '1.x.x'
@piotr-dobrogost
piotr-dobrogost / \etc\openvpn\xxx.conf
Last active March 23, 2016 20:17
Starting OpenVPN directly vs as a service
client
dev tun
proto udp
remote x.x.x.x 1194
remote y.y.y.y 1194
resolv-retry infinite
nobind
@piotr-dobrogost
piotr-dobrogost / code
Last active February 23, 2016 15:29
SQLAlchemy AssertionError: Dependency rule tried to blank-out primary key column
from sqlalchemy import create_engine
from sqlalchemy import Column, ForeignKey, Integer, String, Unicode, UniqueConstraint
from sqlalchemy.ext.associationproxy import association_proxy
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship, sessionmaker
from sqlalchemy.orm.collections import attribute_mapped_collection
Base = declarative_base()
@piotr-dobrogost
piotr-dobrogost / app:__init__.py
Created November 6, 2015 14:42
Interaction between overrides and translations in Pyramid – difference with and without config.begin()
from pyramid.config import Configurator
config = Configurator()
config.begin()
config.override_asset('framework', 'app:framework-overrides/')
config.commit()
config.add_translation_dirs('framework:locale')