Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am hackedd on github.
  • I am hackedd (https://keybase.io/hackedd) on keybase.
  • I have a public key ASBd8xeF9XUEbzHpdCIJLOL4_24SemCL7LkyFey7m_ZSwwo

To claim this, I am signing this object:

from rest_framework.filters import BaseFilterBackend
class BulkFilter(BaseFilterBackend):
def filter_queryset(self, request, queryset, view):
if request.method in ("PUT", "PATCH") and isinstance(request.DATA, list):
ids = [obj.get("id") for obj in request.DATA]
queryset = queryset.filter(pk__in=ids)
return queryset
@hackedd
hackedd / window-focus.py
Created March 19, 2014 11:17
globalhotkey window focus
import gtk
try:
import globalhotkeys
except ImportError:
import guake.globalhotkeys
def log(message, *args):
log.counter = getattr(log, "counter", 0) + 1
import threading
def map_async(func, iterable, num_threads=None):
"""Apply the function to each of the elements of the iterable, and return
the results. The function is run in multiple threads at the same time, the
number of which can be specified (and defaults to the length of the
iterable, so that each thread runs the function once).
The ordering of the results should be considered arbitrary.
"""
@hackedd
hackedd / patch-cinnamon-screensaver.py
Last active January 2, 2016 00:09
Replace default date and time format in cinnamon-screensaver
import sys
source = "/usr/bin/cinnamon-screensaver"
time_format = "%l:%M %p"
date_format = "%A, %B %e"
nul = "\x00"
def patch(data, orig, new):
@hackedd
hackedd / try-parse.py
Created November 19, 2013 07:07
Try to parse C.tmLanguage
def etree_parse(fp):
from xml.etree.cElementTree import iterparse
parser = iterparse(fp, events=('start', 'end'))
for action, element in parser:
pass
def sax_parse(fp):
from xml.sax import make_parser, xmlreader, SAXParseException
@hackedd
hackedd / sh_template_spaces.patch
Created May 28, 2013 22:38
Patch for dex2jar to accept spaces in arguments to shell wrappers.
diff -r fc1958b32b6a dex-tools/src/main/resources/com/googlecode/dex2jar/bin_gen/sh_template
--- a/dex-tools/src/main/resources/com/googlecode/dex2jar/bin_gen/sh_template Mon May 27 11:23:44 2013 +0800
+++ b/dex-tools/src/main/resources/com/googlecode/dex2jar/bin_gen/sh_template Wed May 29 00:28:35 2013 +0200
@@ -37,4 +37,4 @@
do
_classpath="${_classpath}:${k}"
done
-java -Xms512m -Xmx1024m -classpath "${_classpath}" "__@class_name@__" $@
+java -Xms512m -Xmx1024m -classpath "${_classpath}" "__@class_name@__" "$@"