Skip to content

Instantly share code, notes, and snippets.

View rense's full-sized avatar

Rense VanderHoek rense

  • AMMO
  • Amsterdam
View GitHub Profile
export MY_HOSTNAME=foobar; for n in LocalHostName ComputerName HostName; do sudo scutil --set $n $MY_HOSTNAME; done
@rense
rense / gist:99914d02c88bd444e5de3abdd92864f9
Created January 20, 2017 10:25
A nicer Django AUTH_PASSWORD_VALIDATORS setting
_validator_module = 'django.contrib.auth.password_validation'
AUTH_PASSWORD_VALIDATORS = [
{'NAME': '%s.UserAttributeSimilarityValidator' % _validator_module},
{'NAME': '%s.MinimumLengthValidator' % _validator_module},
{'NAME': '%s.CommonPasswordValidator' % _validator_module},
{'NAME': '%s.NumericPasswordValidator' % _validator_module},
]
foo = ["foe", "jong", "hai", 'sambal', 'bij']
for x in range(len(foo) + 1):
bar = foo[x:]
while len(bar):
print('.'.join(bar))
_ = bar.pop()
import sys
from django.conf import settings
settings.configure(
DEBUG=True,
SECRET_KEY='thisisthesecretkey',
ROOT_URLCONF=__name__,
MIDDLEWARE_CLASSES=(
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
@rense
rense / beautiful_idiomatic_python.md
Created February 20, 2016 23:43 — forked from JeffPaine/beautiful_idiomatic_python.md
Transforming Code into Beautiful, Idiomatic Python: notes from Raymond Hettinger's talk at pycon US 2013. The code examples and direct quotes are all from Raymond's talk. I've reproduced them here for my own edification and the hopes that others will find them as handy as I have!

Transforming Code into Beautiful, Idiomatic Python

Notes from Raymond Hettinger's talk at pycon US 2013 video, slides.

The code examples and direct quotes are all from Raymond's talk. I've reproduced them here for my own edification and the hopes that others will find them as handy as I have!

Looping over a range of numbers

for i in [0, 1, 2, 3, 4, 5]:
@rense
rense / gist:10989833
Created April 17, 2014 14:58
Fix homebrew for upgrade
cd `brew --prefix`
git remote add origin https://github.com/mxcl/homebrew.git
git fetch origin
git reset --hard origin/master
def sieve(limit):
limit += 1
primes = []
a = [True] * limit
a[0] = a[1] = False
for (i, prime) in enumerate(a):
if not prime:
continue
primes.append(i)
@rense
rense / dlnaclientprofiles.xml
Created October 31, 2012 23:25
Samsung SMT-G7400 (UPC Horizon) DLNA client profile for Plex Media Server
<?xml version="1.0" encoding="utf-8"?>
<Clients>
<Client name="UPC Horizon">
<!-- Samsung SMT-G7400, the UPC Horizon -->
<!-- Author: Rense VanderHoek -->
<!-- DLNA Test Certificate: http://certification.dlna.org/certs/REG47816707.pdf -->
<Identification>
<Header name="User-Agent" substring="Linux/2.6.35 UPnP/1.0 NDS_MHF DLNADOC/1.50"/>
<DeviceDescription type="urn:schemas-upnp-org:device:MediaServer:1">
<FriendlyName substring="UPC Horizon"/>