Skip to content

Instantly share code, notes, and snippets.

View ryanlewis's full-sized avatar

Ryan Lewis ryanlewis

  • Leeds, United Kingdom
  • 22:18 (UTC +01:00)
View GitHub Profile
@ryanlewis
ryanlewis / gist:6112001
Last active December 20, 2015 09:59
Get difference between two commits. Powershell snippet to filter out a list of changed files by extension from git diff --stat
git diff 1.0.2 HEAD --stat=200
git diff 1.0.2 HEAD --stat=500 | where {$_ -Match ".cshtml|.css"} | %{$line=$_.split(" "); write-host $line[1] }
git diff 1.0.2 HEAD --stat=200 | where {$_ -Match ".cshtml|.cs"} | %{$l=$_.split(" "); $file=$l[1]; $file=$file.replace("Umbraco.Site", ""); write-host $file }
@ryanlewis
ryanlewis / Program.cs
Created July 29, 2013 23:00
LinqToTwitter example to fetch tweet data for a particular tweet
using System;
using System.Linq;
using System.Text.RegularExpressions;
using LinqToTwitter;
namespace TweetTest
{
internal class Program
{
private static readonly Regex TweetStatusRegex = new Regex(@"^https?:\/\/twitter\.com\/(?:#!\/)?(\w+)\/status(es)?\/(\d+)$");
JSON.stringify = JSON.stringify || function (obj) {
var t = typeof (obj);
if (t != "object" || obj === null) {
// simple data type
if (t == "string") obj = '"'+obj+'"';
return String(obj);
}
else {
// recurse array or object
var n, v, json = [], arr = (obj && obj.constructor == Array);
@ryanlewis
ryanlewis / ConfigureLuceneIndexing.cs
Created August 18, 2015 18:48
Hooking into the Lucene events with Umbraco
using System.Web.UI;
using Examine;
using Examine.LuceneEngine;
using Examine.LuceneEngine.Providers;
using Umbraco.Core;
using Umbraco.Web;
namespace AMAZINGWEBSITE.Web.Core.ApplicationEventHandlers
{
public class ConfigureLuceneIndexing : IApplicationEventHandler
@ryanlewis
ryanlewis / sublime.reg
Created March 12, 2015 09:58
Add "Open folder as Sublime project" to Explorer right-click menu
Windows Registry Editor Version 5.00
; This will make it appear when you right click ON a folder
; The "Icon" line can be removed if you don't want the icon to appear
[HKEY_CLASSES_ROOT\Directory\shell\sublime]
@="Open Folder as &Sublime Project"
"Icon"="\"C:\\Program Files\\Sublime Text 3\\sublime_text.exe\",0"
[HKEY_CLASSES_ROOT\Directory\shell\sublime\command]
@ryanlewis
ryanlewis / RedirectToParent.cshtml
Created November 4, 2014 13:59
Redirect to Parent page template
@inherits UmbracoTemplatePage
@{
var parent = Model.Content.Parent;
while (true)
{
if (parent.TemplateId > 0 && parent.TemplateId != Model.Content.TemplateId)
{
break;
}
parent = parent.Parent;
@ryanlewis
ryanlewis / your.csproj
Created July 25, 2014 15:15
How we add all assets in our Web projects
<Project>
<Target Name="BeforeBuild">
<Exec WorkingDirectory="..\.." Command="powershell.exe .\grunt-build.ps1 -target $(Configuration)" />
<ItemGroup>
<Content Include="css\**\*.css" />
<Content Include="js\**\*.js" />
<Content Include="js\**\*.js.map" />
<Content Include="fonts\**\*.*" />
<Content Include="img\**\*.png" />
<Content Include="img\**\*.gif" />
@ryanlewis
ryanlewis / StringArrayValueConverter.cs
Last active August 29, 2015 14:04
Property Value Converter for a array of strings
using System;
using Newtonsoft.Json;
using Umbraco.Core.Models.PublishedContent;
using Umbraco.Core.PropertyEditors;
namespace Epiphany.PropertyEditorValueConverters
{
[PropertyValueType(typeof(string[]))]
[PropertyValueCache(PropertyCacheValue.All, PropertyCacheLevel.Content)]
public class StringArrayValueConverter : PropertyValueConverterBase
@ryanlewis
ryanlewis / package.manifest
Created July 15, 2014 12:21
Label datatype stored as "TEXT"
{
propertyEditors: [
{
alias: "Epiphany.NoEditBig",
name: "Label (Big)",
editor: {
view: "~/umbraco/views/propertyeditors/readonlyvalue/readonlyvalue.html",
valueType: 'TEXT',
}
}
@ryanlewis
ryanlewis / CleanASPNETCrap.ps1
Created April 28, 2014 09:17
Clean out your ASP.NET Temporary files
If (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator"))
{
$arguments = "& '" + $myinvocation.mycommand.definition + "'"
Start-Process powershell -Verb runAs -ArgumentList $arguments
Break
}
Get-ChildItem "C:\Windows\Microsoft.NET\Framework*\v*\Temporary ASP.NET Files" -Recurse | Remove-Item -Recurse