Skip to content

Instantly share code, notes, and snippets.

@cferdinandi
cferdinandi / spinners.css
Created February 28, 2014 04:26
Simple CSS3 rotation animations.
/* The class that applies the animation. */
.spinner {
display: inline-block;
@include prefixer(animation, spin 2s infinite linear, webkit moz ms o spec);
}
/* The vendor-specific and generic animation keyframes.
* These control the direction and nature of the animation. */
<?php
function some_name( array $options = array() ) {
// Set defaults for all passed options
$options = array_merge( array(
'property1' => 'default1',
'property2' => 'default2',
), $options);
}
@cferdinandi
cferdinandi / initEventListeners.js
Last active August 29, 2015 14:01
A simple method to set and remove event listeners for dynamically generated content.
// Event selector defaults
var toggles; // Toggle nodes list
var eventListeners = []; //Listeners array
// Whenever a toggle is clicked, run the function
toggles = document.querySelectorAll('[data-collapse]'); // Get all collapse toggles
forEach(toggles, function (toggle, index) {
eventListeners[index] = exports.FUNCTION.bind( null, VARIABLES );
toggle.addEventListener('click', eventListeners[index], false);
});
@cferdinandi
cferdinandi / trim.js
Created June 6, 2014 18:04
Remove whitespace from a string.
/**
* Remove whitespace from a string
* @private
* @param {String} string
* @returns {String}
*/
var trim = function ( string ) {
return string.replace(/^\s+|\s+$/g, '');
};
/*! loadJS: load a JS file asynchronously. [c]2014 @scottjehl, Filament Group, Inc. (Based on http://goo.gl/REQGQ by Paul Irish). Licensed MIT */
function loadJS( src ){
'use strict';
var ref = window.document.getElementsByTagName( 'script' )[ 0 ];
var script = window.document.createElement( 'script' );
script.src = src;
ref.parentNode.insertBefore( script, ref );
return script;
}
@cferdinandi
cferdinandi / kraken-addon-checklist.md
Last active August 29, 2015 14:05
Kraken add-on checklists...

Kraken

  • Kraken

Scripts

  • Buoy
  • Astro
  • Drop
  • Houdini
@cferdinandi
cferdinandi / sublime-text-prefs
Last active August 29, 2015 14:06
My Sublime Text preferences...
{
"color_scheme": "Packages/Monokai Extended/Monokai Extended.tmTheme",
"find_selected_text": true,
"font_face": "Menlo",
"font_size": 14.0,
"highlight_line": true,
"hot_exit": false,
"ignored_packages":
[
"Vintage"

Deploying a subfolder to GitHub Pages

Sometimes you want to have a subdirectory on the master branch be the root directory of a repository’s gh-pages branch. This is useful for things like sites developed with Yeoman, or if you have a Jekyll site contained in the master branch alongside the rest of your code.

For the sake of this example, let’s pretend the subfolder containing your site is named dist.

Step 1

Remove the dist directory from the project’s .gitignore file (it’s ignored by default by Yeoman).

@cferdinandi
cferdinandi / commonJS.js
Last active August 29, 2015 14:10
A common JS wrapper module.
(function (root, factory) {
if ( typeof define === 'function' && define.amd ) {
define('myPlugin', factory(root));
} else if ( typeof exports === 'object' ) {
module.exports = factory(root);
} else {
root.myPlugin = factory(root);
}
})(typeof global !== "undefined" ? global : this.window || this.global, function (root) {
@cferdinandi
cferdinandi / jquery-iife.js
Last active August 29, 2015 14:15
An IIFE wrapper for jQuery scripts that ensures no conflicts between the $ and other scripting languages.
;(function ($, window, document, undefined) {
'use strict';
// Code goes here...
})(jQuery, window, document);