Skip to content

Instantly share code, notes, and snippets.

View BigAB's full-sized avatar
🇨🇦
JavaScript Loving Canadian

Adam L Barrett BigAB

🇨🇦
JavaScript Loving Canadian
View GitHub Profile
@BigAB
BigAB / arrow-functions.md
Last active June 28, 2016 18:10
Arrow functions and code style

When deciding on which code style to use, under different circumstances (i.e. number of parameters, return value, etc.) a good solid rule for consistency and terseness is: Always use the minimum required syntax for the situation

The minimum does not include variable/parameter names, which should should be semantic to the meaning or general depending on how the function will be used. Using an unused parameter name to save one char (like _ => 2*2) is confusing and should be avoided.

With this rule in mind we end up with this:

// no params
() => {}                    // "noop" no parameters, no operations, no return value
() => value + 1             // no parameters, one line operation, a return value (that is not an object)
@BigAB
BigAB / gulpfile.js
Created February 22, 2016 15:54
Use includePaths to import bootstrap into your project
var gulp = require('gulp');
var sass = require('gulp-sass');
gulp.task('style', function() {
return gulp.src('style.scss')
.pipe(sass({
includePaths: ["node_modules/bootstrap/scss"]
}))
.pipe(gulp.dest('./'));
});
@BigAB
BigAB / simple-author-model.js
Created January 8, 2016 06:06
Simple test of Feathers-Mongoose
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var authorSchema = new Schema({
name: String,
age: Number,
blogs: [{ type: Schema.Types.ObjectId, ref: 'Blog' }]
});
var Author = mongoose.model('Author', authorSchema);
@BigAB
BigAB / day2.js
Created December 4, 2015 20:02
Advent of code day 2 answer - adventofcode.com
function calculateWrappingPaperNeeds(input) {
return input.split('\n')
.reduce((sqFt, eq) => {
var d = eq.split('x');
var l = d[0], w = d[1], h = d[2];
sqFt += 2*l*w + 2*w*h + 2*h*l;
sqFt += Math.min(l*w, w*h, h*l); // little extra
return sqFt;
}, 0);
}
@BigAB
BigAB / Live-Sortable-Lists-with-CanJS.markdown
Created April 6, 2015 20:45
Live Sortable Lists with CanJS

Live Sortable Lists with CanJS

Using CanJS and the sortable-plugin, having live sortable lists becomes easy, leading to an simple and expressive template that just works.

A Pen by Adam Barrett on CodePen.

License.

@BigAB
BigAB / .eslintrc
Created March 27, 2015 02:21
ESLint .eslintrc file for configuring eslint
{
// http://eslint.org/docs/rules/
"ecmaFeatures": {
"arrowFunctions": true, // enable arrow functions
"modules": true, // enable modules
"binaryLiterals": false, // enable binary literals
"blockBindings": true, // enable let and const (aka block bindings)
"classes": true, // enable classes
"defaultParams": true, // enable default function parameters
@BigAB
BigAB / dabblet.css
Last active August 29, 2015 14:12
A pretty nav
/* A pretty nav */
body {
color: #eee;
background: rgba(0, 0, 0, 0.8);
font-family: sans-serif;
font-size: 24px;
}
nav {
text-align: right;
@BigAB
BigAB / ABProgressBar.h
Created December 12, 2013 22:46
A nice little customizable view for a progress bar, with optional animation properties
//
// ABProgressBar.h
// Adam L Barrett
//
// Created by Adam L Barrett on 2013-12-10.
// Copyright (c) 2013 Adam L Barrett. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <QuartzCore/QuartzCore.h>
@BigAB
BigAB / ABSearch.m
Created August 21, 2013 15:52
An Equality test thing that though I am deleting I think I should keep around incase something similar comes up in the future.
@implementation ABSearch
{}
- (BOOL)isEqualToSearch:(GBSearch *)search {
if (self == search)
return YES;
static NSString *objTypeIndicator = @"T@";
static NSString *timePropertyName = @"time";
static NSString *locationPropertyName = @"location";