Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 rest_framework import permissions | |
class IsOwner(permissions.BasePermission): | |
""" | |
Custom permission to only allow owners of an object to edit it. | |
""" | |
def has_permission(self, request, view): | |
return request.user and request.user.is_authenticated() |
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 RestrictedSerializerOptions(serializers.ModelSerializerOptions): | |
""" | |
Meta class options for ModelSerializer | |
""" | |
def __init__(self, meta): | |
super(RestrictedSerializerOptions, self).__init__(meta) | |
self.writable_fields = getattr(meta, 'writable_fields', ()) | |
class WriteRestrictedModelSerializer(serializers.ModelSerializer): |
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
function roundToSignificantFigures(num, sigFigs, truncationFunc) { | |
if (num == 0) { | |
return 0; | |
} | |
// We use base 5 because it makes for pretty numbers without intervals | |
// quite as large as base 10. | |
var d = Math.ceil(Math.log(num < 0 ? -num: num) / Math.log(5)); | |
var power = sigFigs - d; |
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
input { | |
height: 34px; | |
width: 100%; | |
border-radius: 3px; | |
border: 1px solid transparent; | |
border-top: none; | |
border-bottom: 1px solid #DDD; | |
box-shadow: inset 0 1px 2px rgba(0,0,0,.39), 0 -1px 1px #FFF, 0 1px 0 #FFF; | |
} |
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
javascript:(() => { | |
if (window.tinysort === undefined) { | |
var script = document.createElement('script'); | |
script.src = 'https://cdnjs.cloudflare.com/ajax/libs/tinysort/2.3.0/tinysort.min.js'; | |
script.onload = function() { | |
sortGoodreads(); | |
}; | |
document.getElementsByTagName('head')[0].appendChild(script); | |
} else { | |
sortGoodreads(); |
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
/* A very classy shadow. */ | |
.classy-shadow { | |
box-shadow: -1px 0 0 0 #d1d1d1, | |
-1px 0 0 0 #e5e5e5, | |
1px 0 0 0 #d1d1d1, | |
2px 0 0 0 #e5e5e5, | |
0 -1px 0 0 #e7e7e7, | |
0 2px 0 0 rgba(240, 240, 240, 0.3), | |
0 1px 0 0 #b0b0b0; | |
} |
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 LSystem(object): | |
def __init__(self, axiom, rules): | |
self.axiom = axiom | |
self.rules = rules | |
self.string = self.axiom | |
self.generation = 0 |
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
$('.help-hover').popover({ | |
trigger: 'hover' | |
}); |
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/local/bin/python | |
from paste.util.multidict import MultiDict | |
from pprint import pprint | |
import hashlib | |
import os | |
import sys | |
def md5(file_path, block_size=2**18): | |
"""Compute md5 hash of first ``block_size`` of the specified file""" |
NewerOlder