Skip to content

Instantly share code, notes, and snippets.

View New-Password.psm1
Function New-Password {
param([int]$length = 12,
[int]$complexity = 4)
[String[]]$source = "abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "1234567890", "[]{}<>@#~?!£$%^&*()"
$newPassword = $null
foreach($counter in 1..$length) {
# Work out which character type to get
$set = Get-Random $complexity
View reset-lastIndex.js
var regexp = /ste/ig;
var results = [];
for(var i = 0; i < 10; i++) {
results.push(regexp.test('Steve Hocking'));
regexp.lastIndex = 0;
}
console.log(results.toString());
View expected-regexp-result.js
var regexp = /ste/i;
var results = [];
for(var i = 0; i < 10; i++) { results.push(regexp.test('Steve Hocking')); }
console.log(results.toString());
View unexpected-regexp-result.js
var regexp = /ste/ig;
var results = [];
for(var i = 0; i < 10; i++) { results.push(regexp.test('Steve Hocking')); }
console.log(results.toString());
View unexpected-filter-result.js
var regexp = /ste/ig;
var names = ['John Smith', 'Steven Hocking', 'Robert Stevenson', 'Steve Hocking', 'Janet Smith'];
var filtered = names.filter(function(name) {return regexp.test(name);});
console.log(filtered.toString());
View ObjectClone.js
function getObjectType(obj) {
var funcNameRegex = /function (.{1,})\(/;
if(!!obj && !!obj.constructor) {
var results = (funcNameRegex).exec(obj.constructor.toString());
return (results && results.length > 1) ? results[1] : "";
}
return typeof obj;
}
View MockingUtils.cs
using System;
using System.Linq;
using System.Linq.Expressions;
namespace Moq
{
public static class MockingUtilities
{
public static Mock<T> AutoMockFluentInterface<T>(this Mock<T> interfaceMock) where T:class
{