This file contains hidden or 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
Find: (?<!\r)\n | |
Replace: \r\n | |
Using regular expressions |
This file contains hidden or 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 measureSvgText(text, className) { | |
if (!text || text.length === 0) { | |
return { width: 0, height: 0 }; | |
} | |
var svg = d3.select('body').append('svg'); | |
if (className) { | |
svg.attr('class', className); | |
} |
This file contains hidden or 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
var measureHtmlText = function (text, className) { | |
var ruler = $('<span>'); | |
ruler.addClass(className) | |
.css('display', 'none') | |
.css('white-space', 'nowrap') | |
.appendTo($('body')); | |
ruler.text(text); | |
var width = ruler.width(); | |
var height = ruler.height(); | |
ruler.remove(); |
This file contains hidden or 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
[diff] | |
tool = vsdiffmerge | |
[difftool] | |
prompt = false | |
[difftool "vsdiffmerge"] | |
cmd = "'C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/vsdiffmerge.exe' $LOCAL $REMOTE //t" | |
keepbackup = false | |
trustexitcode = true |
This file contains hidden or 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
// This opens a window and sets the opener to the current window, then closes it. | |
var win = window.open("", "_top", "", true); | |
win.opener = window; | |
win.close(); |
This file contains hidden or 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
// It may be worth making a copy of the element within <body> that is hidden | |
// or even producing a section of items to copy. | |
// This way you can remove any interactivity styles that make the copied content not | |
// look good when pasted into other applications. | |
var element = document.getElementById('ClipboardTemp'); | |
// This technique is simulating the user selecting these elements. | |
// Think of a ControlRange as a selection of controls and then executing the command like the user pressing 'Ctrl+C' | |
element.contentEditable = 'true'; | |
var controlRange; |
This file contains hidden or 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
protected void Application_BeginRequest() | |
{ | |
this.SetupCorsHeaders(); | |
//OPTIONS request comes before the POST to know the permissions. this forces to send the reply. | |
if (((IList)Request.Headers.AllKeys).Contains("Origin") && Request.HttpMethod == "OPTIONS") | |
{ | |
Response.Flush(); | |
} | |
} |
This file contains hidden or 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
private static object ApplyDefaultData(object data, object defaultData) | |
{ | |
if (defaultData != null) | |
{ | |
var target = new ExpandoObject(); | |
// I apply the default values | |
string defaultJson = JsonConvert.SerializeObject(defaultData, _jsonSerializerSettings); | |
JsonConvert.PopulateObject(defaultJson, target, _jsonSerializerSettings); | |
This file contains hidden or 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 scaleFontToFit(element) { | |
if (element) { | |
// for an element | |
var $element = $(element); | |
if ($element.css("overflow") == "hidden") { | |
var elementHeight = $element.height(); | |
var fontSize = parseInt($element.css("font-size"), 10); | |
var $fullElement = $(element).clone().css('overflow', 'visible').height('auto'); |
This file contains hidden or 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
// This attribute helps return exception text from web API methods when applied to a MVC Web API controller. | |
public class HandleWebApiErrorAttribute : ExceptionFilterAttribute | |
{ | |
public override void OnException(HttpActionExecutedContext context) | |
{ | |
var exception = context.Exception as Exception; | |
if (exception != null) | |
{ | |
var message = exception.Message; | |
message = message.Replace('\r', ' ').Replace('\n', ' '); |
NewerOlder