Skip to content

Instantly share code, notes, and snippets.

View PetersonDave's full-sized avatar

David Peterson PetersonDave

View GitHub Profile
@michaellwest
michaellwest / Cognifide.PowerShell.Services.config
Last active September 14, 2016 14:23
Sitecore PowerShell Extensions Workshop - Sitecore Symposium 2016
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<powershell>
<services>
<mediaUpload>
<patch:attribute name="enabled">true</patch:attribute>
</mediaUpload>
<fileDownload>
<patch:attribute name="enabled">true</patch:attribute>
</fileDownload>
@AdamNaj
AdamNaj / Remove-OldItemVersion.ps1
Last active March 3, 2021 22:21
Item Version Pruner
function Remove-OldItemVersion {
[CmdletBinding()]
param(
[Parameter(Position = 0,Mandatory = $true,ValueFromPipeline = $true)]
[ValidateNotNullOrEmpty()]
[Sitecore.Data.Items.Item]$Item,
[Parameter(Position = 1,Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[int]$MaxVersions
)
#
# MongoDB (as a windows service)
#
$mongoDbPath = "$env:SystemDrive\MongoDB"
$mongoDbConfigPath = "$mongoDbPath\mongod.cfg"
$url = "https://fastdl.mongodb.org/win32/mongodb-win32-x86_64-2008plus-3.2.7.zip"
$zipFile = "$mongoDbPath\mongo.zip"
$unzippedFolderContent ="$mongoDbPath\mongodb-win32-x86_64-2008plus-3.2.7"
if ((Test-Path -path $mongoDbPath) -eq $false)
function resolve(val) {
alert('Counted to ' + val);
return val;
}
function reject(reason) {
alert('Could not count');
return reason;
}
@kamsar
kamsar / async.cs
Created October 29, 2013 02:02
Demonstration of using async to grab a bunch of Sitecore queries in parallel Performance on a dual-core machine appeared to be 30-100% faster than iterative.
using System.Linq;
using Isite.Sitecore.UI.WebControls;
using Isite.Extensions;
using System.Web.UI;
using System.Threading.Tasks;
using Sitecore.Data.Items;
using System.Collections.Generic;
using System.Threading;
using Sitecore.Caching;
using System.Diagnostics;
@joa
joa / code.js
Created June 6, 2013 12:17
Gmail Life Saver
function archiveInbox() {
var query = 'label:inbox is:read older_than:28d -label:unanswered -label:unread';
var batchSize = 100;
while(GmailApp.search(query, 0, 1).length == 1) {
GmailApp.moveThreadsToArchive(GmailApp.search(query, 0, batchSize));
}
}