Skip to content

Instantly share code, notes, and snippets.

View danigunawan's full-sized avatar
🏸
sehat+i

Dani Gunawan danigunawan

🏸
sehat+i
View GitHub Profile
@danigunawan
danigunawan / gist:2359ed4c82e6850ec71aec7c896c8a7f
Created February 22, 2023 17:25 — forked from bartread/gist:d169a4416cefc306a666e2fec2f62eb3
Bash script for installing systemd service on Ubuntu
#! /bin/sh
# Other deployment actions here. Want to install (or bounce) service last.
if [ -f /etc/systemd/system/arcadely.service ]; then
sudo systemctl stop arcadely.service
sudo systemctl disable arcadely.service
else
sudo \cp -f ./arcadely.service /etc/systemd/system/arcadely.service
fi
@danigunawan
danigunawan / create-service.sh
Created February 22, 2023 17:25 — forked from ahmedsadman/create-service.sh
Bash script to create systemd service
#!/usr/bin/bash
##
## Creates Service file based on JSON data
##
# Sample JSON file:
# {
# "service_name": "test_service",
# "description": "Netcore dev server",
@danigunawan
danigunawan / install-docker.sh
Created February 13, 2023 02:21 — forked from p3jitnath/install-docker.sh
Docker and Nvidia Docker installation in Ubuntu 20.04 LTS
# WARNING : This gist in the current form is a collection of command examples. Please exercise caution where mentioned.
# Docker
sudo apt-get update
sudo apt-get remove docker docker-engine docker.io
sudo apt install docker.io
sudo systemctl start docker
sudo systemctl enable docker
docker --version
@danigunawan
danigunawan / README-setup-tunnel-as-systemd-service.md
Created February 1, 2023 05:40 — forked from drmalex07/README-setup-tunnel-as-systemd-service.md
Setup a secure (SSH) tunnel as a systemd service. #systemd #ssh #ssh-tunnel #ssh-forward

README

Create a template service file at /etc/systemd/system/secure-tunnel@.service. The template parameter will correspond to the name of target host:

[Unit]
Description=Setup a secure tunnel to %I
After=network.target
@danigunawan
danigunawan / System Design.md
Created January 30, 2023 09:06 — forked from vasanthk/System Design.md
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@danigunawan
danigunawan / nginx-tuning.md
Created September 1, 2022 11:22 — forked from denji/nginx-tuning.md
NGINX tuning for best performance

Moved to git repository: https://github.com/denji/nginx-tuning

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

@danigunawan
danigunawan / MysqlTunnerOnDocker.sh
Created August 2, 2022 15:52
MySQL Tunner On Docker
# MySQLTuner: https://github.com/major/MySQLTuner-perl
# Open Bash with the container.
docker exec [mariadb_or_mysql] bash
# Change the working directory to `/tmp`.
cd /tmp
# Install wget.
apt-get update
@danigunawan
danigunawan / html_mail.py
Created January 18, 2022 00:31 — forked from ehrenfeu/html_mail.py
Use Python to send HTML emails with expand/collapse boxes working in TB and Android
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
def send_html_mail(subject, body, to_addr, from_addr):
"""Send an HTML email using the given subject, body, etc."""
# Create message container - the correct MIME type is multipart/alternative here!
message = MIMEMultipart('alternative')
message['subject'] = subject
@danigunawan
danigunawan / server.py
Created June 2, 2021 03:12 — forked from brizandrew/server.py
Simple Flask Webhook Example
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from flask import Flask, request
from urllib import unquote_plus
import json
import re
app = Flask(__name__)