Skip to content

Instantly share code, notes, and snippets.

View kimmobrunfeldt's full-sized avatar

Kimmo Brunfeldt kimmobrunfeldt

View GitHub Profile
@kimmobrunfeldt
kimmobrunfeldt / heroku.md
Created November 16, 2015 11:54
Heroku pipelines

Heroku Pipelines, GitHub integration and Review apps

In short, they are awesome. They have some limitations though.

Pipelines

Clear dash board to which documents all the environments and deployment flow.

Heroku forces to categorize your existing applications, e.g. myapp-dev.herokuapp.com to these three slots in the pipeline:

@kimmobrunfeldt
kimmobrunfeldt / 0.md
Created October 8, 2015 12:59
Flux / Redux - How to chain complex actions?

Flux / Redux chaining actions?

Example scenario

Moderation UI where moderator can do various operations to comments. For example:

  • Do operations to single comments, e.g. publish a comment
  • Do operations to multiple comments at a time
  • Answer to a comment. If the original comment is not published, it will be implicitly published when moderator answers to a comment.
const App = React.createClass({
render() {
var page = this.props.currentPage;
return <div>
{page}
</div>;
}
});
import React from 'react';
const Items = React.createClass({
render() {
return [
<li>1</li>,
<li>2</li>
];
}
});
@kimmobrunfeldt
kimmobrunfeldt / test.js
Created September 23, 2015 13:58
Promise catching
// Version 1
a()
.then(b)
.then(c)
.then(success, error); // Here the error handler does NOT catch errors thrown in the success handler
// Version 2
a()
.then(b)
@kimmobrunfeldt
kimmobrunfeldt / pandoc.css
Last active October 15, 2018 06:46 — forked from killercup/pandoc.css
Run: `pandoc --css pandoc.css -s api.md -o api.html && open api.html` and export as PDF from browser.
/*
* I add this to html files generated with pandoc. Originally:
* https://gist.github.com/killercup/5917178#file-pandoc-css
*/
html {
font-size: 100%;
overflow-y: scroll;
-webkit-text-size-adjust: 100%;
-ms-text-size-adjust: 100%;
@kimmobrunfeldt
kimmobrunfeldt / 0-links.md
Last active August 29, 2015 14:18
Suomen karttajärjestelmä
@kimmobrunfeldt
kimmobrunfeldt / 0-looks-like-correct.js
Created March 12, 2015 19:31
One reason why !! is dangerous
// _.find returns undefined if nothing is found, otherwise returns the found item.
var existsOnCurrentPeriod = _.find(currentValues.operators, function(operatorId) {
return operatorId === operator.usbKeyId;
});
operator.existsOnPeriod = !!existsOnCurrentPeriod;
// This looks correct at first glance, but see below
@kimmobrunfeldt
kimmobrunfeldt / prepare-null.js
Created March 6, 2015 09:01
Preparing for null..
// utils.jsx
// Returns wanted data or null. You can specify default value instead of null.
// Remember that arrays are actually objects so you can get index of array with
// 'arr.0'
// e.g get(object, 'data.results.0')
function get(obj, attributePath, defaultValue) {
var opts = _.extend({defaultValue: null}, {defaultValue: defaultValue});
if (!obj) {