Skip to content

Instantly share code, notes, and snippets.

@MichaelaIvanova
MichaelaIvanova / Umbraco Contex Mocker and Request
Created September 1, 2017 13:35
Umbraco Contex Mocker with mocket request and query string
public class ContextMocker
{
public ContextMocker(string [] qKeys = null)
{
ILogger loggerMock = Mock.Of<ILogger>();
IProfiler profilerMock = Mock.Of<IProfiler>();
var contextBaseMock = new Mock<HttpContextBase>();
if (qKeys != null)
{
var requestMock = new Mock<HttpRequestBase>();
@MichaelaIvanova
MichaelaIvanova / colorpicker.html
Created August 25, 2017 10:13 — forked from pbres/colorpicker.html
ColorPicker for Umbraco Grid DataType Settings/Style sections
<div ng-controller="Umbraco.PropertyEditors.ColorPickerController">
<ul class="thumbnails color-picker">
<li ng-repeat="preval in model.prevalues" ng-class="{active: model.value === preval}">
<a ng-click="toggleItem(preval)" class="thumbnail" hex-bg-color="{{preval}}">
</a>
</li>
</ul>
<input type="hidden" name="modelValue" ng-model="model.value" val-property-validator="validateMandatory"/>
</div>
@MichaelaIvanova
MichaelaIvanova / Using YouTube api to get video info
Last active August 24, 2017 12:48
Using YouTube api to get video info
static void Main(string[] args)
{
var youtubeService = new YouTubeService(new BaseClientService.Initializer()
{
ApiKey = "appKey",
ApplicationName = "TestYouTubeApi"
});
var request = youtubeService.Videos.List("snippet,contentDetails,statistics,status,player,topicDetails,recordingDetails");
var EndOfURI = "someVideoId";
@MichaelaIvanova
MichaelaIvanova / RSS Action result
Created August 10, 2017 14:36
rss, custom action result
public class RssActionResult : ActionResult
{
public SyndicationFeed Feed { get; set; }
public override void ExecuteResult(ControllerContext context)
{
context.HttpContext.Response.ContentType = "application/rss+xml";
var rssFormatter = new Rss20FeedFormatter(Feed);
using (var writer = XmlWriter.Create(context.HttpContext.Response.Output))
{
@MichaelaIvanova
MichaelaIvanova / Umbraco Autofac set up
Created July 21, 2017 12:48
Umbraco Autofac set up
public static class AutofacConfig
{
public static void RegisterDependencies()
{
var builder = new ContainerBuilder();
// Register Umbraco Context, MVC Controllers and API Controllers.
builder.Register(c => UmbracoContext.Current).AsSelf();
builder.RegisterInstance(new UmbracoHelper(UmbracoContext.Current));
public static int solution(int[] A)
{
var maxDepth = int.MaxValue;
var counter = 0;
for (int i = 1; i < A.Length - 1; i++)
{
var current = A[i];
var previous = A[i - 1];
var next = A[i + 1];
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace algos
{
class Program
{
public static int solution(string S)
{
var index = 0;
if(string.IsNullOrEmpty(S) || S.Length%2 == 0)
{
index = -1;
}
else if(S.Length == 1)
{
index = 0;
public static int solution(int[] A)
{
Array.Sort(A);
var r = Math.Max(A[A.Length - 1] * A[A.Length- 2] * A[A.Length - 3],
A[0] * A[1] * A[A.Length - 1]);
return r;
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace algos
{
class Program
{