Skip to content

Instantly share code, notes, and snippets.

Writing code from another galaxy.

Douglas Miranda douglasmiranda

Writing code from another galaxy.
View GitHub Profile
douglasmiranda /
Created Jan 12, 2021
Django Admin Inline / Access parent object/instance of an Inline
# Let's say you want to access the Collection instance for a Image in a Django Admin Inline
from django.contrib import admin
from app.models import Image, Collection
class ImageInline(admin.StackedInline):
model = models.Image
extra = 1
douglasmiranda / toasts.css
Last active Sep 27, 2022
Bootstrap Toasts - Top Right Fixed (+ Fix toast-container overlaping content)
View toasts.css
/* */
.toast-container {
position: fixed;
right: 20px;
top: 20px;
.toast:not(.showing):not(.show) {
display: none !important;
douglasmiranda / tagify.js
Created Jan 7, 2021
Tagify: Format for server side comma separated / on form changes event / jQuery example
View tagify.js
jQuery(document).ready(function ($) {
$input = $('#my-form')
.on('change', function (e, tagData) {
if (tagData === undefined) {
// string [{"value":"test"}', '{"value":"test2"}] to JSON Object
var tags = JSON.parse(tagData);
// Converts into a simple array ["test", "test2"], then convert to string "test,test2"
douglasmiranda /
Created Nov 23, 2020
wkhtmltopdf headless fix
douglasmiranda /
Created Jan 4, 2020
Django Field.choices alternative

Django Field.choices

I was never very fond of using that tuple of tuples and acessing those choices with something like choices[0].

In my latest projects I was using a solution of my own.


douglasmiranda /
Created May 8, 2019
Docker client API version mismatch: Error response from daemon: client version 1.40 is too new. Maximum supported API version is 1.39

When building things that will interact with the client/server you can have a mismatch of API versions.

This is a common way to get started with the Docker client in Go: (this will create a new client based on your environment settings for Docker)

cli, err := client.NewClientWithOpts(client.FromEnv)

You may face an error similar to:

View pull.go
package main
import (
douglasmiranda /
Last active Jul 28, 2021
Ubuntu 16.04 Dell G3 series setup