Skip to content

Instantly share code, notes, and snippets.

View BrandonZacharie's full-sized avatar

Brandon Zacharie BrandonZacharie

View GitHub Profile
'use strict';
/**
* Provides extensions to the built-in `Set`.
* @class
*/
module.exports = class Set extends Set {
/**
* Returns a `Set` composed of the elements in the
* current `Set` and a given `set`.
var hyperquest = require('hyperquest');
var hr = hyperquest('INSERT_SLACK_WEBHOOK_URL', { method: 'POST' });
hr.setHeader('content-type', 'application/json');
hr.pipe(process.stdout);
hr.end(JSON.stringify({ text: 'Test 123' }));
module.exports = function (hook) {
var hr = hook.open(hook.env.slack, { method: 'POST' });
hr.setHeader('content-type', 'application/json');
hr.end(JSON.stringify({ text: hook.params.message || 'test' }));
hr.pipe(hook.res);
};
module.exports.schema = {
alert_type_causes: 'string'
, alert_type_description: 'string'
@BrandonZacharie
BrandonZacharie / String.toRegExp.js
Created February 21, 2012 21:23
A JavaScript function to convert a string to a RegExp
if (!String.toRegExp)
String.toRegExp = function String_toRegExp(pattern, flags) {
return new RegExp(pattern.replace(/[\[\]\\{}()+*?.$^|]/g, function (match) { return '\\' + match; }), flags);
};
@BrandonZacharie
BrandonZacharie / String.format.js
Created February 21, 2012 21:17
A .NET inspired String.format function in JavaScript
if (!String.format)
String.format = function String_format(value) {
if (arguments.length === 0)
return null;
for (var i = 1, l = arguments.length; i !== l; ++i)
value = value.replace(RegExp('\\{' + (i - 1) + '\\}','gm'), arguments[i]);
return value;
};