Skip to content

Instantly share code, notes, and snippets.

@DaveGoosem
DaveGoosem / changeDBowner.sql
Created May 16, 2013 00:17
Forcibly changes the owner of a Databse
--replace <newOwner> with DB user
exec sp_changedbowner '<newOwner>'
@DaveGoosem
DaveGoosem / sessionTimeout.xml
Created May 17, 2013 02:09
To set the session timeout value for admin Sitecore users.
<!--
Session expiration for the Sitecore Client.
When managing Client sessions, Sitecore keeps track of every user logged in to the system and assigns a Sitecore user ticket to every user accessing a Sitecore Client application. Sitecore Client user session is not limited in time and is kept alive until the browser is opened.
However, if after 8 hours of the current user inactivity another user logs in and the current Sitecore license used has a concurrent number of users limitation – a newly logged in user may take the currently logged in user’s license slot. Current user will be redirected to the login page when trying to use any Sitecore Client application if there are no more available license slots left for him to automatically re-login to the system.
If 8 hours inactivity period is too long and needs to be changed, the following workaround can be applied:
Copy the Sitecore.Support.323551.dll assembly to the \bin folder.
http://sdn.sitecore.net/upload/faq/session%20expiration/sitecore.support.323551.
@DaveGoosem
DaveGoosem / AdaptiveDesign.css
Created May 26, 2013 12:24
Adaptive Design - Media Queries
/* Plonk as many of these as you need for each device/context and they will be
applied when the media query defined is met.*/
@media screen and (max-width: 320px)
{
/* all styles for this query size go here. */
/*
for mobile, get of as many floats as possible sot hey sit on top
of eachother down the page nicely.
@DaveGoosem
DaveGoosem / getPublishDate.cs
Created June 13, 2013 12:12
Get Sitecore item 'last published' value AKA 'updated'
public Item item;
public String PublishDate()
{
DateTime postDate = Context.Item.Statistics.Updated;
return postDate != null ? postDate.ToString("MMMM dd yyyy H:mm:ss tt") : String.Empty;
}
@DaveGoosem
DaveGoosem / dropDownPopulate.cs
Created June 16, 2013 23:55
Populate Drop Down List with Sitecore data template items
//IncidentCategoryList is the list control
//In this example we are only showing child items of the datasourced item which are using a specific Sitecore template named 'IncidentCategory'
foreach (
var categoryDropDownItem in
DataSourceItem(IncidentCategoryItemId).Children.Where(z => z.TemplateName == "IncidentCategory"))
{
IncidentCategoryList.Add(categoryDropDownItem.DisplayName);
}
// The SecurityDisabler overrides the current security model, allowing you
// to access the item without any security. It's like the user being an administrator
using (new Sitecore.SecurityModel.SecurityDisabler())
{
// Get the master database
Sitecore.Data.Database master = Sitecore.Data.Database.GetDatabase("master");
// Get the template to base the new item on
Items.TemplateItem template = master.GetItem("/sitecore/templates/Sample/Sample Item");
// Get the place in the site tree where the new item must be inserted
@DaveGoosem
DaveGoosem / javascriptModel.js
Last active August 4, 2023 05:30
JavaScript Module Model base. Pinched from Simon here: https://gist.github.com/captainclam/3290833
/*!
* ProjectName SomeModule
* @requires jQuery v1.7.2+
* @requires Underscore v1.3.3+
*
* This comment block is here to encourage you to properly document your modules
* USE IT!
* Particularly if it has odd dependencies they should be listed.
*/
@DaveGoosem
DaveGoosem / MediaLibraryExporter.aspx
Created August 21, 2013 00:21
Export Sitecore Media Library Images to file system
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="MediaLibraryExporter.aspx.cs" Inherits="RBSM.MediaLibraryExporter" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
@DaveGoosem
DaveGoosem / geolookup.js
Created November 5, 2013 01:23
geo lookup from google api sample code which uses callback query string to load <script> for gmaps api only if element exists on page
/*!
* GeoLocation
* @requires jQuery v1.7.2+
*
* Description
* auto-populates a field with geo-location data
*/
; (function ($) {
window.Motorama.geoLocation = window.Motorama.geoLocation || window.Motorama.BaseModule(function () {
@DaveGoosem
DaveGoosem / performance-analysis.js
Created November 12, 2013 14:55
Simple Javascript Performance Testing. Write the same code using different methods and then use this to test execution time (can output it to console). Dev tools may / may not give you same results.
/*
* We need to run the code sample more than once to get a better idea of running time during analysis.
* set this value to be however many times you want to run the code to get a good analysis
* of running time
*/
var maxCount = 20;
var start = new Date().getTime();
for (var n = 0; n < maxCount; n++) {
/* perform operation you want to measure */
}