Skip to content

Instantly share code, notes, and snippets.

@grizmio
grizmio / small_db_dump.sh
Created November 7, 2025 00:58
SMALL postgres in docker dump
#!/bin/bash
# Dump PostgreSQL in Docker with table name, slow as hell but usefull for finding weird values on SMALL databases
DB="furu"
OD="/tmp"
docker exec -t pg psql -t -d $DB -P pager=off -U postgres -c "SELECT table_name FROM information_schema.tables WHERE table_schema = 'public' AND table_type = 'BASE TABLE'"| tr -d '\r'| grep -v '^$' | while read table; do docker exec -t pg pg_dump -U postgres -d $DB -t $table > "$OD/${table}.sql" ; done
@grizmio
grizmio / update_windsurf_ebuild.sh
Created October 9, 2025 16:20
Comandos para actualizar el ebuild de windsurf en gentoo
#!/bin/bash
set -e
cd /var/db/repos/bentoo/app-editors/windsurf
VERSION=$(wget -q https://windsurf-stable.codeium.com/api/update/linux-x64/stable/latest -O- | jq -r '.windsurfVersion')
sudo bash -c "ls -rth1 windsurf* | xargs -I {} cat {} > windsurf-${VERSION}.ebuild"
sudo bash -c "sudo ebuild windsurf-${VERSION}.ebuild manifest"
@grizmio
grizmio / monkey_patch.py
Created October 30, 2024 17:04
monkeypatch decorating django handle_simple tag (static tag)
from django.templatetags.static import StaticNode
def patch_static_tag(unique_per_deploy: str):
def handle_simple_wrapper(func):
def wrapper_func(cls, path):
resolved_static_path = func(path)
if resolved_static_path.endswith('.js') or resolved_static_path.endswith('.css'):
resolved_static_path += f'?u={unique_per_deploy}'
return resolved_static_path
@grizmio
grizmio / distance_sensor_helper.h
Last active September 8, 2024 22:54
DistanceSensorHelper
// https://registry.platformio.org/platforms/platformio/espressif8266/boards
// /homeassistant/esphome/distance_sensor_helper.h
#include "esphome.h"
// https://esphome.io/components/sensor/custom
class DistanceSensorHelper : public PollingComponent, public Sensor {
public:
int _trigPin;
int _echoPin;
DistanceSensorHelper(int polling_time) : PollingComponent(polling_time) {
# https://stackoverflow.com/questions/7499767/temporarily-disable-auto-now-auto-now-add
"""
Con modifcacion de Georgina S
n.b. (1.10) ModelClass._meta.get_field_by_name(field_name)[0] in do_to_model didn't seem to be working for me - changed to: ModelClass._meta.get_field(field_name) –
Georgina S
Commented Mar 8, 2017 at 1:15
"""
def turn_off_auto_now(ModelClass, field_name):
def auto_now_off(field):
@grizmio
grizmio / foo.py
Created July 24, 2023 03:33
Django ModelChoiceField label to "title"
from django.template.defaultfilters import title
class LabelToTitle:
def __init__(self):
self.label = title(self.label)
class FooBarModelChoiceField(forms.ModelChoiceField, LabelToTitle):
def label_from_instance(self, obj):
@grizmio
grizmio / django_reload.sh
Created July 7, 2023 19:40
django_reload develop
alias reload_gunicorn='pidof -x gunicorn|xargs sudo kill -s HUP'
$ inotifywait -m -e modify,create,delete -r . && reload_gunicorn
@grizmio
grizmio / foo.html
Created May 28, 2023 23:54
CSS, add checkmark to label when selected/checked bootstrap 5
<html>
<body>
<style>
.btn-check:checked + label:before {
content: "✓";
left: 3px;
position: absolute;
}
</style>
<div class="col-md-6">
@grizmio
grizmio / gist:ed58dfe8da1ceedc2583649af5165311
Last active May 19, 2023 19:20
JS class callable generate svgs with circles without index out :-D
class GetSVGDot extends Function{
dot_svgs = [];
constructor(size) {
super('return arguments.callee._call.apply(arguments.callee, arguments)');
const dot_colors = ['#FF0000', '#FF8000', '#80FF00', '#000000', '#0000FF', '#0000FF', '#FFFF00', '#FF6600', '#00FF00', '#00FFFF', '#FF00FF', '#8000FF', '#6600FF', '#FF7D00'];
let cont = 0;
for(const dot_color of dot_colors) {
this.dot_svgs.push(`<svg id='svg_circle_${cont}' width='${size}' height='${size}'>
<circle cx="12.5" cy="12.5" r="6.25" fill="${dot_color}">
</circle>
@grizmio
grizmio / gist:8e7965022fb47694fbc0a64365478229
Created January 20, 2023 03:58
zsh, oh my zsh and git plugin too slow
# https://github.com/ohmyzsh/ohmyzsh/issues/10175
DISABLE_UNTRACKED_FILES_DIRTY="true" in .zshrc
git config --global --add oh-my-zsh.hide-status 1
git config --global --add oh-my-zsh.hide-dirty 1