Skip to content

Instantly share code, notes, and snippets.

forename = 'Leeroy'
surname = 'Jenkins'
# Seems nicer to me:
name = f'{forename} {surname}'
# Minimal alternative
name = '{} {}'.format(forename, surname)
# Full alternative
name = '{forename} {surname}'.format(forename=forename, surname=surname)

Contract Killer

The popular open-source contract for web designers and developers by Stuff & Nonsense

  • Originally published: 23/12/2008
  • Revised date: 15/12/2013
  • Original post

Keybase proof

I hereby claim:

  • I am meshy on github.
  • I am meshy (https://keybase.io/meshy) on keybase.
  • I have a public key whose fingerprint is 2B80 5C7E 3854 CA92 6FFF BE40 5BBA 1783 DA19 1613

To claim this, I am signing this object:

@meshy
meshy / urls.py
Last active August 29, 2015 14:06
More DRY urls?
from django.conf.urls import url
from . import utils, views
urlpatterns = [
url(r'^things', utils.include_list_and_detail(
'thing',
views.ThingList,
views.ThingDetail,
@meshy
meshy / gist:5830015
Last active December 18, 2015 18:59

Update: I expanded on this a little on my homepage.

Set up PostgreSQL 9.1 for local user access/tests on Ubuntu.

Wouldn't it be nice if you didn't need to type out that nasty sudo -u postgres pqsl and then enter a password every time you wanted to use a local development database? Well, if you don't mind every Tom, Dick and Harry having a peek at your data, you can get all that "security" balderdash out from under your feet by granting superuser access to your normal login user. :D

  1. Add the following to your /etc/postgresql/9.1/main/pg_hba.conf, replacing meshy with your login name. If you don't know it (really?) you can get it by running whoami.

     host	all		meshy		127.0.0.1/32			trust
    

local all meshy trust

@meshy
meshy / gist:3872035
Created October 11, 2012 12:38
IP or Domain regex with port
ip_byte = r'(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])'
ip_address = '(' + ip_byte + '\.){3}' + ip_byte
web_domain = r'[a-z0-9]+([\-\.][a-z0-9]+)*\.[a-z]{2,6}'
network_port = r':([0-9]{1,5})'
network_regex = '^' + ip_address + '|' + web_domain + network_port + '$'
>>> print(network_regex)
^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])|[a-z0-9]+([\-\.][a-z0-9]+)*\.[a-z]{2,6}:([0-9]{1,5})$
@meshy
meshy / tests.py
Created March 26, 2012 11:37
test
self.quantities = (
(5, 0, 0, 0),
(0, 4, 0, 0),
(5, 0, 2, 1)
)
holiday datepicker starts on wrong day
holidaycal on dashboard
project to track requirements(
add front-end views to django-password. George.
wireframes and UX for holidaycal
Expenses list. James.
irc bouncer
django--oauth--google--admin
holidaycal with google-cl
Sentry for error emails. Marc.
Howdy
.
q
@meshy
meshy / gist:1957251
Created March 2, 2012 09:33
Suggested new dispatch flow for class based views.
# @meshy's suggestion:
def dispatch(self, request, *args, **kwargs):
# Try to dispatch to the right method; if a method doesn't exist,
# defer to the error handler. Also defer to the error handler if the
# request method isn't on the approved list.
if request.method.lower() in self.http_method_names:
handler = getattr(self, request.method.lower(), self.http_method_not_allowed)
else:
handler = self.http_method_not_allowed
self.prepare_view(request, handler, *args, **kwargs)