Skip to content

Instantly share code, notes, and snippets.

@bompus
bompus / gaWorker.js
Created September 3, 2023 03:44 — forked from xiaopc/gaWorker.js
Google Analytics 4 Proxy with Cloudflare Workers
// 2023.4.23 更新,修复 gtag.js 加了个回车导致失效的问题
// 2023.3.2 更新,修复上报到 region*.google-analytics.com 未被代理的问题
addEventListener('fetch', (event) => {
// 这里可以加 filter
return event.respondWith(handleRequest(event));
});
// worker 应用的路由地址,末尾不加 '/'
const DOMAIN = 'https://example.workers.dev/routerpath';
@bompus
bompus / AuthyToOtherAuthenticator.md
Last active November 13, 2022 22:05 — forked from gboudreau/AuthyToOtherAuthenticator.md
Export TOTP tokens from Authy
@bompus
bompus / epson-printer-utility.sh
Last active February 5, 2022 17:57 — forked from derde/epson-printer-utility.sh
Run epson-printer-utility_1.0.2-1lsb3.2_amd64.deb under ubuntu focal, providing missing libQtCore4
#! /bin/bash
# Run epson-printer-utility from epson-printer-utility_1.0.2-1lsb3.2_amd64.deb
# using downloaded libqt4 libraries from previous Ubuntu version (not provided
# in Ubuntu 20.04 "focal fossa"
#
# This downloads the deb files and extracts them in a libs directory in the
# current directory, and then runs the utility
#
# Fix for:
@bompus
bompus / cloudflare-ban.sh
Created January 15, 2019 01:59 — forked from bdtech/cloudflare-ban.sh
OSSEC active response to block an IP at the Cloudflare reverse proxy level who triggers errors in short time frame in nginx logs. Required: Ossec config: sample to block IPs with multiple 500 errors or 400 errors within a minute or two timeframe. /var/ossec/etc/ossec.conf <command> <name>cloudflare-ban</name> <executable>cloudflare-ban.sh</execu…
#!/bin/sh
# Adds an IP to Cloudflare IP block list
# Path: /var/ossec/active-response/bin/cloudflare-ban.sh
#
ACTION=$1
USER=$2
IP=$3
PWD=`pwd`
TKN='CF API KEY'
@bompus
bompus / jquery.external-links-new-window.js
Last active August 9, 2016 17:46 — forked from wpscholar/jquery.external-links-new-window.js
Open all external links in a new window
@bompus
bompus / criticalcss-bookmarklet-devtool-snippet.js
Created April 16, 2016 22:36 — forked from PaulKinlan/criticalcss-bookmarklet-devtool-snippet.js
CriticalCSS Bookmarklet and Devtool Snippet.js
(function() {
var CSSCriticalPath = function(w, d, opts) {
var opt = opts || {};
var css = {};
var pushCSS = function(r) {
if(!!css[r.selectorText] === false) css[r.selectorText] = {};
var styles = r.style.cssText.split(/;(?![A-Za-z0-9])/);
for(var i = 0; i < styles.length; i++) {
if(!!styles[i] === false) continue;
var pair = styles[i].split(": ");
@bompus
bompus / mongodb_collection_sizes.js
Last active August 29, 2015 14:27 — forked from joeyAghion/mongodb_collection_sizes.js
List mongodb collections in descending order of size. Helpful for finding largest collections. First number is "size," second is "storageSize."
var collectionNames = db.getCollectionNames(), stats = [];
collectionNames.forEach(function (n) { stats.push(db[n].stats()); });
(function(){ stats = stats.sort(function(a, b) { return b['size'] - a['size']; }); })();
for (var c in stats) { print(stats[c]['ns'] + ": " + stats[c]['size'] + " (" + stats[c]['storageSize'] + ")"); }