Skip to content

Instantly share code, notes, and snippets.

View emmanueltissera's full-sized avatar

Emm emmanueltissera

View GitHub Profile
// HelloGist.cs
using System;
public class HelloGist
{
public static void Main()
{
Console.WriteLine("Hello, Gist!");
}
}
@emmanueltissera
emmanueltissera / Enable Override for Umbraco site
Created June 29, 2013 18:14
IIS configurations in ApplicationHost file to change overrideModeDefault
<!--Original setting-->
<section name="handlers" overrideModeDefault="Deny" />
<section name="modules" allowDefinition="MachineToApplication" overrideModeDefault="Deny" />
<!--Modified setting-->
<section name="handlers" overrideModeDefault="Allow" />
<section name="modules" allowDefinition="MachineToApplication" overrideModeDefault="Allow" />
@emmanueltissera
emmanueltissera / Default document in web.config
Created June 30, 2013 14:51
Default document configuration in an ASP.NET website
<system.webServer>
<defaultDocument>
<files>
<add value="default.aspx" />
</files>
</defaultDocument>
</system.webServer>
@emmanueltissera
emmanueltissera / Transact SQL for SQL 2005
Created July 1, 2013 14:54
Transact SQL for SQL 2005 to work with a integer array like structure
CREATE PROCEDURE getNodes
@isActive bit
AS
BEGIN
-- Declare a single column table to be used as a single dimension array
DECLARE @activeNodes TABLE (id int)
-- Only if the following condition is satisfied, 1070 will be added to the pseudo-array
IF @isActive = 1
INSERT INTO @activeNodes(id) VALUES (1070)
@emmanueltissera
emmanueltissera / Transact SQL for SQL 2008 and above
Created July 1, 2013 14:56
Transact SQL for SQL 2008 and above to work with a integer array like structure
ALTER PROCEDURE getNodes
@isActive bit
AS
BEGIN
-- Declare a single column table to be used as a single dimension array
DECLARE @activeNodes TABLE (id int)
-- Only if the following condition is satisfied, 1070 will be added to the pseudo-array
IF @isActive = 1
INSERT INTO @activeNodes(id) VALUES (1070)
@emmanueltissera
emmanueltissera / restore-database.sql
Last active April 19, 2016 10:28
Generic T-SQL for restoring a database from a backup
-- INSTRUCTIONS:
-- 1. Replace custom_database with the actual database name (Use a replace all on custom_database)
-- 2. Change @BackUpFileName to the actual location
-- 3. Change parameters for @DbUser & @LoginPassword
-- ============================
-- Restore [custom_database]
-- ============================
DECLARE @BackUpFileName varchar(100), @DbUser varchar(100), @LoginPassword varchar(100);
@emmanueltissera
emmanueltissera / GTM.cshtml
Last active December 4, 2015 10:56
Excluding internal traffic in Google Tag Manager (adding a dataLayer variable)
<!-- Google Tag Manager -->
<noscript><iframe src="//www.googletagmanager.com/ns.html?id=GTM-XXXXXX"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<script>dataLayer = [{'trackThisPage': '@HelperFunctions.TrackThisPage()'}];
(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-XXXXXX');</script>
<!-- End Google Tag Manager -->
@emmanueltissera
emmanueltissera / HelperFunctions.cshtml
Created December 4, 2015 10:56
Excluding internal traffic in Google Tag Manager (HelperFunction to check exclusion)
@functions {
public static string TrackThisPage()
{
if (Request.QueryString["ignoreGTM"] != null && Request.QueryString["ignoreGTM"] == "false")
{
return "true";
}
else if ((Request.Cookies["ignorePageViews"] != null && Request.Cookies["ignorePageViews"].Value == "true") ||
(Request.QueryString["ignoreGTM"] != null && Request.QueryString["ignoreGTM"] == "true") ||
Request.Path.EndsWith("ignore", StringComparison.InvariantCultureIgnoreCase) ||
@emmanueltissera
emmanueltissera / IgnorePageViews.cshtml
Created December 4, 2015 10:56
Excluding internal traffic in Google Tag Manager (setting a cookie)
@{
Response.Cookies["ignorePageViews"].Value = "true";
Response.Cookies["ignorePageViews"].Expires = DateTime.Now.AddYears(10);
<i>Cookie set to ignore page views.</i>
}
@emmanueltissera
emmanueltissera / PageTracked.html
Created December 4, 2015 10:57
Excluding internal traffic in Google Tag Manager (resulting html when page is NOT excluded from tracking)
<!-- Google Tag Manager -->
<noscript><iframe src="//www.googletagmanager.com/ns.html?id=GTM-XXXXXX"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<script>dataLayer = [{'trackThisPage': 'true'}];
(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-XXXXXX');</script>
<!-- End Google Tag Manager -->