This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Internal Server Error: /v1/cinema/ | |
Traceback (most recent call last): | |
File "/Users/hcalves/.virtualenvs/claquete/lib/python2.7/site-packages/tastypie/resources.py", line 192, in wrapper | |
response = callback(request, *args, **kwargs) | |
File "/Users/hcalves/.virtualenvs/claquete/lib/python2.7/site-packages/tastypie/resources.py", line 397, in dispatch_list | |
return self.dispatch('list', request, **kwargs) | |
File "/Users/hcalves/.virtualenvs/claquete/lib/python2.7/site-packages/tastypie/resources.py", line 427, in dispatch | |
response = method(request, **kwargs) | |
File "/Users/hcalves/.virtualenvs/claquete/lib/python2.7/site-packages/tastypie/resources.py", line 1029, in get_list | |
objects = self.obj_get_list(request=request, **self.remove_api_resource_names(kwargs)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Environment: | |
Request Method: GET | |
Request URL: http://localhost:8000/admin/ | |
Django Version: 1.4 | |
Python Version: 2.7.1 | |
Installed Applications: | |
('django.contrib.auth', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
CODES = { | |
'400' => 'Bad Request', | |
'401' => 'Unauthorized', | |
'403' => 'Forbidden', | |
'404' => 'Not Found', | |
'405' => 'Method Not Allowed', | |
'406' => 'Not Acceptable', | |
'408' => 'Request Timeout', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import models | |
class IntegerArrayField(models.Field): | |
__metaclass__ = models.SubfieldBase | |
def db_type(self, *args, **kwargs): | |
return "integer[]" | |
def get_prep_value(self, value): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
YOUTUBE_REGEX = re.compile(r'"http://.+?(/v/|/watch\\?v=)(?P<videoId>[A-Za-z0-9_-]{11}).+?"') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.views.generic.list import ListView | |
from django.conf.urls.defaults import patterns, url | |
from models import Movie | |
class MovieListView(ListView): | |
paginate_by = 50 | |
def get(self, request, *args, **kwargs): | |
self.filter = MovieFilterSet(data=request.GET, queryset=self.queryset) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.core.files.base import ContentFile | |
from django.core.files.storage import FileSystemStorage | |
from django.utils.encoding import filepath_to_uri | |
from django.utils.log import getLogger | |
from django.conf import settings | |
from urllib2 import urlopen, HTTPError | |
from urlparse import urljoin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class NodeManager(models.Manager): | |
def get_query_set(self): | |
qs = super(NodeManager, self).get_query_set() | |
return qs.select_related('category', 'child_class') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var a = [20, 10, 5, 1]; | |
// Everyday array | |
a.sort(); | |
// [1, 10, 20, 5]... WTF? | |
a == [1, 10, 20, 5]; | |
// false | |
a === [1, 10, 20, 5]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from unicodedata import normalize, category | |
def unaccent(s): | |
return unicode( | |
filter( | |
lambda c: category(c) != 'Mn', | |
normalize('NFKD', s.decode('utf-8')) | |
) | |
).encode('utf-8') |
OlderNewer