Skip to content

Instantly share code, notes, and snippets.

@teknikqa
teknikqa / Installation.md
Created July 25, 2022 06:23 — forked from albertbori/Installation.md
Automatically disable Wifi when an Ethernet connection (cable) is plugged in on a Mac

Overview

This is a bash script that will automatically turn your wifi off if you connect your computer to an ethernet connection and turn wifi back on when you unplug your ethernet cable/adapter. If you decide to turn wifi on for whatever reason, it will remember that choice. This was improvised from this mac hint to work with Yosemite, and without hard-coding the adapter names. It's supposed to support growl, but I didn't check that part. I did, however, add OSX notification center support. Feel free to fork and fix any issues you encounter.

Most the credit for these changes go to Dave Holland.

Requirements

  • Mac OSX 10+
  • Administrator privileges
@teknikqa
teknikqa / disable-plugin.php
Last active June 1, 2021 10:18
Convert a WordPress plugin from a network activated state to a site activated one.
<?php
/**
* Convert a plugin from a network activated state to a site activated one.
*
* On a multisite WordPress installation, there is no simple way to deactivate a
* network activated plugin while leaving it active on one or two sites, unless
* the plugin was activated first on a site and then activated across the
* network. This script will convert the plugin from a network activated state
* to a site activated one. After running this script, we can then individually
* disable the plugin from sites that do not need it.
@teknikqa
teknikqa / functions.php
Created June 1, 2021 09:37
Disable the default post type on sites that do not need it.
<?php
/**
* WordPress Theme constants and setup functions
*
* @package WPCustomTheme
*/
/*
* When using WordPress as a CMS the Posts content type might not be useful or
* required on some sites. While WordPress provides a way to deregister custom
@teknikqa
teknikqa / wpmu_username.php
Created September 29, 2020 09:54
Allow very short user names in WordPress.
<?php # -*- coding: utf-8 -*-
/* Plugin Name: Allow short user names for multi site. */
add_filter( 'wpmu_validate_user_signup', 'wpse_59760_short_user_names' );
/**
* Allow very short user names.
*
* @wp-hook wpmu_validate_user_signup
* @param array $result
@teknikqa
teknikqa / cloudflare_drupal_waf.sh
Created July 9, 2019 07:09
Custom Cloudflare WAF rules for Drupal
#!/usr/bin/env bash
#
# Script to import custom WAF rules using the Cloudflare API.
#
# Taken from https://www.pixelite.co.nz/article/custom-cloudflare-waf-rules-that-every-drupal-site-should-run/
# Blocks:
# 1. Unfriendly Drupal 7 URLs
# 2. Autodiscover of Microsoft Exchange
# 3. Wordpress PHP scripts
# 4. Wordpress common folders (excluding content)
@teknikqa
teknikqa / invert_color.php
Created May 28, 2019 08:34
Find the appropriate color that works best on a given background color.
<?php
/**
* @file
* Find the appropriate color that works best on a given background color.
*/
/**
* Convert the standard RGB color to linear RGB.
*
@teknikqa
teknikqa / custom_events.module
Created May 28, 2019 05:35
Drupal code to restrict access to event nodes that are old and no longer valid.
<?php
/**
* @file
* Code for the Custom Events module.
*/
/**
* Implements hook_preprocess_node().
*
* Restrict access to events that more than a year old.
@teknikqa
teknikqa / deleteAmazonSavedItems.js
Created May 19, 2019 08:44 — forked from MichaelLawton/deleteAmazonSavedItems.js
Removes all Amazon saved for later items on the cart page. It will only remove visible items. You might want to scroll first to make more items visible. To use paste code in developer console (Ctrl+Shift+J or Cmd+Opt+J in Chrome) then press enter.
function deleteSavedItems() {
var query = document.querySelectorAll("#sc-saved-cart input[value=Delete]")
if (query.length) {
query[0].click();
}
if (query.length > 1) {
setTimeout(deleteSavedItems,100);
}
else {
console.log('Finished');
@teknikqa
teknikqa / git add certain file types
Created May 9, 2019 07:11 — forked from stoplion/git add certain file types
git add all of certain file type
find . -name "*.sass" | xargs git add
@teknikqa
teknikqa / easywifi.txt
Last active January 23, 2019 10:13
Easy WiFi password sharing
Create a QR code with any QR generator in this format:
WIFI:S:<ssid>;T:<wpa|wep|>;P:<password>;;
Scanning this code will automatically add the WiFi details to the device. [1][2]
iOS will share the username and password. To prevent that, create a configuration file using
the iPhone configuration utility and have the QR code link to that file. This file can be on
Dropbox or any other server. [3]