Skip to content

Instantly share code, notes, and snippets.

@piotr-dobrogost
piotr-dobrogost / custom-log-filtering-and-formatting.py
Created Jan 21, 2019 — forked from acdha/custom-log-filtering-and-formatting.py
Example of how to filter or apply custom formatting using Python's logging library
View custom-log-filtering-and-formatting.py
#!/usr/bin/env python
# encoding: utf-8
from pprint import pformat, pprint
import logging
class PasswordMaskingFilter(logging.Filter):
"""Demonstrate how to filter sensitive data:"""
View angularjs_directive_attribute_explanation.md

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 Oct 18, 2017 — forked from thisismitch/dropbox
Dropbox systemd and init files (CentOS 7)
View dropbox
#!/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 Jul 18, 2017
Set of scripts to manage ethereum miner ethminer.
View mine
#!/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 Jun 28, 2017 — forked from afair/tmux.cheat
Tmux Quick Reference & Cheat sheet - 2 column format for less scrolling!
View tmux.cheat
========================================== ==========================================
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 &
View Call stack while executing line 519 of result.py (run for the first time ever, during app startup)
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)
View gist:225f9a4ac9a1a647b24698454dc7a48a
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 Mar 23, 2016
Starting OpenVPN directly vs as a service
View \etc\openvpn\xxx.conf
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 Feb 23, 2016
SQLAlchemy AssertionError: Dependency rule tried to blank-out primary key column
View code
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 Nov 6, 2015
Interaction between overrides and translations in Pyramid – difference with and without config.begin()
View app:__init__.py
from pyramid.config import Configurator
config = Configurator()
config.begin()
config.override_asset('framework', 'app:framework-overrides/')
config.commit()
config.add_translation_dirs('framework:locale')