Skip to content

Instantly share code, notes, and snippets.

View MarkusH's full-sized avatar
🐍

Markus Holtermann MarkusH

🐍
View GitHub Profile
@MarkusH
MarkusH / antwort.md
Last active October 14, 2016 16:11
Hiring replies

Hallo XXXXXXXXXX,

danke für die Anfrage, aber ich bin derzeit nicht an einem Wechsel interessiert. Eine gute Möglichkeit um 300 andere Django-Entwickler*innen zu treffen und Jobs anzubieten stellt ein Sponsoring der nächsten europäischen Django Konferenz in Florenz dar: https://2017.djangocon.eu/. Die Organisatoren sind unter 2017@djangocon.eu zu erreichen.

Mit freundlichen Grüßen

@MarkusH
MarkusH / git-pr.py
Created April 2, 2016 14:05
git command to checkout a github pull-request from a remote repository and optionally rebase it onto a base branch
#!/usr/bin/env python
# Put this file somewhere in $PATH and name it git-pr
# Also, add the following or simialar lines to .git/config
#
# [pr]
# base = master
# remote = upstream
import subprocess
@MarkusH
MarkusH / stats-1.8.4.pstats
Last active August 29, 2015 14:27
Django issue 24743
$ python -m pstats /tmp/stats-1.8.4.pstats
Welcome to the profile statistics browser.
/tmp/stats-1.8.4.pstats% sort cumtime
/tmp/stats-1.8.4.pstats% stats
Sat Aug 22 19:16:25 2015 /tmp/stats-1.8.4.pstats
176323684 function calls (172452682 primitive calls) in 314.468 seconds
Ordered by: cumulative time
@MarkusH
MarkusH / gist:cc6d9f4aed6c024c562b
Created June 26, 2015 11:49
Middle button scrolling with Thinkpad trackpoint
install xorg-xinput and put the following lines into ~/.xinitrc
xinput set-prop "TPPS/2 IBM TrackPoint" "Evdev Wheel Emulation" 1
xinput set-prop "TPPS/2 IBM TrackPoint" "Evdev Wheel Emulation Button" 2
xinput set-prop "TPPS/2 IBM TrackPoint" "Evdev Wheel Emulation Timeout" 200
xinput set-prop "TPPS/2 IBM TrackPoint" "Evdev Wheel Emulation Axes" 6 7 4 5
xinput set-prop "TPPS/2 IBM TrackPoint" "Device Accel Constant Deceleration" 0.75
@MarkusH
MarkusH / django.diff
Created June 17, 2015 21:52
managers in migrations
diff --git a/django/db/migrations/state.py b/django/db/migrations/state.py
index b1cba07..1fdd9f6 100644
--- a/django/db/migrations/state.py
+++ b/django/db/migrations/state.py
@@ -467,7 +467,10 @@ class ModelState(object):
(name, instance) for name, (cc, instance) in
sorted(managers_mapping.items(), key=lambda v: v[1])
]
- if managers == [(default_manager_name, models.Manager())]:
+ # In case the only manager on the model is the default manager
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from __future__ import print_function
from smtpd import SMTPServer
import asyncore
import quopri
class DebuggingServer(SMTPServer):
#!/usr/bin/env python3
"""
From @pydanny at https://gist.github.com/pydanny/ddf965bbec415084fb6d
Git Integration
===============
1. Move .git/hooks/pre-commit.sample to .git/hooks/pre-commit
2. Add::

Share Counts

I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.

If you want to roll up all of these into a single jQuery plugin check out Sharrre

Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.

Twitter

@MarkusH
MarkusH / main.js
Last active August 29, 2015 14:19
Github Pull-Request line length indicator
/**
* Add a new bookmark with this content.
**/
javascript:$('body').append($('<div style="border: 1px solid red; position: fixed; top: 10px; left: 10px; height: 25px; min-width: 50px" id="line-length"></div>'));$('.blob-code.blob-code-addition').on('mouseover', function(event) {$('#line-length').text(event.target.innerText.length - 1)});
@MarkusH
MarkusH / changes.patch
Created April 14, 2015 19:49
Postgresql function based indexes in Django (based on 825bb0ab08cec353edcd2b9aea651bfe9392ef97)
diff --git a/django/db/backends/postgresql_psycopg2/schema.py b/django/db/backends/postgresql_psycopg2/schema.py
index 8340059..692866e 100644
--- a/django/db/backends/postgresql_psycopg2/schema.py
+++ b/django/db/backends/postgresql_psycopg2/schema.py
@@ -1,6 +1,21 @@
import psycopg2
from django.db.backends.base.schema import BaseDatabaseSchemaEditor
+from django.db.models.expressions import Func
+from django.db.models.sql.compiler import SQLCompiler