Skip to content

Instantly share code, notes, and snippets.

Avatar

Andy Kish Kobold

View GitHub Profile
@Kobold
Kobold / xkcd-worth-the-time.ipynb
Last active Aug 30, 2016
A Jupyter notebook to explore variations of xkcd's "Is it worth the time?" comic.
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.
@Kobold
Kobold / inset_input.css
Created May 4, 2016 — forked from nrrrdcore/inset_input.css
The Perfect Inset Input CSS
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;
}
@Kobold
Kobold / sortGoodreadsByPopularity.js
Created Apr 27, 2016
Bookmarklets to sort arbitrary Goodreads views by popularity and rating!
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();
@Kobold
Kobold / nice-toolkit.css
Created Apr 21, 2016
Classy little helper CSS.
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;
}
@Kobold
Kobold / 1 screencast_1.py
Last active Dec 25, 2015
Nate s L-systems
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'
});
@Kobold
Kobold / round.js
Created Sep 16, 2015
Cool intelligent rounding function
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;
@Kobold
Kobold / dump2csv.py
Created Aug 13, 2015
Dump querysets to csv
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::
@Kobold
Kobold / permissions.py
Created Apr 17, 2015
IsOwner - Custom django-rest-framework permission to only allow owners of an object to edit it.
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()
@Kobold
Kobold / 0005_blah.py
Created Dec 11, 2014
How to make an order_with_respect_to migration work.
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.
"""
You can’t perform that action at this time.