Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 "$@"
}
#!/bin/bash
function test {
echo ${FOO:=$(curl https://gist.githubusercontent.com/RWJMurphy/ded51ead3b153364099a/raw/348c26370e90b6c77a08a2e8fb3258fa6f1a7426/gistfile1.txt)}
}
test
test
@RWJMurphy
RWJMurphy / dwarf_fortress.vim
Last active August 29, 2015 14:03
DF Init & Raw file syntax highlighting for vim - WIP
if exists("b:current_syntax")
finish
endif
" # matches and keywords
" ## Tags
syntax cluster initTags contains=@initTagNames,initTagDelimiter,@initValues
syntax region initTag start=/\v\[/ end=/\v[\]\n]/ contains=@initTags
syntax match initTagDelimiter /\v:/ contained