Post data to url:
curl -d "k1=v1&k2=v2" http://example.com/
Post multipart form data to url:
curl -F "photo=@test_image.jpg" -F "k1=v1" -F "k2=v2" http://example.com/
""" | |
Decrease the verbosity of writing view tests. | |
Old way: | |
self.client.get(reverse("my-view")) | |
self.client.post(reverse("my-view"), data={"key": "value"}) | |
self.client.login("username", "password") | |
self.client.get(reverse("my-other-view")) | |
self.client.logout() |
sudo curl "http://phildawson.co.uk/ssh-copy-id" -o /usr/bin/ssh-copy-id | |
sudo chmod +x /usr/bin/ssh-copy-id |
from django.template.defaultfilters import slugify as django_slugify | |
class MyModel(models.Model): | |
def save(*args, **kwargs): | |
# Build our slug from the name, keeping it short for | |
# linkability, but still guarantee uniqueness | |
if not self.pk and self.slug: | |
self.slug = self.slugify(self.slug) |
#!/bin/sh | |
# | |
# redis - this script starts and stops the redis-server daemon | |
# | |
# chkconfig: - 85 15 | |
# description: Redis is a persistent key-value database | |
# processname: redis-server | |
# config: /etc/redis/redis.conf | |
# config: /etc/sysconfig/redis | |
# pidfile: /var/run/redis.pid |
""" | |
WSGI application configuration. | |
Read http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango to learn | |
more about integrating with Django. | |
""" | |
import os | |
import site | |
import sys |
try: | |
contents = urllib2.urlopen(url).read() | |
except urllib2.HTTPError, exc: | |
# handle exception | |
pass | |
mymodel.image.save(file_name, ContentFile(contents)) |
try: | |
variable_name = re.search("as (\w+)", token.contents).group(1) | |
except AttributeError: | |
raise template.TemplateSyntaxError, \ | |
"%r tag had invalid arguments." % token.split_contents()[0] |
Post data to url:
curl -d "k1=v1&k2=v2" http://example.com/
Post multipart form data to url:
curl -F "photo=@test_image.jpg" -F "k1=v1" -F "k2=v2" http://example.com/
<!DOCTYPE HTML> | |
<!-- zero-timeout.html, L. David Baron <[email protected]>, 2010-03-07, 2010-03-09 --> | |
<!-- | |
Copyright (c) 2010, The Mozilla Foundation | |
All rights reserved. | |
Redistribution and use in source and binary forms, with or without | |
modification, are permitted provided that the following conditions are |
<!-- Carousel --> | |
<div id="carousel" class="feature autorotate slidelinks group"> | |
<!-- Slides --> | |
<div class="carousel-slides"> | |
<div class="slide"> | |
<a href="/bundles/greatest-need/"><img src="//www.gfamedia.org/images/bundles-slide/greatest-need.jpg" alt=""></a> | |
</div> | |
<div class="slide"> |