Skip to content

Instantly share code, notes, and snippets.

View dejanvasic85's full-sized avatar

Dejan Vasic dejanvasic85

View GitHub Profile
@dejanvasic85
dejanvasic85 / passwordModule.js
Last active August 29, 2015 14:14
Angular Strength Indicator
angular.module('passwordModule', [])
.controller('credentialsController', ['$scope',
function($scope) {
// Initialise the password as hello
$scope.credentials = {
password: 'hello'
};
}
])
.directive('passwordStrength', [
@dejanvasic85
dejanvasic85 / passwordModule.html
Last active August 29, 2015 14:14
Angular Password Strength Indicator
<div ng-app="passwordModule" ng-controller="credentialsController" class="container">
<form name="form">
<div class="form-group">
<label for="password">Password</label>
<input type="text" name="password" id="password" ng-model="credentials.password" ng-model-options="{allowInvalid: true}" pattern-validator="((?=.*\d)(?=.*[A-Z])(?=.*\W).{8,8})" class="form-control" />
</div>
<div class="form-group">
<label>Password Strength</label>
public static class UnityConfig
{
public static IUnityContainer RegisterComponents()
{
var container = new UnityContainer();
// Register all repository classes automatically
// Register all service classes automatically in the business layer
@dejanvasic85
dejanvasic85 / MockBuilder.cs
Created May 19, 2015 06:49
Nice builder pattern to for building mock objects using Actions
internal class MockBuilder<TBuilder, TMock>
where TBuilder : MockBuilder<TBuilder, TMock>, new()
where TMock : class, new()
{
private IList<Action<TMock>> _buildSteps;
protected MockBuilder()
{
_buildSteps = Enumerable.Empty<Action<TMock>>().ToList();
}
@dejanvasic85
dejanvasic85 / MustBeTrueAttribute
Created February 29, 2016 00:35
Custom validation attribute to ensure a checkbox is checked
/// <summary>
/// This is used on mostly checkboxes that ensure that they are ticked such as terms and conditions.
/// </summary>
public class MustBeTrueAttribute : ValidationAttribute
{
public override bool IsValid(object value)
{
if (value == null) return false;
if (value.GetType() != typeof(bool)) return false;
@dejanvasic85
dejanvasic85 / SessionLifetimeManager.cs
Last active July 10, 2016 12:07
Custom Unity lifetime manager
public class SessionLifetimeManager<T> : Microsoft.Practices.Unity.LifetimeManager
{
private string key;
public SessionLifetimeManager()
{
this.key = typeof(T).Name;
}
/// <summary>
@dejanvasic85
dejanvasic85 / LoginPage.cs
Last active September 25, 2016 13:04
Selenium WebElement scrolling so element is in the middle of page
public class LoginPage{
private IWebDriver _webDriver;
public LoginPage(IWebDriver webDriver){
_webDriver = webDriver;
}
[FindsBy(How = How.Name, Using = "username")]
private IWebElement UsernameInputElement {get;set;}
@dejanvasic85
dejanvasic85 / New.cs
Last active July 31, 2017 11:56
Selenium WebDriver with Google GeoComplete
public BookingEventStep WithLocation(string location)
{
_webdriver.ScrollElementToMiddle(LocationInput);
LocationInput.FillText(location);
var wait = new WebDriverWait(_webdriver, TimeSpan.FromSeconds(10));
wait.Until(ExpectedConditions.ElementToBeClickable(By.ClassName("pac-item")));
LocationInput.SendKeys(Keys.ArrowDown);
LocationInput.SendKeys(Keys.ArrowDown);
@dejanvasic85
dejanvasic85 / FileUploadController.cs
Last active August 11, 2017 06:49
Asp.net WebForms multiple file upload
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.Http;
namespace TestFileUpload
{
public class FileUploadController : ApiController
@dejanvasic85
dejanvasic85 / tsconfig.json
Last active March 31, 2018 11:05
Node with Docker on AWS Fargate
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"outDir": "dist",
"sourceMap": true
},
"files": [
"./node_modules/@types/mocha/index.d.ts",
"./node_modules/@types/node/index.d.ts"