Skip to content

Instantly share code, notes, and snippets.

USE master
GO
EXEC sp_configure 'show advanced options', 1
GO
RECONFIGURE
GO
EXEC sp_configure 'xp_cmdshell', 1
GO
RECONFIGURE
GO
@hoangitk
hoangitk / HlslAntlrLexer.g4
Created October 8, 2015 17:09 — forked from tgjones/HlslAntlrLexer.g4
ANTLR4 grammar for HLSL
lexer grammar HlslAntlrLexer;
@lexer::header {#pragma warning disable 3021}
AppendStructuredBuffer : 'AppendStructuredBuffer';
Bool : 'bool';
Bool1 : 'bool1';
Bool2 : 'bool2';
Bool3 : 'bool3';
Bool4 : 'bool4';
public static class HtmlHelperExtensions
{
private static readonly char Separator = '/';
private static readonly string TemplateFolder = HttpContext.Current.Server.MapPath("~/App/templates");
private static readonly IViewEngine ViewEngine = new HandlebarsRazorViewEngine();
public static MvcHtmlString RenderEmber(this HtmlHelper helper, string path = "", bool noTemplateName = false)
{
if (HttpRuntime.Cache[path] == null)
{
public static HtmlTag InputBlock<T>(this HtmlHelper<T> helper,
Expression<Func<T, object>> expression,
Action<HtmlTag> inputModifier = null,
Action<HtmlTag> validatorModifier = null) where T : class
{
inputModifier = inputModifier ?? (_ => { });
validatorModifier = validatorModifier ?? (_ => { });
var divTag = new HtmlTag("div");
divTag.AddClass("col-md-10");
public static HtmlTag FormBlock<T>(this HtmlHelper<T> helper,
Expression<Func<T, object>> expression,
Action<HtmlTag> labelModifier = null,
Action<HtmlTag> inputBlockModifier = null,
Action<HtmlTag> inputModifier = null,
Action<HtmlTag> validatorModifier = null
) where T : class
{
labelModifier = labelModifier ?? (_ => { });
inputBlockModifier = inputBlockModifier ?? (_ => { });
@hoangitk
hoangitk / OptimizationExtensions.cs
Created April 22, 2016 04:18 — forked from MrScruffy04/OptimizationExtensions.cs
Allows one to minify JS and CSS within a Razor View. See usage at the bottom of the source.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Optimization;
using Microsoft.Ajax.Utilities;
namespace System.Web.Mvc
{
public static class OptimizationExtensions
@hoangitk
hoangitk / SlackClient.cs
Created May 18, 2016 05:23 — forked from jogleasonjr/SlackClient.cs
A simple C# class to post messages to a Slack channel. You must have the Incoming WebHooks Integration enabled. This class uses the Newtonsoft Json.NET serializer available via NuGet. Scroll down for an example test method and a LinqPad snippet. Enjoy!
using Newtonsoft.Json;
using System;
using System.Collections.Specialized;
using System.Net;
using System.Text;
//A simple C# class to post messages to a Slack channel
//Note: This class uses the Newtonsoft Json.NET serializer available via NuGet
public class SlackClient
{
using System;
using System.Linq;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
public class Program
{
public static void Main(string[] args)
{
var services = new ServiceCollection();
@hoangitk
hoangitk / jquery.validate.unobtrusive.dynamic.js
Created October 6, 2016 09:32 — forked from joelpurra/jquery.validate.unobtrusive.dynamic.js
$.validator.unobtrusive.parseDynamicContent by XHalent, modified to keep a reference to the jQuery selector/context object
/// <reference path="../jquery-1.7.js" />
/// <reference path="../jquery.validate.js" />
/// <reference path="../jquery.validate.unobtrusive.js" />
// Originally by XHalent, @xhalent
// http://xhalent.wordpress.com/
// http://xhalent.wordpress.com/2011/01/24/applying-unobtrusive-validation-to-dynamic-content/
// Modified by Joel Purra
// http://joelpurra.com/
@hoangitk
hoangitk / SelfCompile.cs
Last active October 12, 2016 08:55 — forked from plaurin/SelfCompile
Self Compiling LinqPad query
/*
System.CodeDom.Compiler
System.Runtime.InteropServices
Microsoft.CSharp
*/
void Main()
{
Environment.CurrentDirectory = Path.GetDirectoryName(Util.CurrentQueryPath);
Compiler.CompileFiles(Options.CreateOnDiskDll(