Skip to content

Instantly share code, notes, and snippets.

@RWJMurphy
RWJMurphy / 2011-08-18_whmscripts_disabling_invoice_emails.md
Last active February 27, 2023 21:40
WHMScripts: Disabling invoice creation emails in WHMCS on a per-client basis

If you’re using WHMCS to manage your cPanel shared servers, this is probably a request that you’ve received a few times. You have clients that are set up to pay invoices automatically from their credit cards, and they’d rather not receive the “Invoice Created” or “Invoice Payment Reminder” emails every month.

Normally WHMCS only allows you to disable these emails globally but, by making use of the EmailPreSend action hook, we can set up a list of clients not to receive these.

To get started just download the following script, change the file extension to .php, edit it to set up the $client_ids and place it in your WHMCS /includes/hooks/ directory

Please note, this script doesn’t disable only the automatically sent invoice notification emails, but also blocks manual sending of these for the selected clients.

(originally posted at http://whmscripts.net/whmcs/2011/disabling-invoice-creation-emails-in-whmcs-on-a-per-client-basis/)

@RWJMurphy
RWJMurphy / filerotator.py
Last active February 1, 2023 04:02
Python class and utility for file rotation. Configurable daily, weekly and monthly retention; can use hard links to save space; supports `argparse` config files.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# vim: ft=python ts=4 sw=4 expandtab
#
# Copyright (c) 2013 Reed Kraft-Murphy <reed@reedmurphy.net>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@RWJMurphy
RWJMurphy / metabuzz.py
Created March 26, 2018 23:02
golf all the fizzbuzz
from itertools import combinations as c
s = sorted
def a(m):return reduce(lambda x,y:(x[0]+2**y[0],x[1]+y[1]),m,(0,''))
def p(x):return [None]+[x for _,x in s([a(d) for r in range(len(x)) for d in c(enumerate(x), r+1)])]
def metabuzz(m):
n=s([(v,k) for k,v in m.items()])
return '''def o(i):return str(%r[k(i)] or i)
def k(n):return sum([(n%%v==0)<<i for i,v in enumerate(%r)])
print "\\n".join(map(o, range(1, 101)))'''%(p([v for _,v in n]),[k for k,_ in n])
@RWJMurphy
RWJMurphy / __init__.py
Last active June 3, 2017 13:16
Fabric fabfile for turning a directory of scripts into remote-running tasks. Like magic. Just drop `__init__.py` into a folder containing your executable scripts, and `import script_dir` from your existing `fabfile.py`. Each script file will then be available as a task named `script_dir.script_name`
import os
import os.path
import re
import fabric.api
import fabric.tasks
SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__))
SUDO_PREFIX = re.compile(r'/(root|sudo)_?', re.I)
@RWJMurphy
RWJMurphy / delegate.py
Created February 10, 2017 16:51
python delegate class decorator
"""A class decorator to enable classes to delegate to an attribute."""
def delegate(delegate_class, delegate_name):
"""
Delegating class decorator.
.. code-block:: python
class Location():
@RWJMurphy
RWJMurphy / mattermost_emoji_uploader.sh
Last active December 20, 2016 23:43
terrible bulk emoji uploader for mattermost. needs [`jq`](https://stedolan.github.io/jq/), [`jo`](https://github.com/jpmens/jo), GNU `parallel`, and `curl`
#!/bin/bash
set -eu
MM_URL="https://mm.example.org"
API_URL="${MM_URL}/api/v3"
LOGIN_URL="${API_URL}/users/login"
USERS_ME_URL="${API_URL}/users/me"
ADD_EMOJI_URL="${API_URL}/emoji/create"
banner() {

Keybase proof

I hereby claim:

  • I am RWJMurphy on github.
  • I am rwjkm (https://keybase.io/rwjkm) on keybase.
  • I have a public key whose fingerprint is 37AC 6F5F A997 56C4 499B DD4A 7AD3 A560 5779 5178

To claim this, I am signing this object:

@RWJMurphy
RWJMurphy / do_boot2.sh
Created June 20, 2016 13:59 — forked from leucos/do_boot2.sh
Bootstrap your DO infrastructure unsing Ansible without dynamic inventory (version for Ansible v2.0+ and DO API v2.0)
#!/bin/bash
#
# What is that
# ============
#
# This script will help you setting up your digital ocean
# infrastructure with Ansible v2.0+ and DO API v2
#
# Usually, when working with DO, one is supposed to use digital_ocean.py
# inventory file, and spin up instances in a playbook.
class Composed:
"""Composable class."""
def __init__(self, components=None):
self.__components = []
if components:
self.register_components(components)
def register_components(self, components):
for component in components:
#!/bin/bash
function silent() {
"$@" >/dev/null 2>&1
}
function command_exists() {
silent hash "$@"
}