Skip to content

Instantly share code, notes, and snippets.

@jacoduplessis
jacoduplessis / dev.sh
Created June 10, 2018 20:28
Run a build script when source files change
while inotifywait -e close_write src ; do NODE_ENV=development node build.js; done
@jacoduplessis
jacoduplessis / extract_keyframes.sh
Created July 9, 2018 21:17
Extract keyframes from video
ffmpeg -skip_frame nokey -i video.mp4 -vsync 0 -r 30 -f image2 thumbnails-%03d.jpg
@jacoduplessis
jacoduplessis / firefox_geckodriver_standalone.go
Created November 14, 2018 05:53
Running headless firefox without selenium in golang.
package main
import (
"fmt"
"github.com/tebeka/selenium"
"github.com/tebeka/selenium/firefox"
"log"
"os"
)
var GeoJSONFilterControl = L.Control.extend({
initialize: function (geoJsonLayer, data, fields, options = {}) {
this.layer = geoJsonLayer;
this.data = data;
this.fields = fields;
this.filteredOut = {};
L.Util.setOptions(this, options);
},
options: {
position: 'bottomright'
@jacoduplessis
jacoduplessis / colors.js
Created February 6, 2019 15:43
List of 20 simple distinct colours
// from https://sashat.me/2017/01/11/list-of-20-simple-distinct-colors/
var categoricalColors = [
'#e6194B',
'#3cb44b',
'#ffe119',
'#4363d8',
'#f58231',
'#911eb4',
'#42d4f4',
@jacoduplessis
jacoduplessis / utils.py
Last active March 28, 2019 05:45
Stream SQLAlchemy result as CSV response in Django
import csv
from sqlalchemy.engine.result import ResultProxy
class _Echo:
def write(self, value):
return value
def stream_csv(res: ResultProxy):
w = _Echo()
@jacoduplessis
jacoduplessis / data.csv
Created April 10, 2019 08:17
D3 v5 Waterfall
period start of period new returned went inactive
Four Weeks Ago 100 20 30 40
Three Weeks Ago 110 30 20 30
Two Weeks Ago 130 40 25 40
One Week Ago 155 30 55 50
Current Week 190 0 0 0
@jacoduplessis
jacoduplessis / admin.py
Created April 12, 2020 06:04
MPTT admin to move multiple nodes at once
class PlaceAdmin(MPTTModelAdmin):
def get_model_info(self):
app_label = self.model._meta.app_label
return app_label, self.model._meta.model_name
def get_move_form_class(self):
class MoveSelectTargetForm(forms.Form):
target = forms.ModelChoiceField(self.model.objects.all())
position = TreeNodePositionField()