Skip to content

Instantly share code, notes, and snippets.

View douglasmiranda's full-sized avatar

Douglas Miranda douglasmiranda

  • Earth, Brazil
View GitHub Profile
douglasmiranda / gist:aa171323de9711b8344efdb96d9d822d
Created September 14, 2023 01:14
Fix Virtualbox USB not detected
View gist:aa171323de9711b8344efdb96d9d822d
Virtual box cant enumerate
Virtual box no usb devices detected
sudo usermod -aG vboxusers $USER
douglasmiranda / Dockerfile
Created January 24, 2023 23:14
Python Pillow build on Alpine
View Dockerfile
FROM python:3.11-alpine3.17
# Python packages build dependencies
RUN apk add --no-cache --virtual .build-dependencies \
# Essentials
gcc musl-dev openssl-dev openssl \
# Pillow / PIL build dependencies
douglasmiranda /
Created January 12, 2021 22:02
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 December 8, 2022 19:29
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 January 7, 2021 16:57
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 November 23, 2020 20:19
wkhtmltopdf headless fix
douglasmiranda /
Created January 4, 2020 17:00
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 02:52
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 (