Skip to content

Instantly share code, notes, and snippets.

@walterrenner
walterrenner / gist:c51d09a0fcc4b5269611
Last active August 29, 2015 14:07 — forked from philippeowagner/gist:6794344
delete *.pyc files recursively
find -type f -name "*.pyc" -delete
@walterrenner
walterrenner / punch.py
Last active August 29, 2015 14:11 — forked from koenbollen/punch.py
#!/usr/bin/env python
#
# Proof of Concept: UDP Hole Punching
# Two client connect to a server and get redirected to each other.
#
# This is the client.
#
# Koen Bollen <meneer koenbollen nl>
# 2010 GPL
#
import atexit
import os
import sys
try:
import readline
except ImportError:
print "Module readline not available."
else:
import rlcompleter
readline.parse_and_bind('tab:complete')
@walterrenner
walterrenner / models.py
Created January 29, 2015 15:52
get_admin_url() for any model instance
from django.core import urlresolvers
from django.contrib.contenttypes.models import ContentType
from django.db import models
class MyModel(models.Model):
def get_admin_url(self):
content_type = ContentType.objects.get_for_model(self.__class__)
return urlresolvers.reverse("admin:%s_%s_change" % (content_type.app_label, content_type.model), args=(self.id,))
@walterrenner
walterrenner / command.py
Created August 21, 2015 11:54
print django project information
from compat import import_string
from django.conf import settings
for app_name in settings.INSTALLED_APPS:
app = __import__(app_name)
print "Information for " + app_name
try:
print "verion: " + app.__version__
except Exception as e:
print "version: " + str(e)
@walterrenner
walterrenner / scrollposition.html
Created December 7, 2012 08:42
Detect Scroll Position and act
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Detect Scroll Position and act</title>
<!-- CSS -->
<style type="text/css">
@walterrenner
walterrenner / nested-kbd.html
Created December 7, 2012 08:38
Stylish kbd Element
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Stylish kbd Element</title>
<!-- CSS for nested kbd Elemnts -->
<style type="text/css">
@walterrenner
walterrenner / readme.md
Created October 14, 2015 12:55
Use project related mirgation modules

Keep your custom Migrations in your project

A proof of concept.

If you cant't/won't use the apps Migration files this workaround can be helpful for you.

We assume you have a clean Database without any Migrations applied and a Project named my_project that you are working on. Add the below snippet in your settings.py right after INSTALLED_APPS.

This tells django to use migration files from the module in my_project.migrations.<appname>.migrations.

@walterrenner
walterrenner / hide-url-bar.html
Last active December 10, 2015 08:18
Hide URL-Bar in mobile Safari
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Hide URL-Bar in mobile Safari</title>
</head>
<body>
<div id="wrapper" style="font-size:3em;">
foo:bar
/* Smartphones (portrait and landscape) ----------- */
@media only screen
and (min-device-width : 320px)
and (max-device-width : 480px) {
/* Styles */
}
/* Smartphones (landscape) ----------- */
@media only screen
and (min-width : 321px) {