Skip to content

Instantly share code, notes, and snippets.

View G4brym's full-sized avatar
πŸ‡΅πŸ‡Ή

Gabriel Massadas G4brym

πŸ‡΅πŸ‡Ή
View GitHub Profile
@dmontagu
dmontagu / fastapi_cbv.py
Last active May 12, 2025 07:22
FastAPI CBV
import inspect
from typing import Any, Callable, List, Type, TypeVar, Union, get_type_hints
from fastapi import APIRouter, Depends
from pydantic.typing import is_classvar
from starlette.routing import Route, WebSocketRoute
T = TypeVar("T")
CBV_CLASS_KEY = "__cbv_class__"
This file has been truncated, but you can view the full file.
# No inicio.jsp
<input type="hidden" id="controloAlteracoes" value="0">
# no acesso.js (chamado no inicio.jsp)
$("#controloAlteracoes").change(function () {
if ($(this).val() == 1) {
toastr.clear();
toastr["info"]("Existem informaΓ§Γ΅es nΓ£o guardadas", "AtenΓ§Γ£o", {
"closeButton": true,
"debug": false,
package agent;
import common.Action;
public class AlphaBeta extends GameAlgorithm {
//ALFABETA-DECISION(state) returns an action
// max = -∞
// For each a from ACTIONS(state) do
// v = MINVALUE(RESULT(state, a), max, +∞, 1)
@emmettna
emmettna / Docker-compose Nginx + Django + Gunicorn
Last active June 27, 2021 20:50
Docker-compose Nginx + Django + Gunicorn
1. Make folder tree like these
mi_project
β”œβ”€β”€ src
β”‚ β”œβ”€β”€ midjangoapp
β”‚ β”œβ”€β”€ manage.py
β”œβ”€β”€ config
β”‚ β”œβ”€β”€ requirements.pip
β”‚ β”œβ”€β”€ nginx
β”‚ β”œβ”€β”€ midjangoapp.conf
β”œβ”€β”€ Dockerfile
@sirodoht
sirodoht / migrate-django.md
Last active September 22, 2025 17:30
How to migrate Django from SQLite to PostgreSQL

How to migrate Django from SQLite to PostgreSQL

Dump existing data:

python3 manage.py dumpdata > datadump.json

Change settings.py to Postgres backend.

Make sure you can connect on PostgreSQL. Then:

@cvan
cvan / webgl-detect-gpu.js
Last active December 9, 2025 18:37
use JavaScript to detect GPU used from within your browser
var canvas = document.createElement('canvas');
var gl;
var debugInfo;
var vendor;
var renderer;
try {
gl = canvas.getContext('webgl') || canvas.getContext('experimental-webgl');
} catch (e) {
}
@Calinou
Calinou / build_linux.sh
Last active July 8, 2023 23:24
Compile Godot for GNU/Linux 64-bit easily
#!/bin/sh -x
# This script compiles Godot for GNU/Linux in 64-bit.
# Place this script at the root of your Godot Git clone.
# CC0 1.0 Universal
# Build 64-bit Godot for GNU/Linux desktop, in debug and release mode
scons p=x11 -j$(nproc) verbose=no tools=yes target=release_debug openssl=builtin
scons p=x11 -j$(nproc) verbose=no tools=no target=release_debug openssl=builtin
@mattlong
mattlong / admin.py
Created September 17, 2014 18:26
Add a custom admin page for a model and link to it from the detail page
from functools import update_wrapper
from django.contrib import admin
from django.contrib.admin import ModelAdmin
from django.contrib.admin.templatetags.admin_urls import add_preserved_filters
from django.core.exceptions import PermissionDenied
from django.shortcuts import render
from myapp.models import Widget
from myapp.forms import ManageWidgetForm
@Zearin
Zearin / python_decorator_guide.md
Last active January 12, 2026 16:30
The best explanation of Python decorators I’ve ever seen. (An archived answer from StackOverflow.)

NOTE: This is a question I found on StackOverflow which I’ve archived here, because the answer is so effing phenomenal.


Q: How can I make a chain of function decorators in Python?


If you are not into long explanations, see [Paolo Bergantino’s answer][2].