Skip to content

Instantly share code, notes, and snippets.

View alexshyba's full-sized avatar
🏀

Alex Shyba alexshyba

🏀
View GitHub Profile
@alexshyba
alexshyba / gist:6116855
Created July 30, 2013 20:56
Subscribing to item:saved where you can access item changes and do lots of efficient exclusion.
Event.Subscribe("item:saved", this.Item_Saved);
private void Item_Saved([NotNull] object sender, [NotNull] EventArgs e)
{
var changes = Event.ExtractParameter<ItemChanges>(e, 1);
if (!changes.IsFieldModified(FieldIDs.Security) && !changes.IsFieldModified(FieldIDs.Workflow) &&
!changes.IsFieldModified(FieldIDs.WorkflowState))
{
return;
@alexshyba
alexshyba / gist:6197773
Created August 9, 2013 22:18
Playing with dotTrace SDK
var config = new JetBrains.dotTrace.Api.SaveSnapshotProfilingConfig(@"C:\perflog\publish_profiling\")
{
ProfilingControlKind = JetBrains.dotTrace.Api.ProfilingControlKind.API,
TempPath = @"C:\perflog\publish_profiling\temp",
RedistPath = @"C:\perflog\Redist\JetBrains.dotTrace.ExternalLauncherProcess.exe",
SavePath = @"C:\perflog\publish_profiling\",
SnapshotFormat = JetBrains.dotTrace.Api.SnapshotFormat.Compressed,
CoreLogMask = 6,
};
@alexshyba
alexshyba / IndexingProvider.cs
Created August 12, 2013 20:47
IndexingProvider.GetHistory
Log.Info("*** IndexingProvider.GetHistory(). Starting processing history collection.", new object());
var result = new HistoryEntryCollection();
foreach (HistoryEntry entry in history)
{
IEnumerable<HistoryEntry> historyEntries = from historyEntry in history
where historyEntry.Action == entry.Action && historyEntry.ItemId == entry.ItemId &&
historyEntry.ItemLanguage == entry.ItemLanguage && historyEntry.ItemVersion == entry.ItemVersion && historyEntry.Created > entry.Created
select historyEntry;
if (historyEntries.Count() > 0)
@alexshyba
alexshyba / gist:6233235
Created August 14, 2013 17:19
exception
ManagedPoolThread #4 10:17:51 ERROR Cannot start profiler. The directory name is invalid.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.Directory.SetCurrentDirectory(String path)
at JetBrains.dotTrace.Api.SelfAttachImpl.StartSelfAttach(BaseProfilingConfig config, String executablePath, String savePath, UInt16 storageFmt)
at JetBrains.dotTrace.Api.SelfAttachImpl.Attach(BaseProfilingConfig config)
var config = new JetBrains.dotTrace.Api.SaveSnapshotProfilingConfig(@"C:\perflog\publish_profiling\")
{
ProfilingControlKind = JetBrains.dotTrace.Api.ProfilingControlKind.API,
TempPath = @"C:\perflog\publish_profiling\temp",
//changed this
RedistPath = @"C:\perflog\Redist\",
SavePath = @"C:\perflog\publish_profiling\",
SnapshotFormat = JetBrains.dotTrace.Api.SnapshotFormat.Compressed,
CoreLogMask = 6,
};
@alexshyba
alexshyba / _.md
Created April 15, 2015 23:21
sitecorian
@alexshyba
alexshyba / README.md
Created November 6, 2015 03:35
my first block
@alexshyba
alexshyba / mapreduce.js
Created November 25, 2015 22:11
Mongo: accessing goal properties in XDB with map reduce
var map = function m() {
for (var p = 0; p < this.Pages.length; p++)
{
if(this.Pages[p].PageEvents){
for (var e = 0; e < this.Pages[p].PageEvents.length; e++){
var key = this.Pages[p].PageEvents[e].Name;
var text = this.Pages[p].PageEvents[e].Text;
if(text && text.indexOf('=' > -1) && text.indexOf('&' > -1)){
var keys = text.split("&");
if(keys.length > 0)
@alexshyba
alexshyba / aggregate.js
Created November 25, 2015 22:12
Mongo: using aggregate to access page event meta data within XDB
db.Interactions.aggregate([
{ "$match": { "StartDateTime": { $gte: ISODate("2015-11-01T00:00:00.000Z"),
$lt: ISODate("2015-11-01T03:00:00.000Z")}}},
{ $project : { Pages : "$Pages" } },
// Un-wind the array's to access filtering
{ "$unwind": "$Pages" },
{ "$unwind": "$Pages.PageEvents" },
// Group results to obtain the matched count per key
{ "$group": {
@alexshyba
alexshyba / GetProps.cs
Created February 7, 2016 20:15
GetProps
private dynamic GetProps()
{
dynamic props = new ExpandoObject();
var dataSourceItem = GetDataSourceItem();
foreach (Field field in dataSourceItem.Fields)
{
if (field.Name.StartsWith("__"))
{
continue;