Skip to content

Instantly share code, notes, and snippets.

@dmy3k
dmy3k / django_logging.py
Created January 23, 2014 10:37
Part of django settings.py as a sample logging setup
import os.path
p = lambda *x: os.path.abspath(os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', *x))
# Main configuration goes here
LOGGING = {
'version': 1,
'disable_existing_loggers': True,
'formatters': {
'standard': {
@dmy3k
dmy3k / opt.skype.skype
Created January 20, 2014 14:15
AppArmour Skype profile [openSuse 13.1, dynamic skype at /opt]
# vim:syntax=apparmor
#
# Copyright (C) 2012 Lekensteyn <lekensteyn@gmail.com>
#include <tunables/global>
/opt/skype/skype {
#include <abstractions/kde>
#include <abstractions/nameservice>
#include <abstractions/video>
#include <abstractions/audio>
@dmy3k
dmy3k / word_click.js
Last active December 24, 2015 07:09
Get word on click.
// see See http://stackoverflow.com/questions/7563169/detect-which-word-has-been-clicked-on-within-a-text
$(".clickable").click(function(e) {
s = window.getSelection();
var range = s.getRangeAt(0);
var node = s.anchorNode;
while (range.toString().indexOf(' ') != 0) {
range.setStart(node, (range.startOffset - 1));
}
range.setStart(node, range.startOffset + 1);
do {
@dmy3k
dmy3k / imsim.py
Last active February 1, 2017 10:11
Image similarity detection
'''
Bunch of functions to do basic image similarity detection
See:
http://www.gossamer-threads.com/lists/python/python/901273
http://sourceforge.net/projects/imsim/?source=dlp
'''
from PIL import Image
from PIL import ImageStat