Skip to content

Instantly share code, notes, and snippets.

Avatar

Janae Cram naepalm

View GitHub Profile
@naepalm
naepalm / DictionaryController.cs
Created Feb 8, 2017
Get all dictionary items for a language on a site and spit them out in an API Controller.
View DictionaryController.cs
using System;
using System.Collections.Generic;
using System.Linq;
using Umbraco.Web;
using Umbraco.Web.WebApi;
namespace Olympic.Web.Controllers.Api
{
public class DictionaryController : UmbracoApiController
{
@naepalm
naepalm / TextOverImagePartial.cshtml
Created Jan 12, 2017
Files to easily render the Text Over Image Editor on the front.
View TextOverImagePartial.cshtml
@model TextOverImage.Models.ImageWithText
@{
// Use this code to render this partial in your template. Replace "banner" with whatever your property name is
// Make sure to include @using TextOverImage.Models at the top of your template
//@if(Model.Content.HasProperty("banner") && Model.Content.HasValue("banner"))
//{
// @Html.Partial("TextOverImagePartial", Model.Content.GetPropertyValue<ImageWithText>("banner")
//}
@naepalm
naepalm / RazorServerDirectoryListingHelper.cshtml
Created Aug 17, 2016
Displays a list of directories and files on a server, for those nasty moments when you don't have access and are looking for something.
View RazorServerDirectoryListingHelper.cshtml
@helper RenderFolders(string dirPath, bool displaySubDirs = false)
{
try
{
List<string> dirs = new List<string>(Directory.EnumerateDirectories(dirPath));
<h4>@string.Format("Directory: {0}", dirPath.Substring(dirPath.LastIndexOf("\\") + 1))</h4>
<p>@(string.Format("{0} directories found.", dirs.Count))</p>
<ul>
@foreach (var dir in dirs)
@naepalm
naepalm / TastyCookies.js
Last active Aug 23, 2016
Kyle's handy-dandy cookie scripts.
View TastyCookies.js
/**
* @class Cookie
* @description Helper functions for adding and deleting cookies.
*/
var Cookie = {
/**
* @method delete
* @param {string} cookieName - The name of the cookie to delete.
* @description Deletes the indicated cookie.
*/
@naepalm
naepalm / Helpers.js
Last active Aug 3, 2017
Helper functions for react, such as price currency formatting.
View Helpers.js
var Helpers = {
/**
* @function formatMoney
* @param {number} n - The number to be formatted
* @param {string} d - The character to be used for the decimal. Defaults to ".".
* @param {string} t - the character to be used for the thousands separator. Defaults to ",".
* @param {int} c - the number of decimal places. Defaults to 2.
* @returns {string}
* @description Formats a number to a price
*/
View CacheService.cs
public class CacheService : ICacheService
{
private readonly MemoryCache _memoryCache = new MemoryCache("Cache.Key");
public void Add<T>(T cacheObject, string key)
{
var cacheItemPolicy = new CacheItemPolicy
{
AbsoluteExpiration = DateTimeOffset.Now.AddHours(24)
};
@naepalm
naepalm / ContentExtensions.cs
Last active Jan 10, 2019
A set of useful extension methods for Umbraco properties.
View ContentExtensions.cs
namespace Client.Web
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Models;
using Newtonsoft.Json;
using Umbraco.Core.Models;
@naepalm
naepalm / ContactForm.cs
Created Dec 3, 2015
Contact Form for Umbraco with a Departments dropdown list. Assumes the dropdown list is NestedContent on the selected Email Template.
View ContactForm.cs
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using Umbraco.Core.Models;
using Umbraco.Web;
namespace Forms.Web.Models
{
public class ContactForm
{
@naepalm
naepalm / MediaSave.cshtml
Last active Dec 3, 2015
A little razor template snippet that re-saves/republishes all media in Umbraco
View MediaSave.cshtml
@using Umbraco.Core.Models;
@{
var mediaService = ApplicationContext.Current.Services.MediaService;
SaveMedias(mediaService.GetRootMedia().ToList());
}
@functions
{
View EventsLogic.cs
namespace Client.Web.Models
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Buzz.Hybrid;
using Buzz.Hybrid.Models;