Skip to content

Instantly share code, notes, and snippets.

View akikoo's full-sized avatar

Aki Karkkainen akikoo

View GitHub Profile
@akikoo
akikoo / gist:6200960
Last active January 9, 2018 14:51
Automatic Responsive screenshots creation with PhantomJS and CasperJS.
/*!
*
* Automatic Responsive screenshots creation with PhantomJS and CasperJS.
* Adapted from the Responsive Design Workflow book by Stephen Hay (http://responsivedesignworkflow.com/).
*
* Usage instructions:
- Install PhantomJS (http://phantomjs.org/) and CasperJS (http://casperjs.org/)
- Save this script as `screenshots-multipages.js` in a folder somewhere in your filesystem
- In the same folder, create a subfolder called `screenshots` (defined in `screenshotFolder` variable)
- Define the URLs you want to process in `baseUrl` (string) and `links` (array) variables
@akikoo
akikoo / scss base template
Created July 7, 2012 19:55
SCSS (Sass) template with cross-browser CSS3 mixins
/* Welcome to Compass.
* In this file you should write your main styles. (or centralize your imports)
* Import this file using the following HTML or equivalent:
* <link rel="stylesheet" href="/stylesheets/screen.css" media="screen" type="text/css" /> */
// This comment is not output to CSS
/* This comment is output to CSS */
// The CSS3 module provides cross-browser mixins for CSS properties
@akikoo
akikoo / gist:2944398
Created June 17, 2012 12:21
Detect from JavaScript whether media queries have been executed in CSS
<!DOCTYPE html>
<!--
Technique for maintaining the media queries in CSS only. Media query CSS
execution is detected by JavaScript that reads the CSS generated content value.
Credits:
http://adactio.com/journal/5414/
http://adactio.com/journal/5429/
https://gist.github.com/2481019
@akikoo
akikoo / gist:2906490
Created June 10, 2012 16:27
jQuery plugin boilerplate
/*!
* jQuery plugin boilerplate
*
* Inspiration:
* http://msdn.microsoft.com/en-us/scriptjunkie/ff608209
* http://www.learningjquery.com/2007/10/a-plugin-development-pattern
* http://shichuan.github.com/javascript-patterns/
*
* Author: Aki Karkkainen/@akikoo
* Licensed under the MIT license
@akikoo
akikoo / gist:2906478
Created June 10, 2012 16:25
IE browser sniffing using conditional comments
/**
* Browser sniffing using conditional comments. JavaScript Patterns book.
* It is slightly safer than looking for strings in navigator.userAgent,
* because these strings are easy to change by the user.
*
* Having this:
* var isIE = /*@cc_on!@*/false;
* will set isIE to false in all browsers (because they ignore the comment),
* but it will be true in Internet Explorer, because of the negation ! in the
* conditional comment.
@akikoo
akikoo / gist:2906364
Created June 10, 2012 15:59
Cross-browser event object
/**
* Cross-browser event object
* Adapted from Professional JavaScript for Web Developers, 3rd Edition, by Nicholas C. Zakas
*
* Usage example:
*
* eventUtil.addHandler(elm, "click", function (e) {
* e = eventUtil.getEvent(e); // Get event object
* eventUtil.preventDefault(e); // Prevent default action
* });