Skip to content

Instantly share code, notes, and snippets.

@danielbraun
danielbraun / gist:87384ea330053b3ffa83
Created November 27, 2014 14:03
Django Rest Framework + ImageField URL
When serializing models using DRF, the related ImageFields return the file system path instead of an absolute URL.
To solve it, define an instance variable on your model serializer:
class PersonSerializer(serializers.ModelSerializer):
image = serializers.Field('image.url')
@idan
idan / gist:3135754
Created July 18, 2012 11:50
A Sample Post

Hello there! This is a sample post for gist.io, a super-lightweight writing soapbox for hackers.

Now look up. Further. Above the post title. See that grey text with the gist ID?

Now back to me. That grey text is a link! Open that sucker in a new tab to see the source for this post. Also, I'm on a horse.

This is a major heading

If you peek at it with a web inspector, you'll see that it is a second-level heading. You can use first level headings, but they'll look just like the second level ones, and the gods of the HTML5 outlining algorithm will frown upon you.

@gialloporpora
gialloporpora / apod.php
Last active October 6, 2015 06:07
With this code (PHP) you can create an URL that automatically redirect to the APOD (Astronomy Image Of the Day)
/*
With the following code you can create a static url that automatically redirect to the apod (Astronomy Image of the day
* You can use it like wallpaper in your Firefox's about:home page. Look at next file
Download Simple HTML parser from here:
http://simplehtmldom.sourceforge.net/
*/
<?php
function randomImage(){
$best_images = Array(