Skip to content

Instantly share code, notes, and snippets.

View socheatsok78's full-sized avatar
🖖
༼ つ ◕_◕ ༽つ is having a baby

Socheat Sok socheatsok78

🖖
༼ つ ◕_◕ ༽つ is having a baby
View GitHub Profile
@socheatsok78
socheatsok78 / 00-README.md
Last active June 23, 2023 10:13
The Twelve Factors Extended - https://12factor.net/

The Twelve Factors

https://12factor.net/

In the modern era, software is commonly delivered as a service: called web apps, or software-as-a-service. The twelve-factor app is a methodology for building software-as-a-service apps that:

  • Use declarative formats for setup automation, to minimize time and cost for new developers joining the project;
  • Have a clean contract with the underlying operating system, offering maximum portability between execution environments;
  • Are suitable for deployment on modern cloud platforms, obviating the need for servers and systems administration;
  • Minimize divergence between development and production, enabling continuous deployment for maximum agility;
@socheatsok78
socheatsok78 / lockrun.c
Created January 2, 2022 12:51
lockrun - Run cron job with overrun protection - http://unixwiz.net/tools/lockrun.html
/*
* $Id: //websites/unixwiz/unixwiz.net/webroot/tools/lockrun.c#8 $
*
* written by : Stephen J. Friedl
* Software Consultant
* Southern California USA
* [email protected]
* http://www.unixwiz.net/tools/
*
* ===================================================================
@socheatsok78
socheatsok78 / README.md
Created January 2, 2022 09:22
Reset sytemd `/etc/machine-id`

Re-Initialize the machine ID in /etc/machine-id.

sudo truncate -s 0 /etc/machine-id
@socheatsok78
socheatsok78 / README.md
Last active June 4, 2025 07:10
A `systemd` service for regenerate SSH host keys as oneshot

A systemd service for regenerate SSH host keys as oneshot

sudo nano /etc/systemd/system/regenerate-ssh-host-keys.service
sudo chown root:root /etc/systemd/system/regenerate-ssh-host-keys.service
sudo systemd daemon-reload
sudo systemctl enable regenerate-ssh-host-keys.service

Note: Do not start the service since the ExecStartPost will disable the service itself once started.

@socheatsok78
socheatsok78 / dump-maas-test-db.sh
Created December 31, 2021 13:44
Create a database dump of MAAS `maas-test-db`
export PGPASS=$(sudo awk -F':\\s+' '$1 == "database_pass" {print $2}' /var/snap/maas/current/regiond.conf)
pg_dump -U maas -h /var/snap/maas-test-db/common/postgres/sockets -d maasdb -F t -f maasdb-dump.tar

Dumping

Use the directory output format because it works better with incremental backups and is most flexible when restoring.

Do not compress because the overwhelming majority of the contents of the MAAS database is already compressed images. For a MAAS installation with one image the saving due to compression was only 1.7% but the dump took noticeably longer. With more images the ratio of already-compressed to not-compressed data goes up, and the savings will likely drop.

@socheatsok78
socheatsok78 / README.md
Last active January 3, 2022 09:05
Soramitsu Khmer On-boarding Experience

Soramitsu Khmer On-boarding Experience

@socheatsok78
socheatsok78 / README.md
Last active November 13, 2021 04:16
Solving VirtualBox “kernel driver not installed (rc=-1908)” Error on macOS

Solving VirtualBox “kernel driver not installed (rc=-1908)” Error on macOS

sh -c "$(curl -fsSL https://git.io/JXAE9)"
@socheatsok78
socheatsok78 / system-theme.js
Created November 10, 2021 10:30
Get a callback when the user changes theme
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', ({matches: isDark}) => {
console.log('isDark', isDark)
})