Skip to content

Instantly share code, notes, and snippets.

Avatar

hong-jen kao cades

View GitHub Profile
View functional core, imperative shell.md

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

https://www.youtube.com/watch?v=yTkzNHF6rMs

@cades
cades / Functional Core, Imperative Shell
Created Jan 8, 2018 — 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
http://www.infoq.com/presentations/Simple-Made-Easy
http://www.infoq.com/presentations/integration-tests-scam
http://blog.thecodewhisperer.com/2010/09/14/when-is-it-safe-to-introduce-test-doubles
http://youtu.be/yTkzNHF6rMs
http://pyvideo.org/video/1670/boundaries
http://skillsmatter.com/podcast/ajax-ria/enumerators
http://alistair.cockburn.us/Hexagonal+architecture
http://c2.com/cgi/wiki?PortsAndAdaptersArchitecture
http://www.confreaks.com/videos/977-goruco2012-hexagonal-rails
http://www.confreaks.com/videos/1255-rockymtnruby2012-to-mock-or-not-to-mock
View keybase.md

Keybase proof

I hereby claim:

  • I am cades on github.
  • I am cadeskao (https://keybase.io/cadeskao) on keybase.
  • I have a public key ASAA4ohCDiWEhnRhWxypFtKQM1ESnUXso-pIWy9JcM-2oQo

To claim this, I am signing this object:

View kaybase.md

Keybase proof

I hereby claim:

  • I am cades on github.
  • I am cadeskao (https://keybase.io/cadeskao) on keybase.
  • I have a public key ASAx0YvoGBzahnrUBRq7XyWOQLT1JV3Y3h7pYaXjl5L0EQo

To claim this, I am signing this object:

@cades
cades / HOC-after-2.2.0.js
Created Apr 21, 2017
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
cades / gist:44862551de984dd760f35a68f3cae21e
Created Jan 30, 2017 — 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: http://stackoverflow.com/questions/14130560/nodejs-udp-multicast-how-to?utm_medium=twitter&utm_source=twitterfeed
!Server
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
cades / 1-first-attempt.js
Last active May 27, 2016
在 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
cades / response.feature
Created Mar 20, 2015
a HTTP server testing DSL proposal
View response.feature
Feature: I can test request response features
Scenario Outline: response code
When I request "GET" "http://httpbin.org/status/<code>"
Then the response code should be <code>
Examples:
| code |
| 200 |
| 411 |
@cades
cades / gulpfile.js
Last active Aug 29, 2015
static web development setup with livereload
View gulpfile.js
var gulp = require('gulp'),
connect = require('gulp-connect');
gulp.task('webserver', function(){
connect.server({
livereload: true
});
});
gulp.task('watch', function(){
@cades
cades / ng-google-auth.js
Created Oct 15, 2014
登入 Google 帳號的 AngularJS directive。 HackNTU 的產出之一,未完成
View ng-google-auth.js
'use strict';
angular.module('calenshareApp')
.factory('GoogleAuth', function () {
(function() {
var po = document.createElement('script');
po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/client:plusone.js?onload=render';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(po, s);