This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
< /dev/urandom tr -db _A-Z-a-z-0-9 | head -c16 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void AddUserToGroup(SPWeb web, string userName, string groupName) | |
{ | |
SPWeb spWeb = web; | |
SPSecurity.RunWithElevatedPrivileges(delegate() | |
{ | |
using (SPSite elevSite = new SPSite(spWeb.Url)) | |
using (SPWeb elevWeb = elevSite.OpenWeb()) | |
{ | |
elevWeb.AllowUnsafeUpdates = true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface IFactory | |
{ | |
IAbbreviationsAndAcronymsService AbbreviationsAndAcronymsService {get; set;} | |
IBusinessActivityService BusinessActivityService {get; set;} | |
Factory Make(ConcreteTypes type); | |
} | |
public class Factory | |
{ | |
public IAbbreviationsAndAcronymsService AbbreviationsAndAcronymsService; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var search = search || {}; | |
(function(o, win) { | |
let _client = document.getElementById("client"); | |
let _server = document.getElementById("server"); | |
let _dateFmt = function(dateStr) { | |
const options = { year: 'numeric', month: 'short', day: 'numeric' }; | |
return new Date(dateStr).toLocaleDateString("en-US", options); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let _idxOf = function(needle){ | |
return function(haystack){ | |
return haystack.toLowerCase().indexOf(needle.toLowerCase()) !== -1; | |
}; | |
}; | |
// e.g | |
let searchTerm = "fly"; | |
let pets = [{ name: 'George', type: 'fly' }, { name: 'Benson', type: 'dog' }]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class PredicateBuilder | |
{ | |
public static Expression<Func<T, bool>> And<T>(this Expression<Func<T, bool>> expr1, Expression<Func<T, bool>> expr2) | |
{ | |
var invokedExpr = Expression.Invoke(expr2, expr1.Parameters.Cast<Expression>()); | |
return Expression.Lambda<Func<T, bool>>(Expression.AndAlso(expr1.Body, invokedExpr), expr1.Parameters); | |
} | |
public static Expression<Func<T, bool>> False<T>() | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Item currentItem = Sitecore.Context.Item; | |
SiteInfo currentSiteRoot = SiteContextFactory.Sites | |
.Where(s => s.RootPath != "" && currentItem.Paths.Path.ToLower().StartsWith(s.RootPath.ToLower())) | |
.OrderByDescending(s => s.RootPath.Length) | |
.FirstOrDefault(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private function SetTimeZone($dtStr) | |
{ | |
$newDt = DateTime::createFromFormat(DateTime::ISO8601, $dtStr); | |
$newDt->setTimezone(new DateTimeZone('Australia/Perth')); | |
$newDtStr = $newDt->format("c"); | |
return $newDtStr; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// dependancies: Newtonsoft.Json, RestSharp; | |
public interface IRpcClient<T> | |
{ | |
string AccessToken { get; } | |
string BaseUrl { get; } | |
T DataStore { get; } | |
string Host { get; } | |
string Protocal { get; } | |
string RelativeUrl { get; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static IRestResponse<T> MakeRequest(string relativeUrl, Func<RestClient, RestRequest, IRestResponse<T>> clientFunc) | |
{ | |
var client = new RestClient("https://someresource.com"); | |
var request = new RestSharp.RestRequest(relativeUrl); | |
return clientFunc(client, request); | |
} | |
// example call | |
var request = MakeRequest("/api/whatever", (c, r) => c.Execute<SomeType>(r)); | |
var deserializedSomeTypeData = request.Data; |