Skip to content

Instantly share code, notes, and snippets.

View marcusgadbem's full-sized avatar

Marcus Gadbem marcusgadbem

View GitHub Profile
@marcusgadbem
marcusgadbem / index.js
Last active November 25, 2021 22:20
Middleware to minify HTML output for express template render engines in which supports callbacks
/* app/controllers/index.js */
module.exports.index = function(req, res) {
res.render('index.html');
};
@marcusgadbem
marcusgadbem / test.js
Created February 23, 2014 07:08 — forked from jmyrland/test.js
Socket.io testing example with Should
/**
* Modify the parts you need to get it working.
*/
var should = require('should');
var request = require('../node_modules/request');
var io = require('socket.io-client');
var serverUrl = 'http://localhost';
@marcusgadbem
marcusgadbem / domcache.js
Created October 21, 2013 18:34
jQuery/Zepto DOM Caching
$C = (function($) {
var DOMCACHESTORE = {};
return function(selector, force) {
if (DOMCACHESTORE[selector] === undefined || force)
DOMCACHESTORE[selector] = $(selector);
return DOMCACHESTORE[selector];
}
})($);
@marcusgadbem
marcusgadbem / ios-orientation-fix.js
Created October 1, 2013 21:38
A fix for the iOS orientationchange zoom bug.
/*! A fix for the iOS orientationchange zoom bug.
Script by @scottjehl, rebound by @wilto.
MIT / GPLv2 License.
*/
(function(w){
// This fix addresses an iOS bug, so return early if the UA claims it's something else.
var ua = navigator.userAgent;
if( !( /iPhone|iPad|iPod/.test( navigator.platform ) && /OS [1-5]_[0-9_]* like Mac OS X/i.test(ua) && ua.indexOf( "AppleWebKit" ) > -1 ) ){
return;
@marcusgadbem
marcusgadbem / social_counter.js
Created March 7, 2013 03:16
Social medias likes-count getter
function getFacebookCounts(url, commentElement, likesElement) {
var facebookUrl = "https://api.facebook.com/method/fql.query?format=json&query=select%20total_count,like_count,comment_count,share_count,click_count%20from%20link_stat%20where%20url='" + url + "'";
$.getJSON(facebookUrl, function (data) {
$(commentElement).text(data[0].comment_count);
$(likesElement).text(data[0].total_count);
});
}
function getTwitterCount(url, countElement) {
var twitterUrl = 'http://cdn.api.twitter.com/1/urls/count.json?url=' + url + '&callback=?';