Skip to content

Instantly share code, notes, and snippets.

@i-like-robots
i-like-robots / ie6-7buttons.js
Created January 27, 2012 17:33
IE6 and 7 button element submit behaviour shim
/**
* IE 6 and 7 button[type=submit] shim
*
* @description Correct behaviour for button[type=submit] elements in IE 6 (all are submitted) and 7 (value is inner text). The
* following is only necessary if you must use button[type=submit] elements, otherwise stick to input[type=submit][class=button]
*/
$(function()
{
$('button[type=submit]').on('click', function()
{
@i-like-robots
i-like-robots / functions.php
Created August 21, 2012 10:01
Wordpress custom comment form
<?php
/**
* Comment form hidden fields
*/
function comment_form_hidden_fields()
{
comment_id_fields();
if ( current_user_can( 'unfiltered_html' ) )
{
@i-like-robots
i-like-robots / wordpress-pagination.php
Created August 22, 2012 09:46
Wordpress pagination
/**
* Archive pagination
* @param string $prevText Previous page link text. Leave blank to ignore.
* @param string $nextText Next page link text. Leave blank to ignore.
* @param integer $break Number of page links to display before truncation. Set to 0 to ignore.
*/
public static function archive_pagination($prevText = 'Previous', $nextText = 'Next', $break = 10)
{
// Maximum pages
global $wp_query;
@i-like-robots
i-like-robots / tmoauth-caching.php
Created August 29, 2012 08:45
Caching Tweets with tmhOAuth
<?php
class Tweets
{
/**
* Cached results as key => value array
*/
private static $cache = array();
@i-like-robots
i-like-robots / transparent-bg.less
Created October 19, 2012 09:40
LESS legacy IE transparent background colour
.ms-compatible-rgba-bg(@color, @alpha) {
// Lacking Sass' 'transparentize' function here =(
background-color:rgba( red(@color), green(@color), blue(@color), @alpha);
// Less can be very ugly, but using JS parsing is pretty useful
@alpha_rgb: 255 * @alpha;
@alpha_hex: ~`( parseInt("@{alpha_rgb}", 10)).toString(16)`;
@color_str: ~`"@{color}".replace('#', '')`;
@i-like-robots
i-like-robots / maps-queue.js
Created April 30, 2013 15:01
An interface for asynchronously loading the Google Maps API and queuing callbacks.
define(function() {
return {
/**
* Queue
* @type {Array}
*/
queue: [],
@i-like-robots
i-like-robots / css-feature-detection.js
Last active December 16, 2015 21:50
Handy drop-in module for CSS feature detection.
define(function() {
/**
* CSS feature detection
* @param {String} property
* @returns {String}
*/
return function(property) {
var i, len, prop;
var support = '';
@i-like-robots
i-like-robots / _config.scss
Last active December 18, 2015 01:48
SCSS skeleton grids with support for fluid or fixed units.
$layout-max-width: 64em;
$layout-break-point: 48em;
$layout-min-width: 20em;
$layout-column-count: 12;
$layout-column-width: 60;
$layout-gutter-width: 20;
@i-like-robots
i-like-robots / handlebars-loop.js
Created June 18, 2013 08:43
Handlebars helper to repeat a chunk of encapsulated output an arbitrary number of times.
// {{#loop 12}}
// <output>
// {{/loop}}
handlebars.registerHelper('loop', function(count, options) {
var out = "";
while (count--) {
out+= options.fn();
}
@i-like-robots
i-like-robots / my-component.js
Created April 29, 2014 13:39
React unit test component with Jasmine
/** @jsx React.DOM */
var MyComponent = React.createClass({
render: function () {
return (
<p ref="p">{this.props.children}</p>
);
}
});