Skip to content

Instantly share code, notes, and snippets.

View brendan-rice's full-sized avatar

Brendan Rice brendan-rice

View GitHub Profile
@brendan-rice
brendan-rice / MediaHelper.cs
Created February 19, 2018 13:13 — forked from greystate/MediaHelper.cs
Helper for rendering media
/// <summary>
/// Overload to render an img tag with srcset and src attributes for a media item,
/// using the specified output width.
/// </summary>
public static HtmlString RenderMedia(object mediaId, int width) {
string imageTag = "";
try {
var media = umbracoHelper.TypedMedia(mediaId);
if (media != null) {
@brendan-rice
brendan-rice / Sitemap.cshtml
Created February 19, 2018 13:08
Sitemap for Umbraco CS.
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@using Umbraco.Core.Models
@using Umbraco.Web
@using System.Linq;
@{ Layout = null;
Response.ContentType = "text/xml";
}<?xml version='1.0' encoding='UTF-8' ?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemalocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
@brendan-rice
brendan-rice / ExamineExtensions.cs
Created February 19, 2018 13:05 — forked from rasmuseeg/ExamineExtensions.cs
Umbraco Extensions
using System;
using System.Globalization;
namespace Umbraco.Examine
{
public static class ExamineExtensions
{
private static string format = "yyyyMMddHHmmssfff";
public static DateTime? ParseExamineDate(this string s)
@brendan-rice
brendan-rice / gist:43b1ef9ffa0d86b377c77314e565caa4
Created February 19, 2018 12:56 — forked from kgiszewski/gist:9842878
v7 Umbraco UrlPicker Gist
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@using UrlPicker.Umbraco.Models;
@{
Layout = "BasePage.cshtml";
var urlPicker = Model.Content.GetPropertyValue<UrlPicker>("myUrlPickerPropAlias");
}
<div>Name: @urlPicker.Name</div>
@brendan-rice
brendan-rice / responsive.js
Created April 16, 2017 00:49 — forked from sniffdk/responsive.js
Small utility functions for handling responsive changes to javascript stuff.
var breakpoints = {
xs: 480,
sm: 768,
md: 992,
lg: 1200
},
currentWidth = 0,
currentBreakpoint = "",
breakpointMethods = []; // array of methods to be run whenever a breakpoint change is registered
DELETE FROM umbracoUser2NodeNotify WHERE umbracoUser2NodeNotify.nodeId IN (SELECT TB1.nodeId FROM umbracoUser2NodeNotify as TB1 INNER JOIN umbracoNode as TB2 ON TB1.nodeId = TB2.id WHERE TB2.trashed = '1' AND TB2.nodeObjectType = 'c66ba18e-eaf3-4cff-8a22-41b16d66a972')
DELETE FROM umbracoUser2NodePermission WHERE umbracoUser2NodePermission.nodeId IN (SELECT TB1.nodeId FROM umbracoUser2NodePermission as TB1 INNER JOIN umbracoNode as TB2 ON TB1.nodeId = TB2.id WHERE TB2.trashed = '1' AND TB2.nodeObjectType = 'c66ba18e-eaf3-4cff-8a22-41b16d66a972')
DELETE FROM umbracoAccessRule WHERE umbracoAccessRule.accessId IN (
SELECT TB1.id FROM umbracoAccess as TB1
INNER JOIN umbracoNode as TB2 ON TB1.nodeId = TB2.id
WHERE TB2.trashed = '1' AND TB2.nodeObjectType = 'c66ba18e-eaf3-4cff-8a22-41b16d66a972')
DELETE FROM umbracoAccess WHERE umbracoAccess.nodeId IN (SELECT TB1.nodeId FROM umbracoAccess as TB1 INNER JOIN umbracoNode as TB2 ON TB1.nodeId = TB2.id WHERE TB
public class BindXmlAttribute : CustomModelBinderAttribute
{
public override IModelBinder GetBinder()
{
return new XmlModelBinder();
}
}
@brendan-rice
brendan-rice / Web.config
Last active August 29, 2015 14:17 — forked from sabbour/Web.config
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Remove index.php rule" stopProcessing="true">
<match url=".*" ignoreCase="false"/>
<conditions>
<add input="{URL}" pattern="^/(media|skin|js)/" ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />

"Help, I keep getting a 'Permission Denied (publickey)' error when I push!"

This means, on your local machine, you haven't made any SSH keys. Not to worry. Here's how to fix:

  1. Open git bash (Use the Windows search. To find it, type "git bash") or the Mac Terminal. Pro Tip: You can use any *nix based command prompt (but not the default Windows Command Prompt!)
  2. Type cd ~/.ssh. This will take you to the root directory for Git (Likely C:\Users\[YOUR-USER-NAME]\.ssh\ on Windows)
  3. Within the .ssh folder, there should be these two files: id_rsa and id_rsa.pub. These are the files that tell your computer how to communicate with GitHub, BitBucket, or any other Git based service. Type ls to see a directory listing. If those two files don't show up, proceed to the next step. NOTE: Your SSH keys must be named id_rsa and id_rsa.pub in order for Git, GitHub, and BitBucket to recognize them by default.
  4. To create the SSH keys, type ssh-keygen -t rsa -C "your_email@example.com". Th