Skip to content

Instantly share code, notes, and snippets.

View denarced's full-sized avatar

Väinö Leppänen denarced

View GitHub Profile
@denarced
denarced / jsonhandler.py
Created December 16, 2023 17:37
Python logging handler to log dicts as JSON
import json
import logging
class JsonDict(dict):
def __str__(self):
try:
return json.dumps(self, ensure_ascii=False, sort_keys=True)
except:
return super().__str__()
@denarced
denarced / gist:d534317e782c83f58e9b
Created September 24, 2014 17:17
Adapt JQueryUI autocomplete to work with angularJs
angular.module('mod').directive('dnAutocomplete', function() {
function link(scope, element, attrs) {
scope.$watch(attrs.dnAutocomplete, function(names) {
element.autocomplete({
source: names,
/**
* The default implementation updates the HTML input's value
* in such a way that the angular doesn't detect it. The
* result is that scope.add.input isn't updated while the
* HTML input itself is. By updating angular's scope object,