Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Stephan Hoyer StephanHoyer

🏠
Working from home
View GitHub Profile
View mithril.js
;(function() {
"use strict"
function Vnode(tag, key, attrs0, children, text, dom) {
return {tag: tag, key: key, attrs: attrs0, children: children, text: text, dom: dom, domSize: undefined, state: undefined, events: undefined, instance: undefined}
}
Vnode.normalize = function(node) {
if (Array.isArray(node)) return Vnode("[", undefined, undefined, Vnode.normalizeChildren(node), undefined, undefined)
if (node != null && typeof node !== "object") return Vnode("#", undefined, undefined, node === false ? "" : node, undefined, undefined)
return node
}
@StephanHoyer
StephanHoyer / diff.js
Created Nov 22, 2016
make a diff-list of two mailchimp exports
View diff.js
'use strict';
var fsp = require('fs-promise');
var differenceBy = require('lodash/differenceBy');
var keys = require('lodash/keys');
var values = require('lodash/values');
var parseCsv = require('csv-parse');
function parse(fileContent) {
return new Promise(function(resolve, reject) {
parseCsv(fileContent, {delimiter: ',', quote: '"', columns: true}, function (err, data) {
View prosemirror-integration.js
'use strict';
var model = require('prosemirror/model');
var ProseMirror = require('prosemirror/edit').ProseMirror;
var toDOM = require('prosemirror/convert/to_dom');
var fromDOM = require('prosemirror/convert/from_dom');
var elt = require('prosemirror/dom').elt;
function inline(dom, context, added) {
var old = context.styles;
View migration.js
function updateTile(tile) {
if (tile.get('width')) {
tile.set('columnCount', (tile.get('width') + gutter) / columnToColumn);
}
tile.set('width', tile.get('columnCount') * columnToColumn - gutter);
return tile.save();
}
function updateTiles() {
// this is called
View tooltip.js
'use strict';
var m = require('mithril');
var isFunction = require('lodash/lang/isFunction');
var assign = require('lodash/object/assign');
var minMax = require('client/utils').minMax;
var content, targetDimensions, options, showTimer, isVisible;
function px(value) {
View passwordComponent.js
'use strict';
var m = require('mithril');
var icons = require('client/utils/icons');
function controller() {
var scope = {
isPasswordVisible: false,
showPassword: function() {
scope.isPasswordVisible = true;
View store-client.js
'use strict';
var omit = require('lodash/object/omit');
var extend = require('lodash/object/extend');
var m = require('mithril');
function apiUrl(type) {
return '/api/v1/' + type;
}
@StephanHoyer
StephanHoyer / checkbox.js
Created Dec 8, 2015
Simple multiselect with mithril.js
View checkbox.js
'use strict';
var m = require('mithril');
var icons = require('client/utils/icons');
function checkbox(label, options) {
options = options || {};
var onclick = function(event) {
event.stopImmediatePropagation();
options.onchange && options.onchange({
@StephanHoyer
StephanHoyer / base.js
Last active Nov 19, 2015
Basic example of a j2c-mithril integration - http://jsfiddle.net/qe805q4q/1/
View base.js
var styler = require('./styler');
function mainView() {
return [
styler.view(),
//...
];
}
You can’t perform that action at this time.