Thursday, July 25, 2013

oneliner: reset Django administrator password



$ ./manage.py shell
 

>>> from django.contrib.auth.models import User
>>> a=User.objects.all()[0]; a.set_password('beerbeer'); a.save()

Tuesday, July 23, 2013

correcting NetworkManager

Ubuntu uses the NetworkManager (NM) daemon to regulate a computer's network connections, most importantly the wireless.  Sometimes it gets confused, and sometimes upstream routers lie to it.

Every now and then someone lies to NM, telling it about Domain Name Server (DNS) machines that don't work.  The symptom is that even though your local LAN works, and you can ping external IPs, web pages generally don't work.  They stall and give you the Unhappy Chrome message.

To test DNS:

dig yahoo.com

If it comes back nearly immediately with verbiage in the "ANSWER SECTION", then your nameserver is fine and working properly.  If it takes a few seconds, then something is confused.

One fix is to overwrite NetworkManager's settings when it does anything.  This is kind of impolite, but what the hell.

As root, copy this script to /etc/NetworkManager/dispatcher.d/50fix-dns and mark it executable with "chmod +x ".

#!/bin/bash
# Fix DNS set by misguided routers
#
# JM 7/2013
cat << EOF > /etc/resolv.conf
# DONT EDIT
# see $0
nameserver 4.2.2.2
EOF

Friday, July 19, 2013

Concurrency/99Bottles

simple concurrency program, written in ~10 different styles in Python!  Includes coroutines, generators, Greenlet, Gevent, and Twisted.

Concurrency/99Bottles - Python Wiki