Skip to content

Instantly share code, notes, and snippets.

@RyanABailey
RyanABailey / js
Created November 24, 2014 05:27
regex password
var password = "Mypassword01";
var regexString = "^((?=.{8,}$)(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).*|(?=.{8,}$)(?=.*\d)(?=.*[a-zA-Z])(?=.*[!\u0022#$%&'()*+,./:;⇔?@[\]\^_`{|}~-]).*)";
var regexx = new RegExp(regexString);
if (!regexx.test(password)) {
// password did not match regex
}
@RyanABailey
RyanABailey / js
Created November 27, 2014 02:37
disable paste
$(document).ready(function () {
$('#email').bind("paste", function (e) {
e.preventDefault();
});
});
@RyanABailey
RyanABailey / frontend
Created December 10, 2014 00:38
angular grouping radio buttons
<input type="radio" name="myGroup" value="1" ng-model="cbSelection"/> Checkbox 1
<input type="radio" name="myGroup" value="2" ng-model="cbSelection"/> Checkbox 2
@RyanABailey
RyanABailey / Frontend
Created January 13, 2015 02:49
angularJS check box repeater
<input
type="checkbox"
name="membersListSelection[]"
value="{{i.MemberNumber}}"
ng-checked="filterData.membersListSelection.indexOf(i.MemberNumber) > -1"
ng-click="toggleMembersListSelection(i.MemberNumber)"
>
@RyanABailey
RyanABailey / JS
Created January 29, 2015 01:42
input mask
$(document).ready(function(){
$("#MyField").inputmask("999-999-999");
$("#OtherField").inputmask("999a");
});
@RyanABailey
RyanABailey / c#
Last active August 29, 2015 14:16
Task parallelism
var addressChanges = request.AddressChangesRequired;
if (addressChanges.Any())
{
var tasks = new List<Task>();
foreach (var addressChange in addressChanges)
{
var memberNumber = addressChange.MemberNumber;
var address = addressChange.Address;
@RyanABailey
RyanABailey / AngularJS Factory
Last active April 5, 2019 05:10
CSRF in AngularJS/Web API
app.factory('LoginProvider', function ($resource) {
return $resource('/api/login/:id', { id: '@id' },
{ 'save': { method: 'POST', headers: { 'X-XSRF-Token': angular.element('input[name="__RequestVerificationToken"]').attr('value') } } });
});
app.factory('OtherProvider', function ($resource) {
return $resource('/api/OtherProvider/:id', { id: '@id' },
{'get': { method: 'GET', headers: { 'X-XSRF-Token': angular.element('input[name="__RequestVerificationToken"]').attr('value') } }});
});
@RyanABailey
RyanABailey / C#
Last active August 29, 2015 14:21
Menu
protected void rptMenuParent_OnItemDataBound(object sender, RepeaterItemEventArgs e)
{
var row = (TopMenu)e.Item.DataItem;
Repeater nestedRepeater = e.Item.FindControl("rptMenuChild") as Repeater;
nestedRepeater.DataSource = row.Children;
nestedRepeater.DataBind();
}
protected void Page_Load(object sender, EventArgs e)
@RyanABailey
RyanABailey / gist:4039f100f60d99bd5b66
Last active August 29, 2015 14:21
Sitecore breadcrumbs
Item currentItem = Sitecore.Context.Item; // Current sitecore item
BreadCrumbs.Current = currentItem.Fields["Title"].ToString(); // set current items title on breadcrumb object
currentItem = currentItem.Parent; // go to parent of current item
while (currentItem.ID != new ID(Items.ContentRootItem))
{
// add parent item to breadcrumb object (a list of parent items)
BreadCrumbs.Parents.Add(new Common.MenuItem
{
Link = Sitecore.Links.LinkManager.GetItemUrl(currentItem),
@RyanABailey
RyanABailey / Index
Last active August 29, 2015 14:21
Sitecore Search Index
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<contentSearch>
<configuration type="Sitecore.ContentSearch.ContentSearchConfiguration, Sitecore.ContentSearch">
<indexes hint="list:AddIndex">
<!-- Change this to Sitecore.ContentSearch.LuceneProvider.SwitchOnRebuildLuceneIndex, Sitecore.ContentSearch.LuceneProvider if you would like indexes to be
built in a temporary directory i.e. while rebuilding is happening, your old indexes work like normal until the rebuild is finished. -->
<index id="CustomSearch" type="Sitecore.ContentSearch.LuceneProvider.LuceneIndex, Sitecore.ContentSearch.LuceneProvider">
<param desc="name">$(id)</param>
<param desc="folder">$(id)</param>