Skip to content

Instantly share code, notes, and snippets.

@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
@grizmio
grizmio / SonarQube howto
Last active January 19, 2023 15:33
SonarQube 8.9.6
First, the server
docker run -d --name sonarqube -p 8000:8000 -p 9000:9000 sonarqube:8.9.6-community
Then login with admin:admin
http://127.0.0.1:9000
Create the project and its token
An example for running the scanner with docker
sudo cat /var/log/audit/audit.log | audit2why
@grizmio
grizmio / unnecesary
Created October 23, 2022 19:32
Typescript traducciones en un enum, y no más strings weando
Lo uso con expo/reactnative, pero sirve para cualquier proyecto con typescript
Para agregar las traducciones, agregar al:
enum Words {
Después los archivos de traducciones ingles y español llorarán
// I18nService.ts
import * as Localization from 'expo-localization';
import { I18n } from 'i18n-js';
import { ITranslationLanguage } from '../interfaces/ITranslationLanguage';
@grizmio
grizmio / scoop commands.ps1
Created August 18, 2022 03:53
scoop commands
scoop cleanup '*'
scoop cache rm '*'
scoop update '*'
@grizmio
grizmio / jwt show command line
Created August 11, 2022 04:03
jwt show command line
Thanks: https://prefetch.net/blog/2020/07/14/decoding-json-web-tokens-jwts-from-the-linux-command-line/
jq -R 'split(".") | .[0],.[1] | @base64d | fromjson' <<< $(cat "${JWT}")