Skip to content

Instantly share code, notes, and snippets.

View timgaunt's full-sized avatar

Tim Gaunt timgaunt

View GitHub Profile
@timgaunt
timgaunt / gist:3999908
Created November 2, 2012 10:07
Umbraco - Sort By SortOrder
<xsl:sort data-type="number" case-order="lower-first" select="@sortOrder" order="ascending" />
@timgaunt
timgaunt / gist:3999911
Created November 2, 2012 10:08
Umbraco - Check if date is in the future
umbraco.library:DateGreaterThanOrEqualToday( data [@alias='ClassDate']]
@timgaunt
timgaunt / gist:4003439
Last active October 12, 2015 09:07
List missing indexes since the last restart (SQL Server 2005+)
/* ------------------------------------------------------------------
-- Title: FindMissingIndexes
-- Author: Brent Ozar
-- Date: 2009-04-01
-- Modified By: Clayton Kramer <ckramer.kramer @="" gmail.com="">
-- Description: This query returns indexes that SQL Server 2005
-- (and higher) thinks are missing since the last restart. The
-- "Impact" column is relative to the time of last restart and how
-- bad SQL Server needs the index. 10 million+ is high.
-- Changes: Updated to expose full table name. This makes it easier
@timgaunt
timgaunt / gist:4191239
Last active October 13, 2015 11:47
Get size of tables in SQL Azure
select sum(reserved_page_count) * 8.0 / 1024
from sys.dm_db_partition_stats
GO
SELECT sys.objects.name, sum(reserved_page_count) * 8.0 / 1024
from sys.dm_db_partition_stats, sys.objects
where sys.dm_db_partition_stats.object_id = sys.objects.object_id
group by sys.objects.name
ORDER BY sum(reserved_page_count) DESC
@timgaunt
timgaunt / gist:5199809
Last active December 15, 2015 04:09
Like on Facebook or Tweet on Twitter with plain text link
http://www.facebook.com/sharer.php?s=100&p[title]=YOUR_TITLE&p[summary]=YOUR_SUMMARY&p[url]=YOUR_URL&p[images][0]=YOUR_IMAGE_TO_SHARE_OBJECT
http://twitter.com/share?url=http://yourdomain.com&text=This+is+where+your+tweets+goes…&hashtags=hash,tags,here
http://pinterest.com/pin/create/bookmarklet/?media=http%3A%2F%2Fyourdomain.com%2Fsomeimage.jpg&url=http%3A%2F%2Fyourdomain.com&title=Your%20Title&is_video=false&description=Some%20Description
@timgaunt
timgaunt / gist:5235354
Created March 25, 2013 06:54
The easiest checkbox select all ever (jQuery) Original: http://briancray.com/posts/check-all-jquery-javascript
$(function () {
$('.checkall').on('click', function () {
$(this).closest('fieldset').find(':checkbox').prop('checked', this.checked);
});
});
@timgaunt
timgaunt / FilesService.cs
Created April 5, 2013 13:09
Quick extract of the code we use to upload files using jQuery and ServiceStack on our MVC solutions but in theory this would work on older ASP.Net implementations as well. You'll need ServiceStack.Mvc - http://nuget.org/packages/ServiceStack.Mvc/ (or the starter kit if you want pointers on getting started: http://nuget.org/packages/ServiceStack.…
using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using BeVancouver.Web.Helpers;
using ServiceStack.ServiceHost;
using ServiceStack.ServiceInterface;
using ServiceStack.ServiceInterface.ServiceModel;
@timgaunt
timgaunt / gist:5542813
Created May 8, 2013 19:09
List Umbraco DataTypes
SELECT
dt.controlId,
n.UniqueId,
n.text,
dt.dbType
FROM dbo.umbracoNode n
LEFT JOIN dbo.cmsDataType dt
ON n.id = dt.nodeId
WHERE dt.nodeId IS NOT NULL
ORDER BY n.text
@timgaunt
timgaunt / gist:5787287
Created June 15, 2013 07:40
Size of all tables in SQL Server
SELECT
t.NAME AS TableName,
p.rows AS RowCounts,
(SUM(a.total_pages) * 8) / 1024 AS TotalSpaceMB,
(SUM(a.used_pages) * 8) / 1024 AS UsedSpaceMB,
((SUM(a.total_pages) - SUM(a.used_pages)) * 8) / 1024 AS UnusedSpaceKB
FROM
sys.tables t
INNER JOIN
sys.indexes i ON t.OBJECT_ID = i.object_id
@timgaunt
timgaunt / gist:8862724
Last active July 23, 2017 03:51
Call a url from PowerShell -useful for scheduling tasks in Windows
-ExecutionPolicy unrestricted -Command "(New-Object Net.WebClient).DownloadString(\"http://...aspx\")"
-ExecutionPolicy unrestricted -Command "(New-Object Net.WebClient).DownloadString($d=Get-Date;$t='{0:yyyyMMddTHHmmssZ}' -f $d.AddMinutes(-2);$f='{0:yyyyMMddTHHmmssZ}' -f $d.AddMinutes(-8);$url=\"http://...aspx?from=\" + $f + \"&to=\" + $t;write-host $url)"