Skip to content

Instantly share code, notes, and snippets.

Avatar
🤖

Benjamin Charity benjamincharity

🤖
View GitHub Profile
@benjamincharity
benjamincharity / wrapLinesFilter.js
Created Jun 30, 2015
Wrap lines in spans that don't go past a certain character count while respecting words.
View wrapLinesFilter.js
angular.module('common')
.filter('split', function() {
//
// Helper function
// Return as many words as possible without going past the limit
var trimWords = function(string, limit) {
var cutAtCharacterLimit = string.slice(0, limit).trim();
var indexOfLastSpace = cutAtCharacterLimit.lastIndexOf(' ');
var cutAtLastSpace;
@benjamincharity
benjamincharity / telephone.filter.js
Created Jul 17, 2015
Filter to format or clean a phone number.
View telephone.filter.js
angular.module('common')
.filter('telephone', function() {
'use strict';
/**
* Clean or format a telephone number
*
* @param {String} number
* @param {String} method
View flexbox.scss
///////////////////////////
//
// Flexbox
//
// flex_container() direction is required.
//
// Possible values:
// - vertical
// - horizontal
//
@benjamincharity
benjamincharity / button.html
Last active Aug 29, 2015
Animated arrow to toggle button.
View button.html
<button class="foo">Test</button>
@benjamincharity
benjamincharity / luhnValidation.js
Created Jul 31, 2015
Validate credit card with the luhn algorithm.
View luhnValidation.js
/*
* Check the validity of a credit card number
*
* https://gist.github.com/2134376
* Phil Green (ShirtlessKirk)
*
* @param {String} number
* @return {Bool} validity
*/
@benjamincharity
benjamincharity / disableAnimate.js
Created Sep 8, 2015
Disable ngAnimate for a specific element.
View disableAnimate.js
function disableAnimate($animate) {
'ngInject';
return {
restrict: 'A',
link: function($scope, $element) {
$animate.enabled($element, false);
},
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);
}