Skip to content

Instantly share code, notes, and snippets.

@sshushliapin
sshushliapin / SitecoreUnitTestingSamples.FirstMock
Last active December 21, 2023 11:28
Switching from FakeDb to mocks
using AutoFixture;
using AutoFixture.Kernel;
using AutoFixture.Xunit2;
using NSubstitute;
using Sitecore.Data;
using Sitecore.Data.Items;
using Xunit;
namespace SitecoreUnitTestingSamples
{
@lowedown
lowedown / IdentifyExample.cs
Last active May 2, 2022 22:13
XConnect Contact Repository and service for use in Sitecore components (Tracker must be active)
// Important: Get consent from user first before identifying. Make sure all applicable rules and regulations are followed correctly.
var service = new TrackingService();
service.IdentifyAs("e-mail", "[email protected]");
service.SetContactName("John", "Doe");
service.SetContactEmail("[email protected]");
@Swimburger
Swimburger / App.config
Created October 12, 2017 14:57
Change username, password and lockout from console application Asp.net identity
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
<connectionStrings>
<add name="core" connectionString="yourconnectionstring" providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.web>
<membership defaultProvider="sql" hashAlgorithmType="SHA512">
@mrkrndvs
mrkrndvs / export-named-sheet-as-csv.gs
Last active September 5, 2025 12:51 — forked from mderazon/export-to-csv.gs
Google apps script to export an individual sheet as csv file
/*
* script to export data of the named sheet as an individual csv files
* sheet downloaded to Google Drive and then downloaded as a CSV file
* file named according to the name of the sheet
* original author: Michael Derazon (https://gist.github.com/mderazon/9655893)
*/
function onOpen() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var csvMenuEntries = [{name: "Download Primary Time File", functionName: "saveAsCSV"}];
@whereisaaron
whereisaaron / pfx-to-crt-and-key.sh
Last active October 3, 2025 18:12
Extract a crt file (PEM), key file, and chain bundle from a PFX file, prompts for password or use PFXPASSWORD environment variable
#!/bin/bash
#------------------
# Extract the key, certficiate, and chain in PEM format from a PFX format file
#
# Must supply the input pfx file
PFX_PATH="$1"
if [ "${PFX_PATH}" == "" ]; then
echo "Must supply pfx file path"
exit 1
@jammykam
jammykam / CreateUsers.ps1
Last active April 4, 2022 18:22
Create Users and Add to specified roles from CSV file using Sitecore PowerShell Extensions
$VerbosePreference = "Continue"
$newUsersFile = Receive-File -Path "C:\temp\upload" -CancelButtonName "No, I will do it using MS Excel instead"
$newUsers = Import-Csv -Path $newUsersFile
foreach($user in $newUsers) {
Write-Verbose "Creating User: $($user.Username)"
New-User -Identity $($user.Username) -Enabled -Password $($user.Password) -Email $($user.Email) -FullName "$($user.Name)"
$($user.Roles).Split(",") | ForEach {