This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// blows up if url contains a query string | |
//string absoluteToUrl = Path.GetFullPath(Path.Combine(cssFilePath, relativeToCSS)); | |
// replace with | |
// this is a path that is relative to the CSS file | |
string relativeToCSS = match.Groups[2].Value; | |
//prevent querystring from causing error | |
var pathAndQuery = relativeToCSS.Split(new[] { '?' }, 2, StringSplitOptions.RemoveEmptyEntries); | |
var pathOnly = pathAndQuery[0]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class StyleRelativePathTransform : IBundleTransform | |
{ | |
private const string UrlPattern = @"url\s*\(\s*([""']?)([^:)]+)\1\s*\)"; | |
private static readonly Regex UrlRegex = new Regex(UrlPattern, RegexOptions.IgnoreCase | RegexOptions.Compiled); | |
public void Process(BundleContext context, BundleResponse response) | |
{ | |
var mergedCss = new StringBuilder(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//replace this method | |
commandProto.doHeading = function (chunk, postProcessing) { | |
// Remove leading/trailing whitespace and reduce internal spaces to single spaces. | |
chunk.selection = chunk.selection.replace(/\s+/g, " "); | |
chunk.selection = chunk.selection.replace(/(^\s+|\s+$)/g, ""); | |
// If we clicked the button with no selected text, we just | |
// make a level 2 hash header around some default text. | |
if (!chunk.selection) { | |
chunk.startTag = "#### "; /* rewrite to start at H4 instead */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Runnable from Linqpad 5 | |
// Must install the Sigil nuget package and include the Sigil namespace | |
void Main() | |
{ | |
var createSample = GetMapperDelegate(); | |
// try it out | |
createSample(23, "Hello").Dump(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[alias] | |
co = checkout | |
ci = commit | |
branches = branch | |
syncdev = "!git fetch origin; git merge origin/development" | |
up-c = checkout -f |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(d) { | |
d.Observe = {} | |
})(jQuery); | |
(function(d, q) { | |
var r = function(e, f) { | |
f || (f = e, e = window.document); | |
var m = []; | |
d(f).each(function() { | |
for (var l = [], g = d(this), h = g.parent(); h.length && !g.is(e); h = h.parent()) { | |
var f = g.get(0).tagName.toLowerCase(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct OrdinalIgnoreCaseString : IEquatable<OrdinalIgnoreCaseString>, IEquatable<string> { | |
string _str; | |
public OrdinalIgnoreCaseString(string str) { | |
_str = str; | |
} | |
public static implicit operator OrdinalIgnoreCaseString(string str) { | |
return new OrdinalIgnoreCaseString(str); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Base58 is case SENSITIVE alphanumeric ELIMINATING: 0 (zero) I (uppercase), O (upppercase), l (lowercase) | |
/// This reduction of characters eliminates the majority of human typoposition errors | |
/// </summary> | |
public class Base58 | |
{ | |
private static readonly BaseN base58 = new BaseN("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"); //base58 | |
public static string Encode(long @long) => base58.Encode(@long); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// This action filter ensures ModelState.IsValid is true as a precondition to entry into the MVC action | |
/// </summary> | |
/// <remarks> | |
/// This class also validates all action parameters unlike the default behavior of ModelState.IsValid | |
/// </remarks> | |
/// <see cref="https://blog.markvincze.com/how-to-validate-action-parameters-with-dataannotation-attributes/" /> | |
public class EnsureModelStateIsValid : ActionFilterAttribute | |
{ | |
private static readonly ConcurrentDictionary<MethodInfo, ParameterInfo[]> MethodCache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |