Skip to content

Instantly share code, notes, and snippets.

Benjamin Charity benjamincharity

Block or report user

Report or block benjamincharity

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@benjamincharity
benjamincharity / Local Fallback for jQuery and Modernizr
Created Jan 6, 2012
Include jQuery and Modernizr from a CDN and add local fallbacks in case the CDN fails. Versions written in HTML and HAML.
View Local Fallback for jQuery and Modernizr
HTML
=====
<script type='text/javascript'>
window.jQuery || document.write('<script src="js/jquery-1.7.1.js">\x3C/script>')
</script>
<script src='http://cdnjs.cloudflare.com/ajax/libs/modernizr/2.0.6/modernizr.min.js' type='text/javascript'></script>
<script type='text/javascript'>
window.Modernizr || document.write('<script src="js/modernizr-2.0.6.js">\x3C/script>')
</script>
View dabblet.css
/**
* Clean Home Button
*/
body {
text-align: center;
}
a {
background: -webkit-gradient(linear, 50% 100%, 50% 0%, color-stop(0%, #ffffff), color-stop(100%, #e5e5e5)), -webkit-gradient(linear, 50% 100%, 50% 0%, color-stop(0%, #6d8a18), color-stop(100%, #6d8a18));
background: -webkit-linear-gradient(bottom, #ffffff, #e5e5e5), -webkit-linear-gradient(bottom, #6d8a18, #6d8a18);
View dabblet.css
/**
* Red Push Button
*/
html {
background: url(data:image/jpeg;base64,/9j/4QAYRXhpZgAASUkqAAgAAAAAAAAAAAAAAP/sABFEdWNreQABAAQAAABQAAD/7gAOQWRvYmUAZMAAAAAB/9sAhAACAgICAgICAgICAwICAgMEAwICAwQFBAQEBAQFBgUFBQUFBQYGBwcIBwcGCQkKCgkJDAwMDAwMDAwMDAwMDAwMAQMDAwUEBQkGBgkNCwkLDQ8ODg4ODw8MDAwMDA8PDAwMDAwMDwwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAz/wAARCACHAIcDAREAAhEBAxEB/8QAhgABAQEBAQEAAAAAAAAAAAAAAgMBAAQIAQEBAQAAAAAAAAAAAAAAAAAAAQQQAQACAQMCBQIDBwMEAwEAAAERAiExEgMAQVFhcSITgTLwkaGxwdFCcoIjUqKyYtLiM+HxkgQRAQACAQQDAQADAQEBAAAAAPAAAaERITFhQXGi4VGRArHBgf/aAAwDAQACEQMRAD8A+CK+3kKna1N1piFqmAx5foYz1tHd+KmYdV5uSGOJmdmyaGLWzbVqY0O/h/p6D64oxKtqW5Fvu2luXdbOYNwAkTGs/XsdB1W+tyDGlTkrupBteO1CGCtGpmXPjOf+WgdVtrcozpUjpWtxzbjxaYbbbEoZfLy7SzAfPIZlVi3KWaUF5DmaoQNWsAflj0MS9B3fipB1/NzN1bWpkTdw7RfuCsqrAzGmn9p0H1wGJm8aWb23TxzZ3Bu9+e2dJz6uIOj0/K31uBjSo2u69l1/yRx5Nvtzl7/jKx0HVba3KM6VOLbo98cZfiPdqxuMlZ7vZ9Mr0HzzBmCm5GzEfHF+avabwAefYPTGXoO78VA6rzcoOcG5bcsUUtZgwpBGn18qnQfXFGJkw1qKBbitaz/MxOqaZFx5+Anp+VvrcgxpUCW2K614WKg22xcYZ82fXOvQdVtrcozpUpYtYsk1
@benjamincharity
benjamincharity / jQuery testing and fallback
Created Jan 10, 2012
Load jQuery 1.7.1 from the CDN. If it loads put it into noConflict mode. If it doesn't, load the local copy. Keep checking until the local copy loads and put that into noConflict mode.
View jQuery testing and fallback
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min1.js"></script>
<script>
var $$;
// If 1.7.1 is loaded, put it into noConflict mode
if(window.jQuery().jquery = '1.7.1') {
$$ = $.noConflict(true);
} else {
// If it is not loaded, load the local version
document.write("<script src='/js/jquery-1.7.1.js'>\x3C/script>");
@benjamincharity
benjamincharity / Javascript to lock iOS zoom until touch
Created Jan 12, 2012
This locks the viewport zoom until the user touches to zoom.
View Javascript to lock iOS zoom until touch
// lock the zoom unless the user is manually zooming
var viewportmeta = document.querySelector('meta[name="viewport"]');
if (viewportmeta) {
viewportmeta.content = 'width=device-width, minimum-scale=1.0, maximum-scale=1.0, initial-scale=1.0';
document.body.addEventListener('gesturestart', function () {
viewportmeta.content = 'width=device-width, minimum-scale=0.25, maximum-scale=1.6';
}, false);
}
View dabblet.css
/**
* Green Upload Button
*/
a {
background: -webkit-gradient(linear, 50% 100%, 50% 0%, color-stop(0%, rgba(255, 255, 255, 0)), color-stop(100%, rgba(255, 255, 255, 0.4))), -webkit-gradient(linear, 50% 100%, 50% 0%, color-stop(0%, #6d8a18), color-stop(100%, #6d8a18));
background: -webkit-linear-gradient(bottom, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.4)), -webkit-linear-gradient(bottom, #6d8a18, #6d8a18);
background: -moz-linear-gradient(bottom, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.4)), -moz-linear-gradient(bottom, #6d8a18, #6d8a18);
background: -o-linear-gradient(bottom, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.4)), -o-linear-gradient(bottom, #6d8a18, #6d8a18);
background: -ms-linear-gradient(bottom, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.4)), -ms-linear-gradient(bottom, #6d8a18, #6d8a18);
View dabblet.css
/**
* Audio Toggle
*/
div, a, ul, li {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font-weight: 100;
View Add custom classes to Middleman pages
def page_classes
path = request.path_info.dup
path << settings.index_file if path.match(%r{/$})
path = path.gsub(%r{^/}, '')
classes = []
parts = path.split('.')[0].split('/')
parts.join(' ')
end
View jQuery for smooth scrolling local links
View dabblet.css
/**
* Audio Toggle
*/
html {
background: #333;
}
div {
padding: 0;
}
#threeway {
You can’t perform that action at this time.