Skip to content

Instantly share code, notes, and snippets.

🤑
Looking for work

Barney Carroll barneycarroll

🤑
Looking for work
Block or report user

Report or block barneycarroll

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 isomorphic-code-splitting-webpack-2-mithril-route-resolver.js
import m from 'mithril'
import store from '../../store'
import {loadUsers} from '../../data/users/actions'
import layout from '../../components/layout'
if (typeof require.ensure !== 'function') require.ensure = (d, c) => c(require)
async function getJs(){
return (await require('./users.js')).default
}
View breadcrumb.js
var m = require('mithril');
var _ = require('lodash');
breadcrumb.view = function (ctrl,array) {
return m('.breadcrumb', [
_.map(array, function (b, i) {
return m('.breadcrumb', [
m('i.material-icons', 'chevron_right'),
m('a.breadcrumb-link', {
href: b.url,
View selectOption.js
var m = require( 'mithril' )
var isSelected = require( '../functions/isSelected' )
function action(option, selection, e){
if (isSelected(ctrl.option, ctrl.selection)) {
var i = ctrl.selection.indexOf(ctrl.option)
ctrl.selection.splice(i, 1)
} else {
@barneycarroll
barneycarroll / app.js
Last active Mar 24, 2016 — forked from tobyzerner/app.js
Mithril ES6 Components
View app.js
// No dependencies! + 1 point
// Only one API to reference! + 1 point
const Widget = {
// Expose desired data directly using destructuring! + 1 point
controller({initialValue}) {
// No more retrieving references buried by the superclass! + 1 point
this.counter = initialValue;
// Two less methods! + 2 points
},
View app.js
var m = require('mithril');
var layout = require('./components/layout/layout.js');
m.route.mode = 'pathname';
var Account = require('./models/account.model');
authRoutes(document.getElementById('app'), '/', layout.wrap({
'/': require('./pages/dashboard.js'),
@barneycarroll
barneycarroll / application.controller.js
Last active Dec 15, 2015 — forked from SirZach/application.controller.js
Can't access object values by dynamic key in Handlebars
View application.controller.js
import Ember from 'ember';
export default Ember.Controller.extend({
numbers:['1','2','3','4'],
letters:['a','b','c','d']
});
View mithriljsonextract.js
// MODEL
'use strict';
var m = require('mithril');
module.exports = function get_himage(){
return m.request({
method: 'GET',
url: '/config.json'
})
.then(function (data) {
View m.validator.js
m.validator = function (model, validations) {
this.errors = {}
this.validations = validations
this.model = model
}
m.validator.prototype.hasErrors = function () {
return Object.keys(this.errors).length
}
View modulator.js
var mod = ( function initModulator(){
if( !Map ){
// A naive shim for maps functionality
var Map = shim;
var WeakMap = shim;
}
// Garbage collection flag
mod.cleanup = true;
You can’t perform that action at this time.