Skip to content

Instantly share code, notes, and snippets.

View karnzx's full-sized avatar
😆
HI ~

Piravit Chenpittaya karnzx

😆
HI ~
View GitHub Profile
@karnzx
karnzx / create cloudflare nginx conf realip.md
Created March 4, 2024 10:55
create nginx config realip for Cloudflare

create nginx config realip for Cloudflare

nginx_conf_cloudflare_real_ip.sh

CF_CFG=/tmp/nginx-realip.conf.$RANDOM
CF_V4=$(curl -s https://www.cloudflare.com/ips-v4)
CF_V6=$(curl -s https://www.cloudflare.com/ips-v6)

cat << 'EoF' > ${CF_CFG}
real_ip_recursive on;
@karnzx
karnzx / get_aws_private_ip_on_vpc.md
Last active March 4, 2024 10:48
Get AWS used private IP on each subnet by given VPC_ID

Get AWS used private IP on each subnet by given VPC_ID

get private ip address used on each subnet but given vpc id on AWS provider

requirements

  • aws
  • jq

get_private_ip.sh

#!/bin/bash
@karnzx
karnzx / Simple Vagrantfile for create multiple vm with virtualbox provider.md
Created January 3, 2024 10:24
auto provision 2 Debian VMs on virtualbox using vagrant

Simple Vagrantfile for create multiple vm with virtualbox provider

what is this Vagrantfile do

Create 2 Linux Debian 12 bookworm VMs

name IP
vm-1 192.168.56.101
vm-2 192.168.56.102

prerequisite

@karnzx
karnzx / simple-echo-in-color.sh
Created August 7, 2023 17:07
bash echo function to print text but with color and style
_print(){
if [[ -z "$1" ]]; then
local funcname=${FUNCNAME[0]}
echo -e "Usage:"
echo -e "$funcname texts (bold|faint|italic|underline) (red|green|yellow|white)"
echo -e "Try:"
echo -e "$funcname hello"
echo -e "$funcname hello bold"
echo -e "$funcname hello bold red"
fi
@karnzx
karnzx / sonarqube_scanner.sh
Last active August 1, 2022 16:28
Analysis Code Quality and Code Security using sonarQube (linux or wsl docker). This bash script provide 2 function "sonarQube" for server and "sonarScan" for scan your projects, simply load into your terminal.
#!\bin\bash
RED="\033[31m"
YELLOW="\033[33m"
GREEN="\033[32m"
RESET="\033[0m"
print_yellow() {
echo -e "${YELLOW}${1}${RESET}"
}
from flask import Flask
app = Flask(__name__)
@app.route('/')
def index():
return "Hello world!"
if __name__ == '__main__':
app.debug = True
@karnzx
karnzx / Main.java
Last active February 13, 2021 07:43
import java.util.*;
class Shape {
private String name;
public Shape(String name) {
this.name = name;
}
public String getName() {
class A {
private int x;
public A(int x) {
this.x = x;
System.out.println("A");
}
public void foo() {
System.out.println(x);
@karnzx
karnzx / map.html
Created March 26, 2020 16:53
Medium Brython add flyto function, click event
{% extends '/base-map.html' %}
{% block body %}
<div>
<p id="coords"></p>
<div>
<button id="chiangmai">ไปเชียงใหม่</button>
<button id="hatyai">ไปหาดใหญ่</button>
<button id="bankkok">ไปกรุงเทพ</button>
</div>
<div id="mapid" style="margin: 1em;"></div>
@karnzx
karnzx / map.html
Created March 26, 2020 16:45
Medium brython change center to thailand, edit zoom, add bankok and chiang mai marks
{% extends '/base-map.html' %}
{% block body %}
<div>
<p id="coords"></p>
<div id="mapid" style="margin: 1em;"></div>
</div>
<script type="text/python">
from browser import alert, document, window, html