Skip to content

Instantly share code, notes, and snippets.

View alexshyba's full-sized avatar
🏀

Alex Shyba alexshyba

🏀
View GitHub Profile
@alexshyba
alexshyba / CustomHead.tsx
Created November 9, 2020 19:32
Disabling Next.js scripts, `NEXT_DATA` and React rehydration
import React from 'react';
import { Head } from 'next/document';
import { cleanAmpPath } from 'next/dist/next-server/server/utils'
function getOptionalModernScriptVariant(path: string) {
if (process.env.__NEXT_MODERN_BUILD) {
return path.replace(/\.js$/, '.module.js')
}
return path
}
@alexshyba
alexshyba / sym2018-talk-links.md
Last active October 15, 2018 22:06
links from my Sitecore Symposium 2018 talk on Experience the development workflow of your dreams with modern JavaScript and Sitecore JSS
@alexshyba
alexshyba / ContextItemChildrenRenderingContentsResolver.cs
Created November 20, 2017 18:20
Sample IRenderingContentsResolver implementations.
using Newtonsoft.Json.Linq;
using Sitecore;
using Sitecore.Data.Items;
using Sitecore.Diagnostics;
using Sitecore.LayoutService.Configuration;
using Sitecore.LayoutService.ItemRendering;
using Sitecore.Links;
using Sitecore.Mvc.Presentation;
namespace Nomad.Jss.CodeFirst.ItemRendering
@alexshyba
alexshyba / counter.jsx
Created February 7, 2016 21:39
Counter component
var Counter = React.createClass({
getInitialState: function() {
return {secondsElapsed: 0};
},
tick: function() {
this.setState({secondsElapsed: this.state.secondsElapsed + 1});
},
componentDidMount: function() {
this.interval = setInterval(this.tick, 1000);
},
@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;
@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 / 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 / README.md
Created November 6, 2015 03:35
my first block
@alexshyba
alexshyba / _.md
Created April 15, 2015 23:21
sitecorian
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,
};