Skip to content

Instantly share code, notes, and snippets.

Aki Karkkainen akikoo

View GitHub Profile
@akikoo
akikoo / gist:6200960
Last active Jan 9, 2018
Automatic Responsive screenshots creation with PhantomJS and CasperJS.
View gist:6200960
/*!
*
* 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 Jul 7, 2012
SCSS (Sass) template with cross-browser CSS3 mixins
View scss base template
/* 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 Jun 17, 2012
Detect from JavaScript whether media queries have been executed in CSS
View gist:2944398
<!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 Jun 10, 2012
jQuery plugin boilerplate
View gist:2906490
/*!
* 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 Jun 10, 2012
IE browser sniffing using conditional comments
View gist:2906478
/**
* 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 Jun 10, 2012
Cross-browser event object
View gist:2906364
/**
* 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
* });
You can’t perform that action at this time.