Skip to content

Instantly share code, notes, and snippets.

Pete Scopes pdscopes

  • Leeds, UK
Block or report user

Report or block pdscopes

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@pdscopes
pdscopes / expand_dict.py
Last active Jun 19, 2019
Function to expand a, partially, flattened dictionary out to a nested dictionary
View expand_dict.py
def expand_dict(dct, delimiter: str = '.') -> dict:
"""
Expand a (partially) flattened dot-notation dictionary.
:param dct: Dictionary/list to be expanded
:param delimiter: String that delimits flattened keys
:return: Expanded dictionary/list
"""
if isinstance(dct, dict):
stale_keys = []
@pdscopes
pdscopes / string_replace_nth.js
Created Sep 13, 2018
String.prototype.replace_nth
View string_replace_nth.js
String.prototype.replace_nth = function (searchValue, replaceValue, n) {
let i = 0;
return this.replace(searchValue, function (match) { return (++i === n) ? replaceValue : match; });
};
View phpunit.xml
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
View homebrew.mxcl.rabbitmq.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>homebrew.mxcl.rabbitmq</string>
<key>Program</key>
<string>/usr/local/opt/rabbitmq/sbin/rabbitmq-server</string>
<key>RunAtLoad</key>
@pdscopes
pdscopes / calcRangePrecision.js
Last active Aug 11, 2016
Javascript calculate the toFixed precision for a given range
View calcRangePrecision.js
/**
* Calculates the toFixed precision required for nicely displaying
* step intervals between the values given.
*
* @param int min Minimum value in set
* @param int max Maximum value in set
*
* @return int Number.toFixed precision
*/
function calcRangePrecision(min, max) {
You can’t perform that action at this time.