Skip to content

Instantly share code, notes, and snippets.

@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@mattbrailsford
mattbrailsford / Bootstrap.cs
Created August 7, 2014 12:50
Indexing JSON values in Umbraco
public class Bootstrapper : ApplicationEventHandler
{
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
base.ApplicationStarted(umbracoApplication, applicationContext);
ExamineManager.Instance.IndexProviderCollection["ExternalIndexer"]
.GatheringNodeData += (sender, e) =>
{
// Extract JSON properties
@Jeavon
Jeavon / AppIcons.cshtml
Last active November 8, 2016 12:31
AppIcons - Partial View for Umbraco
@using Umbraco.Web.Models
@inherits UmbracoViewPage<IPublishedContent>
@{
var internalMediaFolder = Umbraco.TypedMediaAtRoot().FirstOrDefault(x => x.DocumentTypeAlias == "InternalMediaFolder");
if (internalMediaFolder != null)
{
var appleTouchIcon = internalMediaFolder.Descendants().FirstOrDefault(x => x.DocumentTypeAlias == "AppleTouchIcon");
@pburtchaell
pburtchaell / styles.css
Last active February 12, 2025 08:45
VH and VW units can cause issues on iOS devices. To overcome this, create media queries that target the width, height, and orientation of iOS devices.
/**
* VH and VW units can cause issues on iOS devices: http://caniuse.com/#feat=viewport-units
*
* To overcome this, create media queries that target the width, height, and orientation of iOS devices.
* It isn't optimal, but there is really no other way to solve the problem. In this example, I am fixing
* the height of element `.foo` —which is a full width and height cover image.
*
* iOS Resolution Quick Reference: http://www.iosres.com/
*/
@leekelleher
leekelleher / umbraco.io.user.js
Last active March 19, 2018 15:10
Umbraco Cloud UserScript - to assist with common tasks
// ==UserScript==
// @name Umbraco Cloud - UI Fixes
// @namespace http://leekelleher.com/
// @version 0.6.1
// @description Hacking around on umbraco.io
// @author Lee Kelleher
// @match https://www.umbraco.io/project/*
// @match https://www.s1.umbraco.io/project/*
// @grant none
// ==/UserScript==
@kipusoep
kipusoep / gist:9fa2dc1160d21afaabc4
Created December 16, 2014 13:37
ImageProcessor auto-resize
MediaFileSystem mediaFileSystem = FileSystemProviderManager.Current.GetFileSystemProvider<MediaFileSystem>();
IContentSection contentSection = UmbracoConfig.For.UmbracoSettings().Content;
IEnumerable<string> supportedTypes = contentSection.ImageFileTypes.ToList();
foreach (IMedia media in e.SavedEntities)
{
if (media.HasProperty("umbracoFile"))
{
// Make sure it's an image.
string path = media.GetValue<string>("umbracoFile");
$('input[type=submit]').not('.cancel').click(function (evt) {
evt.preventDefault();
var self = $(this);
var frm = self.closest('form');
frm.validate();
if (frm.valid()) {
$.ajax({
cache: false,
async: true,
@joeriks
joeriks / structure_and_content_creation_script.cshtml
Created March 27, 2015 10:59
Poor mans "Code First" implementation for Umbraco - or rather a sample of a Structure and Content creation script
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@{
Layout = null;
}
@functions{
/*
* Poor mans "Code First" implementation for Umbraco
@jhauge
jhauge / MediaApi.cs
Last active December 23, 2015 22:31
private readonly IMediaService _mediaSvc = ApplicationContext.Current.Services.MediaService;
// Updating profile pic
internal void UpdateProfilePic(int profileId, string picPath)
{
if (profileId == 0) throw new ArgumentException("Error updating profile, no profile id in request");
var contentItem = _contentSvc.GetById(profileId);
// Set mediaitem
var mediaFilename = contentItem.Name + Path.GetExtension(picPath);
using System;
using System.IO;
using System.Net;
using System.Threading.Tasks;
using System.Web;
using System.Web.Hosting;
using ImageProcessor.Web.Services;
namespace UmbrellaInc.Web.Services
{