Skip to content

Instantly share code, notes, and snippets.

View nicinabox's full-sized avatar

Nic Haynes nicinabox

View GitHub Profile
@nicinabox
nicinabox / accordion.js
Created May 2, 2012 21:58
Use an accordion dynamically in a Refinery page
if ($('#main').hasClass('accordion')) {
$('#main .content h3').each(function(index) {
content = $(this).nextUntil('h1, h2, h3')
content.wrapAll('<section />')
});
}
$('#main.accordion .content').accordion({
header: 'h3',
collapsible: true,
@nicinabox
nicinabox / gist:2586814
Created May 3, 2012 16:04
Load image with callback
var loadImage = function($img, callback) {
var image;
image = new Image();
return $img.load(function() {
if (typeof callback === 'function') {
callback(this);
}
return this;
});
};
@nicinabox
nicinabox / gist:2770226
Created May 22, 2012 16:55
Regex to fix Sequel Pro's CSV formatting
[\n]+([^\d])
@nicinabox
nicinabox / routes.rb
Created June 5, 2012 19:03
Static routes in Rails
get ":action", :to => "static", :action => /[a-z-]+/, :as => :static
@nicinabox
nicinabox / elastic.scss
Created June 14, 2012 16:38
Elastic navigation
@mixin elastic-nav($width: 100%) {
display: table;
table-layout: fixed;
width: $width;
> li {
display: table-cell;
> a {
width: auto;
}
}
@nicinabox
nicinabox / Readme.md
Created June 28, 2012 15:34
Elastic navigation for responsive designs

Elastic navigation

Demo

Accepts 1 parameter:

  • An integer that is the width to stop being elastic

app.js

* {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
textarea.textarea {
width: 50%;
max-width: none;
}
@nicinabox
nicinabox / device.js
Created September 14, 2012 16:11
Basic device properties for use when checking screen size or mobile.
/*
Author: Nic Aitch - @nicinabox
Version: 1.1
Description: Basic device properties for use when checking screen size or mobile.
License: MIT
*/
(function(window, document, undefined) {
var device = {};
{% capture reading_time %}
{{ 150 | divided_by: 150 }}
{% endcapture %}
<span>
Reading time: about {{ reading_time }}
{% if reading_time == 1 %}
minute
{% else %}
$.fn.showHint = function() {
var $data = this.data('content');
return this.each(function(i) {
$(this).empty().html($data[$(this).val()]);
});
};