Skip to content

Instantly share code, notes, and snippets.

View mikedugan's full-sized avatar

Mike Dugan mikedugan

View GitHub Profile
@mikedugan
mikedugan / vertical-text.css
Created November 29, 2013 22:26 — forked from obenjiro/vertical-text.css
makes text display vertically in browsers
/**
* Works everywere ( IE7+, FF, Chrome, Safari, Opera )
* Example: http://jsbin.com/afAQAWA/2/
*/
.rotated-text {
display: inline-block;
overflow: hidden;
width: 1.5em;
}
.rotated-text__inner {
@mikedugan
mikedugan / equalheight.jquery.js
Created November 22, 2013 13:46
slices up HTML elements into equal height
//slices up the given items in groups of size n
function sliceItems(items, n) {
for(i=0; i <= items.length; i+=n) {
setItems(items.slice(i,i+n));
}
}
//gets the max height and sets all items in a slice to that height
function setItems(items) {
var maxHeight = Math.max.apply(null, items.map(function()
@mikedugan
mikedugan / imgwrap.jquery.js
Created November 12, 2013 17:49
wraps an img in anchor from sibling, and removes the anchor
//where containerDiv is the parent of the img and a
//where imgwrap is the anchor the img will be wrapped in
$('.containerDiv').each(function() {
$('img',$(this)).wrap('<a href="' + $('.imgwrap',$(this)).attr('href') + '"></a>');
});
$('.imgwrap').remove();
@mikedugan
mikedugan / scroll.jquery.js
Created November 11, 2013 22:48
scrolls to a point on a page given anchor & offset
//scrolls to a given point with offset n from point (750)
scrollTo: function() {
$('#main-nav').find('li > a').on("click", function(e){
$('#main-nav').find('li').removeClass('active');
$(this).parent().addClass('active');
var id = $(this).attr("href");
$('html, body').animate({
scrollTop: $(id).offset().top
}, 750);
e.preventDefault();
@mikedugan
mikedugan / findlinks.php
Created November 11, 2013 22:48 — forked from weivall/Find All Links on a Page
grabs all the links on a given page and does something (echo) with them
@mikedugan
mikedugan / generateCSV.php
Created November 11, 2013 22:44 — forked from weivall/Generate CSV file from a PHP array
generates a csv file from a php array
//generates a csv file given an array
function generateCsv($data, $delimiter = ',', $enclosure = '"') {
$handle = fopen('php://temp', 'r+');
foreach ($data as $line) {
fputcsv($handle, $line, $delimiter, $enclosure);
}
rewind($handle);
while (!feof($handle)) {
$contents .= fread($handle, 8192);
}
@mikedugan
mikedugan / iebody.html
Created November 11, 2013 22:39
Appends a class to the body dependant on IE version
<!--[if lt IE 7 ]> <body class="ie6"> <![endif]-->
<!--[if IE 7 ]> <body class="ie7"> <![endif]-->
<!--[if IE 8 ]> <body class="ie8"> <![endif]-->
<!--[if IE 9 ]> <body class="ie9"> <![endif]-->
<!--[if gt IE 9]> <body> <![endif]-->
<!--[if !IE]><!--> <body> <!--<![endif]-->
@mikedugan
mikedugan / jslibrary.md
Created November 11, 2013 12:02
JavaScript Libraries

JavaScript Libraries

This is just a useful reference for links to various JavaScript libraries & jQuery plugins with links and CDNs.

Core Libraries

jQuery jQuery UI jQuery Mobile Sizzle Angular Angular CDN
@mikedugan
mikedugan / easings.jquery.js
Created November 8, 2013 18:04
short array of jquery easing functions
//usefulness debatable - returns array of all easings given basic easing names
var easings = array(
'ease_Sine',
'ease_Quad',
'ease_Cubic',
'ease_Quart',
'ease_Quint',
'ease_Expo',
'ease_Circ',
'ease_Back',
@mikedugan
mikedugan / animate.jquery.js
Created November 8, 2013 17:55
jquery animate - basic usage
$('someEl').click(function() {
$(this).animate({
'font-size': '+=5',
'width': '-=50'
}, 500, 'swing', function() {
console.log("this is the callback functon");
})
});