Skip to content

Instantly share code, notes, and snippets.

View javafun's full-sized avatar

Vincent javafun

View GitHub Profile
@kamsar
kamsar / Install Solr.ps1
Last active February 26, 2019 14:30
Sitecore Solr Cannon
# 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)
@naepalm
naepalm / Pagination.cshtml
Last active December 22, 2021 12:29
A "quick & easy" razor pagination to plug into an Umbraco View, Partial View, or Macro
@{
var pageSize = 8;
if(Model.Content.HasValue("numberOfItemsPerPage")){
pageSize = Model.Content.GetPropertyValue<int>("numberOfItemsPerPage");}
var page = 1; int.TryParse(Request.QueryString["page"], out page);
var items = Umbraco.TypedContent(Model.Content.Id).Children.Where(x => x.DocumentTypeAlias == "exampleAlias" && x.IsVisible()).OrderByDescending(x => x.CreateDate);
var totalPages = (int)Math.Ceiling((double)items.Count() / (double)pageSize);
if (page > totalPages)
@kamsar
kamsar / Performance.Dev.config
Last active August 17, 2021 16:04
SItecore 8.0/8.1/8.2 Performance Config
<!--
A set of performance optimizations for development that vastly increase application startup time.
Should not be used in production, as they largely disable forensic diagnostics that you'd want there over fast startup time after a compile.
-->
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<hooks>
<hook type="Sitecore.Diagnostics.HealthMonitorHook, Sitecore.Kernel">
<patch:delete />
@dcollien
dcollien / ImageTools.es6
Last active April 28, 2023 09:00
Resize Images in the Browser
let hasBlobConstructor = typeof(Blob) !== 'undefined' && (function () {
try {
return Boolean(new Blob());
} catch (e) {
return false;
}
}());
let hasArrayBufferViewSupport = hasBlobConstructor && typeof(Uint8Array) !== 'undefined' && (function () {
try {

Git DMZ Flow

I've been asked a few times over the last few months to put together a full write-up of the Git workflow we use at RichRelevance (and at Precog before), since I have referenced it in passing quite a few times in tweets and in person. The workflow is appreciably different from GitFlow and its derivatives, and thus it brings with it a different set of tradeoffs and optimizations. To that end, it would probably be helpful to go over exactly what workflow benefits I find to be beneficial or even necessary.

  • Two developers working on independent features must never be blocked by each other
    • No code freeze! Ever! For any reason!
  • A developer must be able to base derivative work on another developer's work, without waiting for any third party
  • Two developers working on inter-dependent features (or even the same feature) must be able to do so without interference from (or interfering with) any other parties
  • Developers must be able to work on multiple features simultaneously, or at lea
@davidknipe
davidknipe / AddMetaClass.cs
Created March 5, 2015 10:52
Create an EPiServer Commerce Metafield programmatically and add it to a Metaclass in Business Foundation
/// <summary>
/// Programmatically create a new MetaField on the Contact MetaClass <seealso href="http://world.episerver.com/documentation/Items/Developers-Guide/EPiServer-Commerce/8/Business-Foundation/Business-Meta-Model/MetaField-class/"/>
/// </summary>
private void setupMetaField()
{
MetaClassManager metaModel = DataContext.Current.MetaModel;
foreach (MetaClass mc in metaModel.MetaClasses)
{
if (mc.Name == "Contact")
{
@jashkenas
jashkenas / semantic-pedantic.md
Last active November 29, 2023 14:49
Why Semantic Versioning Isn't

Spurred by recent events (https://news.ycombinator.com/item?id=8244700), this is a quick set of jotted-down thoughts about the state of "Semantic" Versioning, and why we should be fighting the good fight against it.

For a long time in the history of software, version numbers indicated the relative progress and change in a given piece of software. A major release (1.x.x) was major, a minor release (x.1.x) was minor, and a patch release was just a small patch. You could evaluate a given piece of software by name + version, and get a feeling for how far away version 2.0.1 was from version 2.8.0.

But Semantic Versioning (henceforth, SemVer), as specified at http://semver.org/, changes this to prioritize a mechanistic understanding of a codebase over a human one. Any "breaking" change to the software must be accompanied with a new major version number. It's alright for robots, but bad for us.

SemVer tries to compress a huge amount of information — the nature of the change, the percentage of users that wil

namespace Alphabet
{
public class AlphabetTest
{
public static readonly string Alphabet = "abcdefghijklmnopqrstuvwxyz0123456789";
public static readonly int Base = Alphabet.Length;
public static string Encode(int i)
{
if (i == 0) return Alphabet[0].ToString();
@JimBobSquarePants
JimBobSquarePants / CamelCase.cs
Last active January 5, 2019 09:55
Maps an instance of IPublishedContent to a strong typed Model. This would allow you to use models in your views and save logic. In your controller you should be able to use var MyModel = ModelMapper.Map<Type>(renderModel.Content); This could easily be turned into an extension method IPublishedContent. Based on the MVC separation article by Nick …
namespace UmbracoBootstrap.Infrastructure.Extensions
{
#region Using
using System.Diagnostics.CodeAnalysis;
#endregion
/// <summary>
/// Encapsulates a series of time saving extension methods to <see cref="T:System.String">String</see>s.
/// </summary>
public static class StringExtensions
@dereklawless
dereklawless / MembershipProviderExtensions.cs
Created November 13, 2012 23:23
Convert encrypted ASP.NET membership passwords to clear-form.
/// <summary>
/// Extensions for membership providers.
/// </summary>
public static class MembershipProviderExtensions
{
/// <summary>
/// Switches the specified ASP.NET membership user to a clear password format, updating the associated fields.
/// </summary>
/// <param name="user">The membership user.</param>
/// <exception cref="System.ArgumentNullException" />