Skip to content

Instantly share code, notes, and snippets.

@vivianroberts
vivianroberts / ContentSearchTesting.cs
Last active October 20, 2023 10:33
Solution to the wretched "There is no method 'GetResults' on type 'Sitecore.ContentSearch.Linq.QueryableExtensions' that matches the specified arguments" error when unit testing search. Sitecore is tightly coupled to their own implemention of IQueryProvider which contains an 'Execute' method not found on standard .Net implementions.
View ContentSearchTesting.cs
namespace Testing
{
public class NewsController_LatestNews
{
[Theory]
[AutoData]
public void Should_be_news_items_ordered_by_date_descending(IEnumerable<NewsResultItem> newsResultItems)
{
var searchContext = Substitute.For<IProviderSearchContext>();
var queryable = new LuceneProviderQueryableStub(enumerable);
@kamsar
kamsar / Install Solr.ps1
Last active February 26, 2019 14:30
Sitecore Solr Cannon
View Install Solr.ps1
# This script will set up (and install if needed) Apache Solr for a Sitecore instance.
# This does NOT configure Sitecore to use Solr,
# just the Solr server and cores for Sitecore to connect to once it is set up to use Solr.
# So, what does it do?
#
# * Installs SOLR, if needed, from the Bitnami SOLR stack: https://bitnami.com/stack/solr/installer
# * Creates a SOLR config set for the cores to share (shared schema)
# * Creates SOLR cores for all Sitecore indexes, including secondary cores to support online reindexing (Switch on Rebuild)
@gaearon
gaearon / combining.js
Created June 3, 2015 18:03
Combining Stateless Stores
View combining.js
// ------------
// counterStore.js
// ------------
import {
INCREMENT_COUNTER,
DECREMENT_COUNTER
} from '../constants/ActionTypes';
const initialState = { counter: 0 };
@nicolashery
nicolashery / rxjs-react.js
Last active August 1, 2022 03:36
Fetching data asynchronously with RxJS and React
View rxjs-react.js
import React from 'react';
import _ from 'lodash';
import Rx from 'rx';
import superagent from 'superagent';
let api = {
host: 'http//localhost:3001',
getData(query, cb) {
superagent
@anaisbetts
anaisbetts / request-rx.js
Created February 18, 2015 06:36
Rx'ification of request
View request-rx.js
'use 6to5';
const rx = require('rx');
const request = require('request');
let wrapMethodInRx = (method) => {
return function(...args) {
return rx.Observable.create((subj) => {
// Push the callback as the last parameter
args.push((err, resp, body) => {
@sebmarkbage
sebmarkbage / Enhance.js
Last active September 21, 2023 08:13
Higher-order Components
View Enhance.js
import { Component } from "React";
export var Enhance = ComposedComponent => class extends Component {
constructor() {
this.state = { data: null };
}
componentDidMount() {
this.setState({ data: 'Hello' });
}
render() {
@yocontra
yocontra / LazyLoad.js
Created December 2, 2014 01:23
lazy loading react components, useful for video/audio/etc
View LazyLoad.js
var React = require('react');
var events = require('add-event-listener');
var isVisible = require('../isVisible');
var LazyLoad = React.createClass({
displayName: 'LazyLoad',
propTypes: {
distance: React.PropTypes.number,
component: React.PropTypes.node.isRequired,
children: React.PropTypes.node.isRequired
@davidfowl
davidfowl / dotnetlayout.md
Last active November 29, 2023 16:15
.NET project structure
View dotnetlayout.md
$/
  artifacts/
  build/
  docs/
  lib/
  packages/
  samples/
  src/
 tests/
@herskinduk
herskinduk / ArticleViewRendering.cshtml
Last active April 29, 2016 08:34
Sitecore MVC inside-out layout
View ArticleViewRendering.cshtml
@using Sitecore.Mvc.Presentation
@using Sitecore.Mvc
@model RenderingModel
@{
Layout = null;
Sitecore.Context.Items["twitter:title"] = Model.Item["title"]
Sitecore.Context.Items["twitter:description"] = Model.Item["description"]
}
<h1>@Html.Sitecore().Field("title")</h1>
@Html.Sitecore().Field("text")
@staltz
staltz / introrx.md
Last active December 1, 2023 08:15
The introduction to Reactive Programming you've been missing
View introrx.md