Skip to content

Instantly share code, notes, and snippets.

@bchumney
bchumney / gist:7d5f9fd90b18e998591fa31a4c100277
Created March 31, 2023 17:47
Excel function to update sourced url entry
=CONCATENATE("UPDATE edf_url_sourcing SET url = replace(url, '", A2, "', '", B2, "'), resource = replace(resource, '", A2, "', '", B2, "') where id = ", C2, ";")
@bchumney
bchumney / get_custom_dimension.js
Created December 2, 2014 21:26
Get custom dimension
ga(function(tracker) {
console.log(tracker.b.data.w[':dimension5']);
});
@bchumney
bchumney / element_style_values.js
Created December 2, 2014 18:11
Element Style Values with Plain JS
function getStyle(oElm, strCssRule){
var strValue = '';
if (document.defaultView && document.defaultView.getComputedStyle) strValue = document.defaultView.getComputedStyle(oElm, '').getPropertyValue(strCssRule);
else if (oElm.currentStyle){
strCssRule = strCssRule.replace(/\-(\w)/g, function (strMatch, p1){ return p1.toUpperCase(); });
strValue = oElm.currentStyle[strCssRule];
}
return strValue;
}
@bchumney
bchumney / nodejs_and_server.snippets
Last active August 29, 2015 14:06
NodeJS and Server Env
#To make Apache and NodeJS hold hands, add the following to httpd.conf
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
ProxyPass /node http://localhost:3000/
#or whatever your designated node port is
#CentOS server setup and common commands
@bchumney
bchumney / screen_coords.js
Created July 1, 2014 19:09
Get absolute screen coordinates
function GetScreenCordinates(obj) {
var p = {};
p.x = obj.offsetLeft;
p.y = obj.offsetTop;
while (obj.offsetParent) {
p.x = p.x + obj.offsetParent.offsetLeft;
p.y = p.y + obj.offsetParent.offsetTop;
if (obj == document.getElementsByTagName("body")[0]) {
break;
}
@bchumney
bchumney / convio-sticky-columns.js
Created October 31, 2013 17:33
Sticky Columns in Convio Pages
$jq('.sticky').each(function(){
var sticky = $jq(this);
$jq(window).scroll(function(){
if ($jq(window).width() > 600) {
var t = $jq(sticky).parent().offset().top-20;
var b = $jq('#content').offset().top + $jq('#content').height();
var w = $jq(sticky).width();
var h = $jq(sticky).height();
if ($jq(window).scrollTop() < t) $jq(sticky).css({'width':'auto','position':'static'});
else if ($jq(window).scrollTop() >= t && $jq(window).scrollTop() < b-h) $jq(sticky).css({'width':w,'position':'fixed','top':'20px','bottom':'inherit'});
@bchumney
bchumney / blog-sticky-sidebar.js
Created October 31, 2013 17:32
Sticky Sidebar for Blog Section
$(document).ready(function(){
var t, b, w, h;
if ($('#sideColumn').length > 0) {
var sticky = $('#sideColumn').children('.sidebar');
$(window).scroll(function(){
t = $('#sideColumn').offset().top-20;
b = $('#contentArea').offset().top + $('#contentArea').height();
w = $('#sideColumn').width();
h = $(sticky).height();
if ($(window).scrollTop() < t) $(sticky).css({'width':'auto','position':'static'});
@bchumney
bchumney / pagenavigator-to-pageserver.html
Created October 28, 2013 15:12
Convio PageNavigator to PageServer Redirect
[[?[[S8]]::http://support.edf.org/site/PageNavigator/BP_Timeline_Video.html::
<script type="text/javascript">
var search = '',
GA = false;
if (typeof location.search !== 'undefined' && location.search != null && location.search != '') search = location.search.replace('?','&');
window.location.href = 'http://support.edf.org/site/PageServer?pagename=BP_Timeline_Video'+search+location.hash;
</script>
::]]
@bchumney
bchumney / placeholder-test.js
Created October 27, 2013 03:06
Testing for Placeholder Functionality
if ( !!( 'placeholder' in document.createElement('input') ) ) {
//placeholder supported
}
@bchumney
bchumney / javascript-load-tracking-time.js
Created October 23, 2013 14:42
JavaScript Resource Load Tracking Time
var nexacStartTime;
loadJs('https://e.nexac.com/e/a-1319/s-2915.js', myCallback);
function loadJs(url, callback) {
TE('Nexac', 'Requested', (typeof referrer !== 'undefined' ? referrer : 'not defined'));
var js = document.createElement('script');
js.async = true;
js.src = url;
var s = document.getElementsByTagName('script')[0];
js.onload = callback;