Skip to content

Instantly share code, notes, and snippets.

@dvlop
dvlop / gist:fca36213ad6237891609e1e038a3bbc1
Last active March 16, 2025 05:51 — forked from allthingsdem/gist:63b3223a7d14ac1f2457
My long list of bad bots to block in htaccess, ready to copy and paste!
# Start Bad Bot Prevention
<IfModule mod_setenvif.c>
# SetEnvIfNoCase User-Agent ^$ bad_bot
SetEnvIfNoCase User-Agent "^12soso.*" bad_bot
SetEnvIfNoCase User-Agent "^192.comAgent.*" bad_bot
SetEnvIfNoCase User-Agent "^1Noonbot.*" bad_bot
SetEnvIfNoCase User-Agent "^1on1searchBot.*" bad_bot
SetEnvIfNoCase User-Agent "^3D_SEARCH.*" bad_bot
SetEnvIfNoCase User-Agent "^3DE_SEARCH2.*" bad_bot
SetEnvIfNoCase User-Agent "^3GSE.*" bad_bot
@Tom-Millard
Tom-Millard / lazy-fonts.js
Created February 1, 2018 17:47
Lazy load google fonts
(function(d){
var x = d.createElement("link");
var y = d.getElementsByTagName("script")[0];
x.rel = "stylesheet";
x.href = "https://fonts.googleapis.com/css?family=Raleway:400,900";
y.parentNode.insertBefore(x, y);
})(document);
@dideler
dideler / bot.rb
Last active May 7, 2025 12:44
Sending a notification message to Telegram using its HTTP API via cURL
# Use this script to test that your Telegram bot works.
#
# Install the dependency
#
# $ gem install telegram_bot
#
# Run the bot
#
# $ ruby bot.rb
#
@DavidKuennen
DavidKuennen / minimal-analytics-snippet.js
Last active March 17, 2025 06:52
Minimal Analytics Snippet
(function (context, trackingId, options) {
const history = context.history;
const doc = document;
const nav = navigator || {};
const storage = localStorage;
const encode = encodeURIComponent;
const pushState = history.pushState;
const typeException = 'exception';
const generateId = () => Math.random().toString(36);
const getId = () => {
@janispritzkau
janispritzkau / analytics.js
Last active April 5, 2022 17:51
Minimal Google Analytics Script (677 bytes minified)
((document, location, navigator) => {
const domain = location.hostname.split(".")
const match = document.cookie.match(/(^|; ?)_ga=GA1\.\d\.(\d+\.\d+)(;|$)/)
// use existing client id or generate one
const cid = match ? match[2] : ~~(2147483648 * Math.random()) + "." + ~~(Date.now() / 1000)
// set cookie at highest possible domain level
for (let i = domain.length; i--;) {
const cookie = `_ga=GA1.${domain.length - i}.${cid}`
@Greg-Boggs
Greg-Boggs / purge_cf.php
Last active December 17, 2024 18:49
PHP code to Purge Cloudflare Cache
<?php
// Replace EMAIL/API_KEY/ZONE_ID with your details.
// Zone ID is on the dashboard for the domain in the bottom right.
// Api keys are generated from the account settings. You must give cache purge permissions
// Place this script on your webserver and point a Github Webhook at it, and you'll clear
// the Cloudflare cache every time you do a push to GH.
$zoneId = "xxx";
$apiKey = "xxx";
$email = "xxx";
@isaumya
isaumya / wpcspc_device_based_cache_cf_worker_template.js
Last active May 10, 2025 18:46
Custom Cloudflare Worker Code for Device Based Caching - WP Cloudflare Super Page Cache Plugin
/**
* Worker Name: WPCSPC - Device based Cache
* Description: This worker is responsible for caching the requests based on the device type
* Based on Default Worker Version: 2.8.0
* Version: 2.1.0
* @link: https://wordpress.org/plugins/wp-cloudflare-page-cache/
* @link: https://wordpress.org/support/topic/mobile-page-theme-and-cloudflare-caching-plugin-integration/
* @author: Saumya Majumder
*/
// Default cookie prefixes for cache bypassing
<?php
/**
* Check if the user has submitted the form.
*/
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
/**
* Print the $_FILES global variable. This will display the following:
* array(1) {
* ["myfiles"]=> array(6) {
@iamrony777
iamrony777 / bot.rb
Created December 21, 2021 14:35 — forked from dideler/bot.rb
Sending a notification message to Telegram using its HTTP API via cURL
# Use this script to test that your Telegram bot works.
#
# Install the dependency
#
# $ gem install telegram_bot
#
# Run the bot
#
# $ ruby bot.rb
#
@aaronsnoswell
aaronsnoswell / common-syllables.txt
Created February 5, 2022 12:59
The 322 most common syllables (ordered most common to least) in the 5000 most common English words
ing
er
a
ly
ed
i
es
re
tion
in