Skip to content

Instantly share code, notes, and snippets.

@kquinsland
kquinsland / dummy0.netdev
Created December 3, 2019 02:54
How to get consul-agent and systemd.resolvd to co-exist peicefully and still be able to resolve *.consul hostsnames from within docker
# Creates a "dummy" network interface
# we'll configure this interface with a link-local address
# See: https://www.freedesktop.org/software/systemd/man/systemd.netdev.html
##
[NetDev]
Name=dummy0
Kind=dummy
@ekinertac
ekinertac / field_blank_null.md
Last active May 28, 2024 05:50
Django null/blank field explanation
Fields null=True blank=True
CharField, TextField, SlugField, EmailField, CommaSeparatedIntegerField DON'T Django's convention is to store empty values as the empty string, and to always retrieve NULL or empty values as the empty string for consistency. OK Do this if you want the corresponding form widget to accept empty values. If you set this, empty values get stored as empty strings in the database.
BooleanField DON'T Use NullBooleanField instead. DON'T
IntegerField, FloatField, DecimalField OK If you wabt to be able to set the value to NULL in the database OK if you want the corresponding form widget to accept empty values. if so out will also want to set null=True
DateTimeField, DateField, TimeField OK if you want to be able to set the value to NULL in the database. OK If you want the corresponding form widget to accept empty values, or if you are using auto now or auto now add. If so, you will al
@jcupitt
jcupitt / trim.rb
Last active April 30, 2023 02:32
auto-crop in ruby-vips
#!/usr/bin/env ruby
# "trim" is nnow built in, so this is easy
require 'vips'
im = Vips::Image.new_from_file(ARGV[0])
left, top, width, height = im.find_trim
im = im.crop(left, top, width, height)