Skip to content

Instantly share code, notes, and snippets.

@pujianto
pujianto / tailwind-webpack-setup.md
Created October 20, 2023 05:50 — forked from bradtraversy/tailwind-webpack-setup.md
Setup Webpack with Tailwind CSS

Webpack & Tailwind CSS Setup

Create your package.json

npm init -y

Create your src folder

Create a folder called src and add an empty index.js file. The code that webpack compiles goes in here including any Javascript modules and the main Tailwind file.

@pujianto
pujianto / nginx-static-files.conf
Created March 31, 2022 04:16
WHM Serve static files directly from Nginx and fallback to apache if file no found. (WHM with Nginx Proxy Installed)
# Place this file inside /etc/nginx/conf.d/server-includes/
location @httpd_fallback {
proxy_pass $scheme://$CPANEL_APACHE_PROXY_REQ_IP:$CPANEL_APACHE_PROXY_REQ_PORT;
}
location ~ \.(gif|jpg|jpeg|png|css|js|svg|webm|webp)$ {
expires 30d;
add_header Vary Accept-Encoding;
access_log off;
@pujianto
pujianto / 100-nginx-post-update
Last active August 10, 2022 04:33
Auto-update Nginx Brotli dynamic modules after apt upgrade on Ubuntu & CentOS https://devopsan.com/how-to-install-auto-upgrade-nginx-brotli-module-on-ubuntu/
# Ubuntu & Debian
# Store this file as /etc/apt/apt.conf.d/100-nginx-post-update
DPkg::Post-Invoke {"/usr/local/bin/ngx_brotli"; };
@pujianto
pujianto / gist:fd0d631c496502b19670eee59a8aa54a
Created January 19, 2022 12:42
Generate dhparam in fast mode
openssl dhparam -dsaparam -out ./dhparam.pem 4096
@pujianto
pujianto / mongo.js
Created January 11, 2022 19:27
Get database name from Mongo/Mysql URL
// dbUrl example: mongodb://user:[email protected]/MyDB?authsource=admin
const getDatabaseName = (dbUrl) => url.parse(dbUrl).pathname.substring(1);
@pujianto
pujianto / python split_xml.py
Last active December 26, 2021 21:34
Splits an XML file into multiple files
#!/bin/env python
import logging
import os
from lxml.etree import iterparse, tostring
def split_xml(xml_source, rows_per_file, output_dir):
"""
Splits an XML file into multiple files.
@pujianto
pujianto / venv_upgrade.sh
Last active December 17, 2021 07:29
Lazy solution to reinstall your Python libraries inside your PEW virtualenv wrapper or plain virtualenv
#!/bin/sh
# THIS SCRIPT IS INTENDED FOR ROLLING RELEASE DISTRO USERS.
# Sometimes my local libraries didn't work after upgrading my Python, so I decided to write this helper script.
#
# Usage:
# venv_upgrade [options]
#
# Options:
# -h, --help Show this help message.
# -p, --path Path to your virtualenv.
@pujianto
pujianto / wp_download.sh
Created August 7, 2021 07:30
Download the latest WordPress version & extract it on the fly
curl -s -L https://wordpress.org/latest.tar.gz | tar -xzC /path/to/your/wordpress-site --strip-components 1
@pujianto
pujianto / gist:d23ddd8b6790af4768cec6928d68e748
Created July 11, 2021 10:30
Simple python smtp server for debugging
python -m smtpd -c DebuggingServer -n 0.0.0.0:1025
@pujianto
pujianto / yourdomain.tld.conf
Last active August 16, 2021 16:58
NGINX SSL/TLS CIPHER CONFIGURATION; A+ Score on https://www.ssllabs.com/
server {
listen 443 ssl http2;
server_name yourdomain.tld www.yourdomain.tld;
ssl_certificate /etc/nginx/tls.d/yourdomain.tld.crt;
ssl_certificate_key /etc/nginx/tls.d/yourdomain.tld.key;
ssl_session_cache shared:yourdomain:10m;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
ssl_stapling on;