Skip to content

Instantly share code, notes, and snippets.

@precary
precary / ConsoleOutputLog.cs
Created June 21, 2019 19:30 — forked from mikey-t/ConsoleOutputLog.cs
Simple C# utility class to output to both console and a log file at the same time. Use it by simply calling Output.Write() and Output.WriteLine().
public class Output
{
private readonly string LogDirPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "logs");
private static Output _outputSingleton;
private static Output OutputSingleton
{
get
{
if (_outputSingleton == null)
@precary
precary / gist:362e5821767151d2c69ee1f2e1e0726c
Created September 21, 2017 22:11 — forked from niczak/gist:5470218
Check file extension w/ JavaScript
function checkFile(file) {
var extension = file.substr((file.lastIndexOf('.') +1));
if (!/(pdf|zip|doc)$/ig.test(extension)) {
alert("Invalid file type: "+extension+". Please use DOC, PDF or Zip.");
$("#file").val("");
}
}
@precary
precary / cmsContentType_Usage.sql
Created August 16, 2016 12:15 — forked from leekelleher/cmsContentType_Usage.sql
Umbraco - database analysis
-- Copied from Hendy https://our.umbraco.org/forum/umbraco-7/using-umbraco-7/72814-creating-a-list-of-unused-doc-types#comment-233729
-- Find all unused docTypes
-- These results may contain docTypes that are masters of used ones, so need to exclude these too...
SELECT
A.nodeId as 'DocTypeId',
B.text AS 'Name',
A.alias AS 'Alias'
FROM
cmsContentType A LEFT JOIN
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");