Skip to content

Instantly share code, notes, and snippets.

View cades's full-sized avatar

hong-jen kao cades

View GitHub Profile
View functional core, imperative

1. Separation of immutable and mutable logic

Quite a lot of different people have been on the same trail of thought. Gary Bernhardt's formulation of a "functional core, imperative shell" seems to be the most voiced.

"Boundaries" - Gary Bernhardt

"Imperative shell" that wraps and uses your "functional core".. The result of this is that the shell has fewer paths, but more dependencies. The core contains no dependencies, but encapsulates the different logic paths. So we’re encapsulating dependencies on one side, and business logic on the other side. Or put another way, the way to figure out the separation is by doing as much as you can without mutation, and then encapsulating the mutation separately. Functional core — Many fast unit tests. Imperative shell — Few integration tests

cades / Functional Core, Imperative Shell
Created January 8, 2018 16:11 — forked from jhrr/Functional Core, Imperative Shell
Notes and links for ideas about Gary Bernhardt's "functional core, imperative shell"
View Functional Core, Imperative Shell

Keybase proof

I hereby claim:

  • I am cades on github.
  • I am cadeskao ( on keybase.
  • I have a public key ASAA4ohCDiWEhnRhWxypFtKQM1ESnUXso-pIWy9JcM-2oQo

To claim this, I am signing this object:


Keybase proof

I hereby claim:

  • I am cades on github.
  • I am cadeskao ( on keybase.
  • I have a public key ASAx0YvoGBzahnrUBRq7XyWOQLT1JV3Y3h7pYaXjl5L0EQo

To claim this, I am signing this object:

cades / HOC-after-2.2.0.js
Created April 21, 2017 05:51
higher-order component for vue.js 2
View HOC-after-2.2.0.js
export default function(WrappedComponent) {
const mixinProps = (WrappedComponent.mixins || [])
.filter((mixin) => mixin.props)
.map((mixin) => mixin.props);
const allProps = mixinProps.concat(WrappedComponent.props);
const mergedProps = allProps.reduce((merged, props) => Object.assign(merged, props), {});
return {
props: mergedProps,
render(createElement) {
cades / gist:44862551de984dd760f35a68f3cae21e
Created January 30, 2017 04:55 — forked from ciaranj/gist:9056285
A *working* (on Windows) UDP Multicast client & server with Node.Js v0.10.25 (I spent a *LOT* of time getting EINVAL and I still don't quite know why :/)
View gist:44862551de984dd760f35a68f3cae21e
For my own sanity ;) Scraped from a variety of places, including:
var news = [
"Borussia Dortmund wins German championship",
"Tornado warning for the Bay Area",
"More rain for the weekend",
"Android tablets take over the world",
"iPad2 sold out",
cades / 1-first-attempt.js
Last active May 27, 2016 08:14
在 mocha 中模仿 rspec-given 語法
View 1-first-attempt.js
describe('App.login()', () => {
it('should give token if success', sync(function*() {
var subject = Object.create(App), result
subject.init({ authVerifier: fakeAuthVerifier })
result = yield subject.login('user', 'pass', resume())
assert(typeof result.token === 'string')
cades / response.feature
Created March 20, 2015 12:40
a HTTP server testing DSL proposal
View response.feature
Feature: I can test request response features
Scenario Outline: response code
When I request "GET" "<code>"
Then the response code should be <code>
| code |
| 200 |
| 411 |
cades / gulpfile.js
Last active August 29, 2015 14:08
static web development setup with livereload
View gulpfile.js
var gulp = require('gulp'),
connect = require('gulp-connect');
gulp.task('webserver', function(){
livereload: true
gulp.task('watch', function(){
cades / ng-google-auth.js
Created October 15, 2014 07:01
登入 Google 帳號的 AngularJS directive。 HackNTU 的產出之一,未完成
View ng-google-auth.js
'use strict';
.factory('GoogleAuth', function () {
(function() {
var po = document.createElement('script');
po.type = 'text/javascript'; po.async = true;
po.src = '';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(po, s);