Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View asmagin's full-sized avatar

Alex Smagin asmagin

View GitHub Profile
@asmagin
asmagin / index.js
Created March 9, 2020 04:46
MS Teams Notifications Lambda
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 January 18, 2019 16:32
SafePureComponent
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 November 6, 2017 00:40
Install Sitecore 9 - Prerequisites - Part 10 - Install Solr 6.6.2 - Set JAVA_HOME & Path
# 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 October 22, 2016 17:22
Js Engine Performance Tests
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 March 15, 2019 14:02
Sitecore Redux solution
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
@asmagin
asmagin / SimpleContentComponent.js
Last active October 8, 2016 21:33
Sitecore + React
'use strict';
import React from 'react';
import { Grid, Row, Col } from 'react-bootstrap'
require('styles/common/SimpleContent.css');
let yeomanImage = require('../../images/yeoman.png');
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)
@asmagin
asmagin / Catalog - Action - ProductRecommendation.cs
Created August 30, 2016 04:19
Sitecore Catalog Module for Habitat
/// <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 November 25, 2019 18:42
Powershell script to generate nuget packages with dependencies
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"
using System;
using System.IO;
using Newtonsoft.Json;
using YamlDotNet.Serialization;
internal class Program
{
private const int count = 10000;