Skip to content

Instantly share code, notes, and snippets.

View lewisjb's full-sized avatar

Lewis B lewisjb

View GitHub Profile
@lewisjb
lewisjb / min.js
Last active May 17, 2021 12:25
Minimal JS MVVM
/*
* min.js
*
* By lewisjb - 19/1/17
*
* github/lewisjb
* lewisjb.com
*
* ----------------------------------------------------------------------------
* This is meant to be a minimal MVVM written in JS.
@lewisjb
lewisjb / slack_sed.js
Created October 24, 2016 14:19
Slack /s with regex and substitution
TS.utility.msgs.wordReplace = function (text, replace_object) {
if(!replace_object){
return text;
}
var rx_opts = (replace_object.g ? "g" : "") + (replace_object.i ? "i" : "");
var rx = new RegExp(replace_object.str, rx_opts);
return text.replace(rx, replace_object.rpl.replace(/\\(\d+)/g, "$$1"));
};