Joined January 2013
·

Vladimir Prudnikov

Professional web developer, IT entrepreneur. at Bugspot
·
Czech Republic
·
·
·

Posted to POSTing from Angular to Django over 1 year ago

Here is my code:

class JsonPayloadToRequestDataMiddleware(object):
    def process_request(self, request):

        if request.method != "POST":
            return None

        if 'application/json' not in request.META['CONTENT_TYPE']:
            return None

        body = request.body.strip()
        if not body:
            return None

        is_obj = body.startswith("{") and body.endswith("}")
        is_array = body.startswith("[") and body.endswith("]")
        if not is_obj and not is_array:
            return None

        # data is django.http.QueryDict
        json_data = json.loads(request.body)
        string_data = urllib.urlencode(json_data, True)
        data = QueryDict(string_data, mutable=True)
        if request.POST:
            data.update(request.POST)

        # it should be immutable
        request.POST = data.copy()

This way you should always restart Xcode if you modify snippet. There is a much better way to manage and sync snippets in Xcode. It is Snippets http://snippets.me/. Check out this demo http://www.youtube.com/watch?v=0qzsVhKqOHw. You can edit and manage your code snippets in Snippets, sync between your computers and using Snippets Distributor for Xcode push them to the Xcode without needing to restart it.

Posted to Xcode Code Snippets over 1 year ago

The is a much better way to manage code snippets in Xcode. It is Snippets http://snippets.me/. Check out this demo http://www.youtube.com/watch?v=0qzsVhKqOHw

Posted to Pretty diff output with Sublime over 1 year ago

You don't have to save output to the file... This will be just fine

diff path/to/first/file path/to/second/file | subl

or with TextMate

diff path/to/first/file path/to/second/file | mate

I did not tested on many browsers, I needed this for our internal tool. Form data has support in all modern browsers including IE 10+. Also take a look at Modernizr and HTML5Shim.

Achievements
651 Karma
160,111 Total ProTip Views