Skip to content

Instantly share code, notes, and snippets.

View ivanionut's full-sized avatar
🎯
Focusing

Ivan Ionut ivanionut

🎯
Focusing
View GitHub Profile
@fhferreira
fhferreira / nginx-proxy.conf
Created August 16, 2019 02:52
Proxy nginx to use Google Tag Manager
# Google Analytics Bypassing Adblockers
## Client
change www.googletagmanager.com => your.domain.com
```
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://your.domain.com/gtag/js?id=UA-123456789-1"></script>
```
@JamoCA
JamoCA / isValidIPAddress_UDF.cfm
Last active April 9, 2020 13:36
ColdFusion UDF to test string to determine if valid IP address or not.
<!--- 20190801
ColdFusion UDF to test string to determine if valid IP address or not.
https://www.anujgakhar.com/2008/02/21/validate-ip-address-natively-with-coldfusion/ --->
<cfscript>
function isValidIPAddress(inputString){
var response = false;
var IPAddressUtils = createObject("java","coldfusion.util.IPAddressUtils");
response = javacast("boolean", IPAddressUtils.validateIPAdress( javacast("string", arguments.inputString) ));
if (response and listfind("0.0.0.0,255.255.255.255", javacast("string", arguments.inputString))){
@JamoCA
JamoCA / normalizeUTF.cfc
Created June 14, 2019 15:04
ColdFusion script to normalize UTF characters by combining character sequences into a single character
<cfscript>
/* NFKC: UTF Compatibility Decomposition, followed by Canonical Composition */
/* Recommend using Junidecode https://gist.github.com/JamoCA/6565bd4e2526b7c177a5f0cde3980d1c */
function normalizeUTF(inputString){
var normalizer = createObject( "java", "java.text.Normalizer" );
var normalizerForm = createObject( "java", "java.text.Normalizer$Form" );
return normalizer.normalize( javaCast( "string", arguments.inputString ), normalizerForm.NFKC );
}
</cfscript>
@JamoCA
JamoCA / ExistsLen_UDF.cfm
Created April 3, 2019 21:17
Pass a variable name to determine if it exists and has len/arraylen/structcount/recordcount
<cfscript>
/* 11/28/2017 Checks to see if item exists and has len/arraylen/structcount/recordcount */
function ExistsLEN(theVariable){
var tempVal = "";
if (LEN(TRIM(theVariable)) AND isDefined(theVariable) AND isSimpleValue(theVariable)){
tempVal = evaluate(theVariable);
if (isSimpleValue(tempVal) AND LEN(trim(tempVal))){
return true;
} else if (isArray(tempVal) AND ArrayLen(tempVal)){
return true;
@kreativan
kreativan / dropzone.php
Last active November 9, 2024 10:51
Upload files with dropzone.js and php
<?php
// process $_POST request
if(isset($_POST["submitDropzone"])) {
// Do something
print_r($_POST);
}
?>
@Julian-Nash
Julian-Nash / flask_sitemap_generator.py
Last active March 31, 2025 10:44
Flask dynamic sitemap generator
@app.route("/sitemap")
@app.route("/sitemap/")
@app.route("/sitemap.xml")
def sitemap():
"""
Route to dynamically generate a sitemap of your website/application.
lastmod and priority tags omitted on static pages.
lastmod included on dynamic content such as blog posts.
"""
from flask import make_response, request, render_template
@JamoCA
JamoCA / HTMLParagraphFormat.cfm
Last active April 25, 2019 07:40
HTMLParagraphFormat - Replaces ColdFusion ParagraphFormat Tag. (Influenced by 3 other UDFs.)
<cfscript>
/* 20190920 HTMLParagraphFormat
https://gist.github.com/JamoCA/442fc15b4714b848f9882e840185b256
Based on prior examples from:
https://cfdocs.org/paragraphformat
https://www.petefreitag.com/item/344.cfm Pete Freitag May 06, 2005
https://cflib.org/udf/XHTMLParagraphFormat Jeff Howden ([email protected]) 1, July 2, 2008
https://cflib.org/udf/ParagraphFormat2 Ben Forta ([email protected]) June 26, 2002
Returns text wrapped in properly formatted paragraph <p> tags.
@param string String you want formatted. (Required)
@Lathanao
Lathanao / Install Mozjpeg 4 on Debian Ubuntu Mint
Last active September 11, 2024 20:32 — forked from Kelfitas/mozjpeg-install-debian
Install Mozjpeg 4 on debian / Ubuntu
#!/bin/bash
echo ""
echo "---------------------------------"
echo "| AUTO COMPILE MOZJPEG |"
echo "---------------------------------"
echo ""
echo "Apt update"
sudo apt update && apt upgrade && apt remove $(deborphan) && apt autoremove && apt clean
echo "Update"
sudo apt update
@anthumchris
anthumchris / README.md
Last active September 25, 2022 19:04
Clear Nginx Cache

Clearing Nginx's HTTP Cache

I recently implemented Nginx HTTP content caching on our WordPress web servers to improve page load speeds and eliminate redundant, unneeded server-side page rendering. Caching the pages was relatively straightforward, but clearing the cache required a custom workaround.

Nginx comes in two versions: free and “Nginx Plus” at $2,500/year. The free version of Nginx does not offer the needed cache-clearing features of Nginx Plus, and I wasn’t comfortable paying $20,000 for 8 instances without trying to build my own solution.

Our Nginx servers run as an HTTP proxy for multiple PHP/MySQL-backed WordPress sites. The goal was to cache the dynamic PHP HTML responses in Nginx and serve the HTML pages from Nginx to avoid redundant, CPU-intensive PHP renders.

Site Cache Configuration

The example below shows how PHP response caching is configured for a site (other nginx configuration details are excluded for brevity). A cache named cachedemo-prod is defined to store cached HTML f

@1hakr
1hakr / example.com
Last active November 29, 2024 20:48
Supercharge your NGIX config
proxy_cache_path /tmp/cacheapi levels=1:2 keys_zone=microcacheapi:100m max_size=1g inactive=1d use_temp_path=off;
server {
listen 443 ssl http2 default_server;
listen [::]:443 ssl http2 default_server;
server_name example.com;
location /api/ {
# Rate Limiting
limit_req zone=reqlimit burst=20; # Max burst of request