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 / vite.config.js
Last active July 16, 2023 10:04
silence dart-sass / npm sass DEPRECATION WARNING: Using / for division outside of calc() is deprecated and will be removed in Dart Sass 2.0.0.
// silence dart-sass / npm sass DEPRECATION WARNING: Using / for division outside of calc() is deprecated and will be removed in Dart Sass 2.0.0.
const silenceSomeSassDeprecationWarnings = {
verbose: true,
logger: {
warn(message, options) {
const { stderr } = process;
const span = options.span ?? undefined;
const stack = (options.stack === 'null' ? undefined : options.stack) ?? undefined;
@bompus
bompus / ..install.txt
Last active October 30, 2021 18:06
bash local aliases / per-directory aliases in bash
// download .bash_local_aliases file and cd to the download directory
$ cp .bash_local_aliases ~/
$ if ! grep -qF 'source ~/.bash_local_aliases' ~/.bashrc; then echo -e "\nsource ~/.bash_local_aliases" >> ~/.bashrc; fi
$ source ~/.bash_local_aliases && cd .
// place a .aliases file anywhere, in the space-delimited "alias command" format shown in the .aliases example in this gist
// IMPORTANT: .aliases file should end with a single blank, empty line
$ cd .
@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 / cloudSettings
Last active September 28, 2020 15:20
Visual Studio Code Settings Sync Gist
{"lastUpload":"2020-09-28T15:20:26.168Z","extensionVersion":"v3.4.3"}
@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'] + ")"); }