Skip to content

Instantly share code, notes, and snippets.

View madalinignisca's full-sized avatar
🏡
Open for business

Madalin Ignisca madalinignisca

🏡
Open for business
View GitHub Profile
@madalinignisca
madalinignisca / ufw.md
Created June 15, 2024 19:19 — forked from kimus/ufw.md
NAT and FORWARD with Ubuntu’s ufw firewall

UFW

I use Ubuntu’s Uncomplicated firewall because it is available on Ubuntu and it's very simple.

Install UFW

if ufw is not installed by default be sure to install it first.

@madalinignisca
madalinignisca / debian-preseed-simple.cfg
Last active May 13, 2024 09:45
Debian installer preseed PCI compliant minimal
d-i debian-installer/locale string en_US.UTF-8
d-i debian-installer/language string en
d-i debian-installer/country string ES
d-i keyboard-configuration/xkb-keymap select us
d-i netcfg/choose_interface select auto
d-i hw-detect/load_firmware boolean true
d-i mirror/protocol string http
@madalinignisca
madalinignisca / pgdata.md
Created April 2, 2024 19:25
PostgreSQL data directory structure

If you can connect using psql, then you can use this command:

postgres=# SHOW data_directory;
data_directory
-----------------------
/opt/postgres/data/

| directory | description |

@madalinignisca
madalinignisca / rename.sql
Created March 27, 2024 22:23
Rename schema to public in a postgresql database
BEGIN TRANSACTION;
ALTER SCHEMA public RENAME TO public_original;
ALTER SCHEMA my_db RENAME TO public;
DROP SCHEMA public_original CASCADE;
COMMIT;
@madalinignisca
madalinignisca / handle_not_found_404.go
Created February 19, 2024 15:17
GO net/http tips
package main
import (
"fmt"
"net/http"
)
func helloWorld(w http.ResponseWriter, r *http.Request) {
// this is what you want
if r.URL.Path != "/" {
@madalinignisca
madalinignisca / 01_nginx-reload-post-hook.sh
Created January 2, 2024 09:00 — forked from justinhartman/01_nginx-reload-post-hook.sh
Let's Encrypt Certbot post hook command for Nginx which checks the updated configuration files and reloads the server if everything validates.
#!/usr/bin/env bash
#
# Certbot Nginx Reload
#
# Let's Encrypt Certbot post hook command for Nginx which checks the updated
# configuration files and reloads the server if everything validates.
#
# Author : Justin Hartman <code@justinhartman.co>
# Version : 1.0.1
# License : MIT <https://opensource.org/licenses/MIT>
@madalinignisca
madalinignisca / hideunhideitemsmacosdesktop.sh
Created November 25, 2023 10:00
Hide / UnHide items on MacOS Desktop
# This will hide
defaults write com.apple.finder CreateDesktop -bool false; killall Finder
# This will show them back
defaults write com.apple.finder CreateDesktop -bool true; killall Finder
@madalinignisca
madalinignisca / ST_Epgs3857_DWithin.sql
Created November 13, 2023 18:33 — forked from Tylerian/ST_Epgs3857_DWithin.sql
ST_DWithin function implementation for MySQL 8.0
-- Made by Jairo Tylera
-- (github.com/Tylerian)
-- (c) 2019 - present
-- Released under MIT X11 License
CREATE
DEFINER=`root`@`localhost`
FUNCTION
`ST_Epgs3857_DWithin`(p1 POINT, p2 POINT, distance_mts FLOAT)
RETURNS
@madalinignisca
madalinignisca / nextjs-deploy.md
Created November 9, 2023 20:06 — forked from jjcodes78/nextjs-deploy.md
Deploying NEXTJS site with nginx + pm2

How to setup next.js app on nginx with letsencrypt

next.js, nginx, reverse-proxy, ssl

1. Install nginx and letsencrypt

$ sudo apt-get update
$ sudo apt-get install nginx letsencrypt

Also enable nginx in ufw

Discover

SELECT CEILING(Total_InnoDB_Bytes*1.6/POWER(1024,3)) RIBPS FROM
(SELECT SUM(data_length+index_length) Total_InnoDB_Bytes
FROM information_schema.tables WHERE engine='InnoDB') A;

Take the value and set it as innodb_buffer_pool_size sufixed with G, example 20G