Skip to content

Instantly share code, notes, and snippets.

View andrewbrg's full-sized avatar

Andrew Borg andrewbrg

View GitHub Profile
@andrewbrg
andrewbrg / migrate.sh
Created February 18, 2020 05:10
Migrate Redis DB to another place (use MIGRATE COPY for v3.0<= redis)
#!/bin/bash
# Set connection data accordingly
source_host=localhost
source_port=6379
source_db=1
target_host=localhost
target_port=6379
target_db=2
# Copy all keys without preserving ttl!
@andrewbrg
andrewbrg / gcrgc.sh
Created April 23, 2019 17:04 — forked from ahmetb/gcrgc.sh
Script to clean up Google Container Registry images pushed before a particular date
#!/bin/bash
# Copyright © 2017 Google Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
@andrewbrg
andrewbrg / bot.detect.inc.php
Last active August 22, 2018 21:05 — forked from geerlingguy/crawler_detect.php
Detect crawlers/bots/spiders in PHP (simple and fast)
<?php
/**
* Check if a request originated from a crawler, spider, or bot.
*
* @param null|string $userAgent
* @param array $identifiers
* @return bool
*/
if (!function_exists('isBot')) {
function isBot($userAgent = null, $identifiers = array())
@andrewbrg
andrewbrg / loader.js
Last active November 27, 2018 22:30
Load remote JavaScript files programatically at runtime
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Allows you to load JavaScript files programatically from within other JavaScript files in your project.
//
// Instructions:
// 1. Include this file before all other scripts in your project.
// 2. Call jsLoader.load() or jsLoader.loadAsync() from within your scripts passing a single JS file path or
// array of multiple JS paths to load into your script at runtime.
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const jsLoader = {
@andrewbrg
andrewbrg / console.toggle.js
Created August 15, 2018 11:10
Toggle console methods dynamically
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Allows the console browser object to be enabled or disabled seamlessly throughout your entire project. This is
// useful when you want to disable all console logging on a production release without removing the actual calls
// to the console.log (or other console methods) from your application code.
//
// Instructions:
// 1. Include this file before all other scripts in your project (including it first lets it capture all console methods)
// 2. Call the console.enabled() function passing a boolean indicating whether you want the console methods to be actioned or not
//
// By default this script will prevent console messages from appearing in the browser, so if you want them to be displayed