Skip to content

Instantly share code, notes, and snippets.

View douglasmiranda's full-sized avatar
👽

Douglas Miranda douglasmiranda

👽
  • Earth, Brazil
View GitHub Profile
@douglasmiranda
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
douglasmiranda / Dockerfile
Created January 24, 2023 23:14
Python Pillow build on Alpine
View Dockerfile
FROM python:3.11-alpine3.17
ENV PATH=$PATH:$HOMEAPP/.local/bin
ENV PYTHONPATH=$HOMEAPP:$PROJECT_NAME
# Python packages build dependencies
RUN apk add --no-cache --virtual .build-dependencies \
# Essentials
gcc musl-dev openssl-dev openssl \
# Pillow / PIL build dependencies
@douglasmiranda
douglasmiranda / admin.py
Created January 12, 2021 22:02
Django Admin Inline / Access parent object/instance of an Inline
View admin.py
# 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
douglasmiranda / toasts.css
Last active December 8, 2022 19:29
Bootstrap Toasts - Top Right Fixed (+ Fix toast-container overlaping content)
View toasts.css
/* https://getbootstrap.com/docs/5.0/components/toasts/ */
.toast-container {
position: fixed;
right: 20px;
top: 20px;
}
.toast:not(.showing):not(.show) {
display: none !important;
@douglasmiranda
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')
.tagify()
.on('change', function (e, tagData) {
if (tagData === undefined) {
return;
}
// 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
douglasmiranda / wkhtmltopdf.md
Created November 23, 2020 20:19
wkhtmltopdf headless fix
View wkhtmltopdf.md
@douglasmiranda
douglasmiranda / choices.md
Created January 4, 2020 17:00
Django Field.choices alternative
View choices.md

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.

This:

@douglasmiranda
douglasmiranda / docker-client-go.md
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
View docker-client-go.md

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 (
"context"
"fmt"
"io/ioutil"
"os"
"github.com/containerd/containerd/content/local"
"github.com/containerd/containerd/images"