View xkcd-worth-the-time.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View inset_input.css
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; | |
} |
View sortGoodreadsByPopularity.js
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(); |
View nice-toolkit.css
/* 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; | |
} |
View 1 screencast_1.py
class LSystem(object): | |
def __init__(self, axiom, rules): | |
self.axiom = axiom | |
self.rules = rules | |
self.string = self.axiom | |
self.generation = 0 |
View help-hover.js
$('.help-hover').popover({ | |
trigger: 'hover' | |
}); |
View round.js
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; |
View dump2csv.py
# Via: http://palewi.re/posts/2009/03/03/django-recipe-dump-your-queryset-out-as-a-csv-file/ | |
import csv | |
from django.db.models.loading import get_model | |
def dump2csv(qs, outfile_path): | |
""" | |
Takes in a Django queryset and spits out a CSV file. | |
Usage:: |
View permissions.py
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() |
View 0005_blah.py
# -*- coding: utf-8 -*- | |
from __future__ import unicode_literals | |
from django.db import models, migrations | |
class AlterOrderWithRespectTo(migrations.AlterOrderWithRespectTo): | |
""" | |
Represents a change with the order_with_respect_to option. | |
""" |
NewerOlder