Skip to content

Instantly share code, notes, and snippets.

Avatar

Alex Smagin asmagin

View GitHub Profile
@asmagin
asmagin / index.js
Created Mar 9, 2020
MS Teams Notifications Lambda
View index.js
const fetch = require("node-fetch");
const IN_PROGRESS_IMAGE = "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD/4QBmRXhpZgAATU0AKgAAAAgABAEaAAUAAAABAAAAPgEbAAUAAAABAAAARgEoAAMAAAABAAIAAAExAAIAAAAQAAAATgAAAAAAAABgAAAAAQAAAGAAAAABcGFpbnQubmV0IDQuMi44AP/bAEMABgQFBgUEBgYFBgcHBggKEAoKCQkKFA4PDBAXFBgYFxQWFhodJR8aGyMcFhYgLCAjJicpKikZHy0wLSgwJSgpKP/bAEMBBwcHCggKEwoKEygaFhooKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKP/AABEIACgAKAMBIgACEQEDEQH/xAAfAAABBQEBAQEBAQAAAAAAAAAAAQIDBAUGBwgJCgv/xAC1EAACAQMDAgQDBQUEBAAAAX0BAgMABBEFEiExQQYTUWEHInEUMoGRoQgjQrHBFVLR8CQzYnKCCQoWFxgZGiUmJygpKjQ1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4eLj5OXm5+jp6vHy8/T19vf4+fr/xAAfAQADAQEBAQEBAQEBAAAAAAAAAQIDBAUGBwgJCgv/xAC1EQACAQIEBAMEBwUEBAABAncAAQIDEQQFITEGEkFRB2FxEyIygQgUQpGhscEJIzNS8BVictEKFiQ04SXxFxgZGiYnKCkqNTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqCg4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2dri4+Tl5ufo
@asmagin
asmagin / index.jsx
Created Jan 18, 2019
SafePureComponent
View index.jsx
import * as React from 'react';
import * as Models from './models';
export class SafePureComponent<P, S extends Models.SafePureComponentState> extends React.PureComponent<P, S> {
private hasError: boolean = false;
constructor(props: P, context?: any) {
super(props, context);
}
@asmagin
asmagin / set JAVA_HOME.ps1
Created Nov 6, 2017
Install Sitecore 9 - Prerequisites - Part 10 - Install Solr 6.6.2 - Set JAVA_HOME & Path
View set JAVA_HOME.ps1
# set JAVA_HOME and Path variables
$JAVA_HOME = "C:\Program Files\Java\jre1.8.0_151"
$Path = "${env:Path};${JAVA_HOME}\bin"
[Environment]::SetEnvironmentVariable("JAVA_HOME", $JAVA_HOME, "Machine")
[Environment]::SetEnvironmentVariable("Path", $Path, "Machine")
@asmagin
asmagin / Engine.cs
Last active Oct 22, 2016
Js Engine Performance Tests
View Engine.cs
public class Engine : IDisposable
{
private IJsPool pool;
private string initJs;
public Engine()
{
//JsEngineSwitcher.Instance.EngineFactories.AddMsie(new MsieSettings() { EngineMode = JsEngineMode.Auto });
//JsEngineSwitcher.Instance.DefaultEngineName = MsieJsEngine.EngineName;
@asmagin
asmagin / AssemblyRegistration.cs
Last active Mar 15, 2019
Sitecore Redux solution
View AssemblyRegistration.cs
using JavaScriptEngineSwitcher.Core;
using React;
using React.TinyIoC;
namespace Smagin.Alex.React
{
/// <summary>
/// Handles registration of core ReactJS.NET components.
/// </summary>
public class AssemblyRegistration : IAssemblyRegistration
View SimpleContentComponent.js
'use strict';
import React from 'react';
import { Grid, Row, Col } from 'react-bootstrap'
require('styles/common/SimpleContent.css');
let yeomanImage = require('../../images/yeoman.png');
View Catalog Repository.cs
private MultipleProductSearchResults GetMultipleProductSearchResults(BaseItem dataSource,
CommerceSearchOptions productSearchOptions)
{
Assert.ArgumentNotNull(productSearchOptions, "productSearchOptions");
MultilistField searchesField = dataSource.Fields[Templates.ProductSearch.Fields.NamedSearches.ToString()];
var searches = searchesField.GetItems();
var productsSearchResults = new List<SearchResults>();
foreach (var search in searches)
View Catalog - Action - ProductRecommendation.cs
/// <summary>
/// An action to manage data for the ProductList
/// </summary>
/// <param name="pageNumber">The page number.</param>
/// <param name="facetValues">The facet values.</param>
/// <param name="sortField">The sort field.</param>
/// <param name="sortDirection">The sort direction.</param>
/// <returns>
/// The view that represents the ProductList
/// </returns>
@asmagin
asmagin / GenerateSitecoreNugetPackages.ps1
Last active Nov 25, 2019
Powershell script to generate nuget packages with dependencies
View GenerateSitecoreNugetPackages.ps1
param(
[string] $Major = "8",
[string] $Minor = "1",
[string] $Update = "0",
[string] $Date = "151003",
[string] $nugetPath = ".\tools\nuget.exe",
[string] $downloadsPath = ".\downloads",
[string] $nuspecTemplate = ".\tools\package.nuspec.xml",
[string] $apiKey,
[string] $nugetFeed = "http://use-your.own/nuget/Sitecore-Libs"
View YAML vs JSON.cs
using System;
using System.IO;
using Newtonsoft.Json;
using YamlDotNet.Serialization;
internal class Program
{
private const int count = 10000;
You can’t perform that action at this time.