Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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,))
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 / 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
#
@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
  • a bigger project
    • first subtask #1234
    • follow up subtask #4321
    • final subtask cc @mention
  • a separate task
@walterrenner
walterrenner / datetime_formatting.py
Last active August 29, 2015 14:06
Common Python datetime formatting strings
# A complete list of available directives id available on:
# https://docs.python.org/2/library/datetime.html#strftime-and-strptime-behavior
from datetime import datetime
now = datetime.now()
print now.strftime('%d. %b %Y') # 17. Sep 2014
print now.strftime('%d.%m.%y') # 17.09.14
#"%D %d %M %Y" -> 'Wed 09 Jan 2008'
@walterrenner
walterrenner / config.ini
Last active August 29, 2015 14:06 — forked from philippeowagner/config.ini
Install the 3bot worker on your machine
[3bot-settings]
BOT_ENDPOINT=*

Launch Sublime Text 2 from the Mac OS X Terminal

Sublime Text 2 ships with a CLI called subl (why not "sublime", go figure). This utility is hidden in the following folder (assuming you installed Sublime in /Applications like normal folk. If this following line opens Sublime Text for you, then bingo, you're ready.

open /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl

You can find more (official) details about subl here: http://www.sublimetext.com/docs/2/osx_command_line.html

Installation