Skip to content

Instantly share code, notes, and snippets.

View muratgozel's full-sized avatar

Murat Gözel muratgozel

View GitHub Profile
@muratgozel
muratgozel / setup_nginx.sh
Last active July 29, 2023 09:51
setup nginx latest version on ubuntu.
#!/bin/bash
sudo apt install curl gnupg2 ca-certificates lsb-release ubuntu-keyring
curl https://nginx.org/keys/nginx_signing.key | gpg --dearmor | sudo tee /usr/share/keyrings/nginx-archive-keyring.gpg >/dev/null
gpg --dry-run --quiet --no-keyring --import --import-options import-show /usr/share/keyrings/nginx-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] http://nginx.org/packages/ubuntu `lsb_release -cs` nginx" | sudo tee /etc/apt/sources.list.d/nginx.list
echo -e "Package: *\nPin: origin nginx.org\nPin: release o=nginx\nPin-Priority: 900\n" | sudo tee /etc/apt/preferences.d/99nginx
sudo apt update
sudo apt install nginx
@muratgozel
muratgozel / setup_docker_compose.sh
Last active June 17, 2022 09:29
setup docker and docker-compose.
#!/usr/bin/env bash
apt install -y apt-transport-https ca-certificates curl gnupg lsb-release
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
apt update
apt install -y docker-ce docker-ce-cli containerd.io
/bin/cat <<EOM >/etc/docker/daemon.json
{
"metrics-addr" : "127.0.0.1:9323",
@muratgozel
muratgozel / constants.js
Last active December 15, 2021 10:34
Sheet size and cost computation of the machine.
function constants() {
const data = {
T: { // levha kalınlıkları
single: 3,
double: 5
},
tCostFactor: { // levha maliyetleri
single: 5.5,
double: 8.5
},
@muratgozel
muratgozel / findDockerServiceIdByName.js
Created October 27, 2021 14:15
Find docker service id by service name in docker compose.
import {execSync} from 'child_process'
const service = 'some_service'
const containerId = execSync(`docker ps -f name=${service} --quiet`).toString().trim()
// filtering something by its lifetime with slonik
const filterByLifetimeQuery = sql`
select id
from eventlog
where
code=${code} and
payload=${sql.json(payload)} and
created_at + interval '1 second' * ${parseInt(ctx.threshold)} > now()
`
user nginx;
worker_processes auto;
error_log syslog:server=unix:/dev/log notice;
pid /var/run/nginx.pid;
#load_module modules/ngx_http_brotli_filter_module.so;
#load_module modules/ngx_http_brotli_static_module.so;
events {
worker_connections 1024;
@muratgozel
muratgozel / configure_directory_permissions.sh
Last active November 2, 2020 09:37
Configure existing and future file and folder user and group permissions recursively in linux.
#!/bin/bash
SAMPLE_DIR=/mnt/some-volume
# change ownership of the directory and all of its contents
chown -R cmsman:cmsteam $SAMPLE_DIR
# change permissions of the directory and all of its contents
chmod -R u=rwX,g=rwX,o-rwx $SAMPLE_DIR
# set uid and gid
chmod -R u+s $SAMPLE_DIR
@muratgozel
muratgozel / gen_rsa_key_pair.sh
Created October 26, 2020 15:57
Generate RSA private and public key pair with OpenSSL.
openssl genrsa -out cms_auth_key.pem 4096
openssl rsa -in cms_auth_key.pem -outform PEM -pubout -out cms_auth_key_public.pem
@muratgozel
muratgozel / cross-browser-performance-library.js
Created February 9, 2020 10:39
Tiny, cross browser frontend performance checking library.
/*
*
* Purformance
*
* Simply use mark and measure methods similar to native performance api.
*
* Native performance methods are not supported by browsers
* and there is no better way to measure performance than Date.getTime()
* in those cases.
*
@muratgozel
muratgozel / resolving_no_space_left_error.md
Created January 29, 2020 09:27
Resolving no space left on device error.

Check which filesystem doesn't have any space left:

sudo df -h

Check which folder uses this space most:

sudo find / -xdev -printf '%h\n' | sort | uniq -c | sort -k 1 -n