Skip to content

Instantly share code, notes, and snippets.

View GeoffCox's full-sized avatar
🏠
Working from home

Geoff Cox GeoffCox

🏠
Working from home
View GitHub Profile
@GeoffCox
GeoffCox / CloseWithoutPrompt.js
Created April 16, 2015 16:41
Close browser without prompting the user
// 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();
@GeoffCox
GeoffCox / git.config
Last active December 16, 2016 01:19
Update GIT.config to use Visual Studio for mergetool
[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
@GeoffCox
GeoffCox / measureHtmlText.js
Created August 25, 2015 17:22
Measure text in HTML
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();
@GeoffCox
GeoffCox / measureSvgText.js
Last active August 29, 2015 14:28
Measure text in SVG
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);
}
@GeoffCox
GeoffCox / LFtoCRLF.regex
Last active November 17, 2015 16:22
Regex to replace LFWithCRLF
Find: (?<!\r)\n
Replace: \r\n
Using regular expressions