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 / README.md
Last active April 30, 2024 16:47
Debian installer preseed PCI compliant minimal

root password: Us3-th3-F0rc3

expects a vm with 20G of disk (more is better), bios mode.

it is designed for deploying small virtual servers with intention to run an application/service.

normally, u deploy your artifact in /opt/[servicename] and you configure it for statefull data in /var/opt/[servicename].

application/service logs should go in /var/log/[servicename]

@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 jjsquady/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

@madalinignisca
madalinignisca / 00-README.md
Last active November 24, 2023 06:41
Minimal cloud init suitable for any public cloud server instance

Cloud init snippets

Mostly used by me for Hetzner cloud, but should work with all Public Cloud server providers.

  • cloud-init.yml
    • please ensure to set your user, group for the normal user you want to use
    • ssh_import_id can be used with github usernames instead of ssh_authorized_keys
    • disable_root: true ensures root can't ssh in
  • optionally add a sshd extra config that will secure more; tweak TcpForwarding and PermitTunnel as your requiments are!