Skip to content

Instantly share code, notes, and snippets.

@denised
denised / lr_accumulator.py
Created September 8, 2019 08:53
Accumulate multiple lr/loss curves in fastai
from matplotlib import pyplot
from fastai.core import ifnone
# See my post on forums.fast.ai for an example
class LRAccumulator(object):
"""Accumulate multiple recorder results to compare them on the same graph. Can be applied across any Learner fit method
(lr_find, fit, etc.), and a single accumulator can be used across multiple learners, models, data... anything where you'd like
to compare the loss graphs."""
def __init__(self, learner=None, title="a", fmt=''):
@denised
denised / pull_from_github.yml
Created August 30, 2017 05:43
Ansible tasklist to pull from a github repo, with different behavior in dev vs. production
---
# This is a *task-level* include
# Invoke it as a task like so
# - include: "lib/pull_from_github.yml"
# vars:
# ...
# where the vars are these:
# repo=name required. name is like "smbbeta_testing"
# dest=dir required. directory for the repo
# deploy_type=prod|dev required. deployment type.
@denised
denised / fillRows.js
Created March 28, 2017 22:41
Left-justify columns in html tables (datatables implementation, generally applicable concept)
/*
* Create a justified table, while *also* enabling wrapable columns to mainain their width.
* This is not possible today with pure css, so we resort to javascript.
* This code is a tweak of the way datatables computes column widths (no way would I have been
* able to write this from scratch!).
*
* Usage: give the header of one column in the table the class 'dt-rowFiller'. As the most
* common use case, to have a natural looking, left-justified, table, add an extra empty column
* at the end, with this class. Then invoke one of the functions: fillRows() will cause the filling
* to happen a single time, while autoFillRows() watches for events that may cause table resizing and
@denised
denised / responsive-measure.scss
Created April 23, 2016 20:25
Simple Sass mixin for responsive css: start height / width / margin / font-size/etc. at one size, and shrink when the screen is smaller.
/*
* Set a measure to a standard size on large screens,
* and beneath 750 pixels width, scale it according to screen width.
* Useful for margins, padding, font-sizes: anything which takes a measure.
* Works with absolute measures (px, pt, etc., also rem), not
* with relative measures (em, etc.)
*
* Usage:
* foo {
* @include responsive-measure(margin,20px);
@denised
denised / layout.css
Created March 19, 2016 21:44
Simple css to for sticky footer or fixed header/footer *independent of footer size*. (Applies to wordpress as well as other sites).)
/* There are a lot of 'sticky footer' implementations out there, but they
* almost always require you to know the size of your footer in advance.
* Or they rely on some trick like display: table-row, whatever that really
* does. And most "fixed" header/footer implementations cause
* scrolling of the main body to be unintuitive (try to page forward and
* it goes too far, putting text you haven't seen yet under the header)
*
* This implementation is:
* (1) Very direct and 'semantic', i.e. No tricks. It uses
* flex display which is by now well supported.
@denised
denised / smartposition.js
Last active August 29, 2015 14:16
Some smart behavior for Cordova geolocation
/* smartPosition
TL;DR:
smartPosition makes using the cordova geolocation plugin easier.
It "tries a reasonable amount" to obtain a desired level of
location accuracy.
the minimal call is just
smartPosition(onSuccess)
@denised
denised / gist:5924370
Created July 4, 2013 02:07
Illustration of problem scrolling to fragment identifiers with absolutely positioned div.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Testing</title>
<style>
#header {
position:fixed;
left:0; right:0; top:0;
padding: 0 50px;