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
#include <stdio.h> | |
#include <list> | |
#include <memory> | |
#include <pybind11/pybind11.h> | |
#include <pybind11/stl.h> | |
struct B; | |
struct A { |
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
#include <stdio.h> | |
#include <list> | |
#include <memory> | |
#include <pybind11/pybind11.h> | |
#include <pybind11/stl.h> | |
struct B; | |
struct A { |
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
#include "llcpp/llcpp.hpp" | |
#include <stdio.h> | |
#include <utility> | |
// typestring.hpp | |
template<typename CharT, CharT... Chars> | |
struct typestring { | |
static constexpr const CharT *data() { return chars; } |
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
''' | |
When ImageFields are serialized with Djang Rest Framework you only get | |
the URN of the file. So I made this serializer which adds the rest | |
of the URI. | |
''' | |
class ImageFileFieldSerializer(serializers.WritableField): | |
def __init__(self, *args, **kwargs): | |
super(ImageFileFieldSerializer, self).__init__(*args, **kwargs) | |
def to_native(self, obj): |
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
def HideNotFoundSubClass(base_class): | |
''' | |
So apparently, django-rest-framework's permission checks aren't quite enough | |
for me. | |
It has 2 steps: | |
1. Check global permissions by calling has_permission for each of the | |
permission classes | |
2. Check object permissions by calling has_object_permission for each | |
of the permission classes | |
Between 1 and 2, it tries to find the object with get_object(). |
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
def truncateObject(apitoken, swifturl, container, object, size): | |
url = swifturl[1] | |
body="" | |
headers = { "X-Auth-Token":apitoken, "Content-type":"application/json-patch", | |
"x-patch-offset":0, "x-new-size":size, "Content-Length":0 | |
} | |
conn = httplib.HTTPConnection(url) | |
conn.request("PATCH", "%s/%s/%s" % (swifturl[2],container,object), body, headers) | |
response = conn.getresponse() |