Skip to content

Instantly share code, notes, and snippets.

View dannluciano's full-sized avatar
🏠
Working from home

Dann Luciano dannluciano

🏠
Working from home
View GitHub Profile
@dannluciano
dannluciano / README.md
Created October 21, 2024 00:00 — forked from iosifnicolae2/README.md
How to Create a Dynamic ModelForm in Django Admin to Display Dynamic Columns
image
class OrganizationMaterialVariantPriceForm(ModelForm):
    def __init_subclass__(cls, **kwargs):
        if cls.__name__ == OrganizationMaterialVariantPriceForm.__name__:
            for color in Color.objects.all():
                field_name = f'color_{color.slug}'
                cls.declared_fields[field_name] = IntegerField(
                    label=color.name,

Refs:

// Init new db
// If the database file does not exist, it is created
// This happens synchronously, which means you can start executing queries right away
const Database = require('better-sqlite3');
@dannluciano
dannluciano / GNUPG Cheatsheet.md
Created March 6, 2024 16:27 — forked from turingbirds/GNUPG Cheatsheet.md
GPG (GNUPG) Cheatsheet

GNUPG CHEATSHEET

Setting up: key generation

This generates a public/private keypair.

$ gpg --gen-key

$ gpg --list-secret-keys

@dannluciano
dannluciano / generate_openssl_selfsigned_certificate.sh
Created December 22, 2023 12:25
Generate Openssl Self-Signed Certificate
#! /bin/bash
openssl req -x509 -sha256 -nodes -newkey rsa:4096 -keyout priv.key -days 3660 -out cert.pem -subj "/C=XX/O=Default Company/OU=XX/CN=selfsigned.ssh3" -addext "subjectAltName = DNS:selfsigned.ssh3,DNS:*"
@dannluciano
dannluciano / build.sh
Created July 17, 2023 20:01 — forked from WesleyAC/build.sh
Simple rust build and deploy script — https://blog.wesleyac.com/posts/simple-deploy-script
#!/usr/bin/env bash
cd $(dirname $0)
docker run --rm -it -v "$(pwd)":/home/rust/src -v cargo-git:/home/rust/.cargo/git -v cargo-registry:/home/rust/.cargo/registry -v "$(pwd)/target/":/home/rust/src/target ekidd/rust-musl-builder:nightly-2021-01-01 sudo chown -R rust:rust /home/rust/.cargo/git /home/rust/.cargo/registry /home/rust/src/target
docker run --rm -it -v "$(pwd)":/home/rust/src -v cargo-git:/home/rust/.cargo/git -v cargo-registry:/home/rust/.cargo/registry -v "$(pwd)/target/":/home/rust/src/target ekidd/rust-musl-builder:nightly-2021-01-01 cargo build --release

macOS Internals

Understand your Mac and iPhone more deeply by tracing the evolution of Mac OS X from prelease to Swift. John Siracusa delivers the details.

Starting Points

How to use this gist

You've got two main options:

@dannluciano
dannluciano / 55-bytes-of-css.md
Created September 25, 2022 23:11 — forked from JoeyBurzynski/55-bytes-of-css.md
58 bytes of css to look great nearly everywhere

58 bytes of CSS to look great nearly everywhere

When making this website, i wanted a simple, reasonable way to make it look good on most displays. Not counting any minimization techniques, the following 58 bytes worked well for me:

main {
  max-width: 38rem;
  padding: 2rem;
  margin: auto;
}
@dannluciano
dannluciano / fix-microphone-background-noise.sh
Created February 4, 2022 14:28 — forked from adrianolsk/fix-microphone-background-noise.sh
FIx linux microfone background noise
# Microphone Realtime background noise reduction script
# author Luigi Maselli - https://grigio.org licence: AS-IS
# credits: http://askubuntu.com/questions/18958/realtime-noise-removal-with-pulseaudio
# run as: sudo && pulseaudio -k
# wget -qO - https://gist.github.com/adrianolsk/bfa32f3227dc674eff72a2008f6c0316 | sudo bash && pulseaudio -k
sudo cp /etc/pulse/default.pa /etc/pulse/default.pa.bak
sudo cat <<EOT >> /etc/pulse/default.pa
load-module module-echo-cancel source_name=noechosource sink_name=noechosink
@dannluciano
dannluciano / columns.sql
Created December 7, 2021 19:48
PostgreSQL util queries
-- Adapted from information_schema.columns
SELECT
c.oid :: int8 AS table_id,
nc.nspname AS schema,
c.relname AS table,
(c.oid || '.' || a.attnum) AS id,
a.attnum AS ordinal_position,
a.attname AS name,
CASE
@dannluciano
dannluciano / Cesar.java
Created December 7, 2021 19:44
Cifra de Cesar
import java.util.Scanner;
public class Cesar {
public static void main(String[] args) {
Scanner teclado = new Scanner(System.in);
char[] mapa = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".toCharArray();
int chave = 26;
while (chave < 0 || chave > 25) {