Skip to content

Instantly share code, notes, and snippets.

in order to override the graypy version number, you need to use a filter which takes in the record... then override the version attribute:
def filter(self, record):
added_fields = dict(record.args)
record.version = APP_VERSION # dynamically generated at module level
record.company_name = added_fields.get('company_name', None)
# add whatever data fields here we want to search by
# record.does_not_exist = "DOES NOT EXIST TEST"
return True
@chrcoe
chrcoe / gist:92c388a98774d66bb6a8
Last active August 29, 2015 14:18
Lenovo X1C fixes
iwlwifi disable 802.11n to allow 100% uptime with wifi::
sudo echo "options iwlwifi 11n_disable=1" > /etc/modprobe.d/iwlwifi-disable11n.conf
to fix the trackpad (need to use kernel 4 to allow buttons to act as expected) will still need to change the scrolling functionality:
add the following to: /etc/X11/xorg.conf.d/20-trackpad.conf
Section "InputClass"
found this at Leo's blog: http://techblog.leosoto.com/django-secretkey-generation/
$ python -c 'import random; import string; print "".join([random.SystemRandom().choice(string.digits + string.letters + string.punctuation) for i in range(100)])'
@chrcoe
chrcoe / troubleshoointg_selinux
Last active August 29, 2015 14:08
Troubleshooting Steps for SELinux
Troubleshooting Steps for SELinux (presented by Carl Miller at OLF 2015: http://carltm.com
This is only a portion of the presentation, all credit goes to Carl, thanks Carl!
$ sudo wc -l < /var/log/audit/audit.log
$ sudo setenforce permissive
run the command(s) that failed
@chrcoe
chrcoe / sample-pickling
Created September 10, 2014 15:46
Shows sample pickling operations using normal file, tempfile and in memory.
import pickle
import math
import tempfile
import os
# write
def writePickle(outputFile):
'''
Takes in a filename to use and saves the pickle to that
specific location. Stores pickle in a file on the system
@chrcoe
chrcoe / copy ssh
Last active August 29, 2015 14:05
copy ssh pubkey to server on one line, found this @http://www.davidgrant.ca/copy_ssh_public_key_to_server_in_one_line I got tired of trying to find the link every time
cat ~/.ssh/id_dsa.pub | ssh user@hostname "cat - >> ~/.ssh/authorized_keys"
alternative:
ssh user@hostname "echo `cat ~/.ssh/id_dsa.pub` >> ~/.ssh/authorized_keys"
here is another alternative I use on new servers (that don't already have an ~/.ssh directory:
cat ~/.ssh/id_dsa.pub | ssh user@hostname "mkdir ~/.ssh/; cat - >> ~/.ssh/authorized_keys"
*OR*
ssh user@hostname "mkdir ~/.ssh/; echo `cat ~/.ssh/id_dsa.pub` >> ~/.ssh/authorized_keys"
@chrcoe
chrcoe / centos_python_env_setup
Created July 31, 2014 12:26 — forked from floer32/centos_python_env_setup
this is useful information but a bit outdated now
#!/bin/bash
# Source: http://toomuchdata.com/2012/06/25/how-to-install-python-2-7-3-on-centos-6-2/
# Install stuff #
#################
# Install development tools and some misc. necessary packages
yum -y groupinstall "Development tools"
yum -y install zlib-devel # gen'l reqs
@chrcoe
chrcoe / testMultiArgs.py
Created July 15, 2014 15:35
This is a quick snippet to show very basic usage of *args and **kwargs in Python function calls
'''
Snippets for args and kwargs usage, both calling and handling *args and **kwargs
Created on July 15, 2014
@author Chris Coe
'''
@chrcoe
chrcoe / AESCipher.py
Last active November 29, 2021 09:03
PyCrypto AES using ECB mode implementation in Python 3.3. This uses very basic 0x00 padding, I would recommend PKCS5/7
'''
Created on Mar 20, 2014, uses PyCrypto/Python 3.3
@author: Chris Coe
'''
import binascii
from Crypto.Cipher import AES
class AESCipher:
'''