Skip to content

Instantly share code, notes, and snippets.

View marcusgadbem's full-sized avatar

Marcus Gadbem marcusgadbem

View GitHub Profile
@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=?';
@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 / 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 / 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 / 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 / javascript_resources.md
Created July 6, 2014 20:13 — forked from jookyboi/javascript_resources.md
Here are a set of libraries, plugins and guides which may be useful to your Javascript coding.

Libraries

  • jQuery - The de-facto library for the modern age. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers.
  • Backbone - Backbone.js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing API over a RESTful JSON interface.
  • AngularJS - Conventions based MVC framework for HTML5 apps.
  • Underscore - Underscore is a utility-belt library for JavaScript that provides a lot of the functional programming support that you would expect in Prototype.js (or Ruby), but without extending any of the built-in JavaScript objects.
  • lawnchair - Key/value store adapter for indexdb, localStorage
@marcusgadbem
marcusgadbem / rails_resources.md
Created July 6, 2014 20:13 — forked from jookyboi/rails_resources.md
Rails-related Gems and guides to accelerate your web project.

Gems

  • Bundler - Bundler maintains a consistent environment for ruby applications. It tracks an application's code and the rubygems it needs to run, so that an application will always have the exact gems (and versions) that it needs to run.
  • rabl - General ruby templating with json, bson, xml, plist and msgpack support
  • Thin - Very fast and lightweight Ruby web server
  • Unicorn - Unicorn is an HTTP server for Rack applications designed to only serve fast clients on low-latency, high-bandwidth connections and take advantage of features in Unix/Unix-like kernels.
  • SimpleCov - SimpleCov is a code coverage analysis tool for Ruby 1.9.
  • Zeus - Zeus preloads your Rails app so that your normal development tasks such as console, server, generate, and specs/tests take less than one second.
  • [factory_girl](h
@marcusgadbem
marcusgadbem / Gruntfile.js
Created August 14, 2014 22:31
grunt-concurrent with nodemon and watch
/* globals module */
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
watch: {
gruntfile: {
@marcusgadbem
marcusgadbem / development.rb
Created October 11, 2014 20:50
unicorn in development
# config/environments/development.rb
MyApp::Application.configure do
# Tell Rails to log to STDOUT instead Rails::Rack::LogTailer
config.logger = Logger.new(STDOUT)
config.logger.level = Logger.const_get(
ENV['LOG_LEVEL'] ? ENV['LOG_LEVEL'].upcase : 'DEBUG'
)
end