Skip to content

Instantly share code, notes, and snippets.

Ben Barnett benbarnett

Block or report user

Report or block benbarnett

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View doughCollapsableExample.html
<!--
The main thing to note here is the data-dough-collapsable-trigger="1" and data-dough-collapsable-target="1"
This is how the trigger and target correspond to each other.
You can set the value to anything you like, it just need to match the trigger and target. We have just used "1" in this example.
-->
<p class="hidden-for-print collapsable__trigger" data-dough-component="Collapsable" data-dough-collapsable-trigger="1">
This is the text for the show/hide trigger link (it will be converted to a link by the Javascript)
</p>
@benbarnett
benbarnett / errors
Created Aug 8, 2014
Example Error API Response
View errors
{
errors: [
{
inputs: ['user_email'],
error_number: 1,
error_message: "Please provide a valid email address"
},
{
inputs: ['user_password', 'user_password_confirm'],
error_number: 2,
View gist:ea458463142cd67acb06
<div class="validation-summary">
<div class="validation-summary__content-container">
<p class="validation-summary__title">Please double-check the form for the following errors</p>
<ol class="validation-summary__list">
<li class="validation-summary__error">
<a href="#interest_rate-errors">Based on 25 year repayment mortgage at: must be a number</a>
</li>
<li class="validation-summary__error">
<a href="#annual_income-errors">Annual income must be a number</a>
@benbarnett
benbarnett / app.js
Created Oct 15, 2013
Include cookie sessions
View app.js
var cookieSessions = require('./modules/cookieSessions');
app.configure(function() {
app.use(express.cookieParser('a9e687e0-a1e0-11e2-9e96-0800200c9a66'));
app.use(cookieSessions('ucheckout'));
});
@benbarnett
benbarnett / cookieSessions.js
Created Oct 15, 2013
NodeJS Signed cookies
View cookieSessions.js
/**
* Signed session cookies used for persistence
* @param {[type]} name [description]
* @return {[type]} [description]
*/
module.exports = function(name) {
return function(req, res, next) {
req.session = req.signedCookies[name] || {};
@benbarnett
benbarnett / vines.txt
Created May 9, 2013
Vine's from @ben_cameron
View vines.txt
Fun times with @mrnickharvey https://vine.co/v/b29EtOb6nw6
Quick message of thanks to everyone for the Vine feedback https://vine.co/v/b2EHtJTpvYv
Vining for the sake of vining https://vine.co/v/b20lwHiPzHD
The truth about my Vines https://vine.co/v/b20xKdM6Xxm
Tough love (the outtake) https://vine.co/v/b20Up1QvJXX
Tough love https://vine.co/v/b20U7ipjZlA
Bus face https://vine.co/v/b211O6QxnE6
I don't like cheesy poofs https://vine.co/v/bQPBI5x5MdK
I don't like cheesy poofs https://vine.co/v/bQPBibOj17A
Wake up! https://vine.co/v/bQHQAjLMUPi
@benbarnett
benbarnett / preloadimages.js
Created Nov 30, 2012
Preload multiple images
View preloadimages.js
function loadImgs(urls, doneCallback) {
var remaining = total = urls.length;
var imgs = [];
function imgLoad(url) {
if (!--remaining) {
doneCallback(imgs);
}
}
@benbarnett
benbarnett / GroupsToPNG.jsx
Created Jan 17, 2012
Groups to PNG Photoshop Script
View GroupsToPNG.jsx
#target photoshop
var sizes = {
'xlarge': [1490, 730],
'large': [1160, 568],
'medium': [890, 436],
'small': [760, 372]
};
View gist:1555873
<a href="http://twitter.com/benpbarnett" rel="contact">@benpbarnett on Twitter</a>
View jquery-get-enhanced-demo.js
var sillyWords = ["incredible", "awesome", "amazing", "fantastic"];
$('button#start').click(function() {
var button = $(this).attr('disabled', 'disabled');
$.get('endpoint/data.html #target', function(data) {
// do something amazing with the data
if (data) {
// fetch word
var word = sillyWords[Math.floor(Math.random() * sillyWords.length)];
You can’t perform that action at this time.