Skip to content

Instantly share code, notes, and snippets.

View jkarsrud's full-sized avatar

Jesper Haug Karsrud jkarsrud

View GitHub Profile
@jkarsrud
jkarsrud / BundleInstall.md
Last active May 27, 2020 08:51
How to use ASP.NET Bundling and Minifications in Umbraco

How to use ASP.NET Bundling and Minifications in Umbraco

Using the ASP.NET bundling and minifications is pretty straight forward, but here is a small guide that take care of a few gotchas when implementing bundles in your Umbraco project.

Installing ASP.NET Bundling and Minifications

ASP.NET Bundling and Minifications is part of the Microsoft ASP.NET Web Optimization Framework and is installed via NuGet;

PM> Install-Package Microsoft.AspNet.Web.Optimization

Once this is done, you need to create a BundleConfig.cs in your App_Start1 folder. This is where you register your different bundles. It can be extremely simple, or it can be more complex, but the gist of it is this;

@jkarsrud
jkarsrud / project.js
Created May 21, 2013 12:51
Sequelize model definition
module.exports = function(sequelize, DataType) {
return sequelize.define('Project', {
id: {type: DataType.INTEGER, autoIncrement: true, primaryKey: true},
name: { type: DataType.STRING, allowNull: false},
description: DataType.TEXT
});
};
@jkarsrud
jkarsrud / db.js
Created May 28, 2013 07:58
Dreamcode of global sequelize connection checking
var sequelize = new Sequelize(config.db, config.user, config.pass).error(function() {
// do some error handling
});
@jkarsrud
jkarsrud / application.js
Created May 28, 2013 13:43
Ember Templates in script files
var application = "<h1>{{name}}</h1>\n<p>{{content}}</p><ul>{{#each item}}<li>{{item.name}}</li>{{/each}}</ul>";
Ember.TEMPLATES["application"] = Ember.Handlebars.compile(application);
// Do the same for more templates if you like
// Template
Ember.Handlebars.compile("<h1>{{name}}</h1>\n<p>{{content}}</p><ul>{{#each item}}<li>{{item.name}}</li>{{/each}}</ul>")
// Compiled js version
function (context, options) {
options = options || {};
var result = templateSpec.call(container, Handlebars, context, options.helpers, options.partials, options.data);
var compilerInfo = container.compilerInfo || [],
compilerRevision = compilerInfo[0] || 1,
App.ProjectsController = Ember.ArrayController.extend({
cancel: function() {
// Do something
}
});
App.ProjectsNewController = Ember.ArrayController.extend({
create: function() {
// Do something
}
var events = Model.Content.Descendants("Event")
.Where(x => x.GetPropertyValue<DateTime>("startTime").Date >= DateTime.UtcNow.Date)
.OrderByDescending(x => x.GetPropertyValue<DateTime>("startTime"));
@jkarsrud
jkarsrud / controller.cs
Created August 22, 2013 14:36
Setting up and using the UmbracoHelper inside a custom controller
public class HomeController : Controller
{
private readonly UmbracoHelper _umbracoHelper = new UmbracoHelper(UmbracoContext.Current);
public ActionResult Index()
{
var node = _umbracoHelper.TypedContent(1000);
return View(node);
}
}
@jkarsrud
jkarsrud / exception
Last active December 25, 2015 06:49
Umbraco.CodeGen exception
[ArgumentNullException: Value cannot be null.
Parameter name: value]
System.Xml.Linq.XText..ctor(String value) +97958
System.Xml.Linq.XCData..ctor(String value) +4
Umbraco.CodeGen.DocumentTypeXmlGenerator.GenerateProperty(PropertyDeclaration prop) +1055
System.Linq.WhereSelectEnumerableIterator`2.MoveNext() +145
System.Xml.Linq.XContainer.AddContentSkipNotify(Object content) +273
System.Xml.Linq.XElement..ctor(XName name, Object content) +22
Umbraco.CodeGen.DocumentTypeXmlGenerator.Generate(TypeDeclaration type) +379
System.Linq.WhereSelectEnumerableIterator`2.MoveNext() +145
@jkarsrud
jkarsrud / web.config40.xml
Last active December 29, 2015 02:29
Assembly redirect differences in Umbraco 7 on .NET 4.5 vs. .NET 4.0
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<!-- Old asp.net ajax assembly bindings -->
<dependentAssembly>
<assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="4.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="4.0.0.0"/>