Skip to content

Instantly share code, notes, and snippets.

View sporto's full-sized avatar

Sebastian Porto sporto

  • Melbourne, Australia
View GitHub Profile

Here are some thoughts on testing, this example is probably too simple and doesn't fully articulate the issue, but hopefully you get the idea. Something to discuss.

Define upfront

let(:car)           { F(:car) }
let(:fast_car)      { F(:car, fast: true) }
let(:red_car)       { F(:car, color: :red) }
let(:red_fast_car) { F(:car, fast: true, color: :red) }
@sporto
sporto / In Linux
Created March 8, 2016 22:47
Change location of docker containers
/etc/default/docker
# Use DOCKER_OPTS to modify the daemon startup options.
DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4 -g /home/sebastian/docker-data"
@sporto
sporto / unit-type.md
Created February 29, 2016 09:39
Elm Unit type

The unit type

The empty tuple () called the unit type is so prevalent in Elm that it deserves some explanation.

Consider a type alias with a type variable (represented by a):

type alias Message a = {
    code: String,
 body: a
@sporto
sporto / seamless.md
Last active November 25, 2015 21:48
Reducers with Seamless Immutable

Change one property

ES6

return {
  ...state,
  [productId]: (state[productId] || 0) + 1
}
@sporto
sporto / more-like-elm.md
Last active October 27, 2015 07:15
More like Elm

Ruby

array = []
array[0] * 2
undefined method `*' for nil:NilClass (NoMethodError)
@sporto
sporto / process.md
Last active February 24, 2016 04:33
Deploy Phoenix app using docker

Deploying an Phonenix App with Docker

I'm attempting to build and deploy a Phoenix (Elixir) application using Docker. I would like to produce a container or set of container, that I can simply push to my server and run using docker-compose

1. Build container for front end

Includes IOJS NPM Copy package json, then NPM install

I build apps in Rails and Phoenix. Usually I build them so I have a collection of rich applications embeded inside a traditional server side app:

I would love to start using Elm, but cannot figure out yet how to:

  • Have my wrapper navigation and CSS
  • And Elm reactor at the same time

An example showing how to structure this would be great.

Create an application

app = flip.app({
  resource: ['people', 'email']
})

Loader components

@sporto
sporto / css.md
Last active August 29, 2015 14:17
Thoughts on building maintainable CSS

Cascading is the enemy

  • When styles selectors cascade through the DOM we get unpredictable results
  • BEM help by removing cascading out of the equation, by using unique naming that shouldn't collide

Pure BEM is too prescriptive

BEM is very prescriptive, according to it something like bootstrap is a bad idea. It suggest staying away from things like .well or .row

Common patterns

@sporto
sporto / gist:2a04dff19424decb6a10
Last active August 29, 2015 14:15
Refactor curations show
def show
start = Time.now
previous_centre_future = nil
self.class.trace_execution_scoped(['Custom/CurationsController/show-api-calls']) do
if flash[:previous_centre_id].present?
previous_centre_future = Concurrent::Future.execute{CentreService.fetch flash[:previous_centre_id]}
previous_centre_future.add_observer(FutureObserver.new('previous_centre_future', start))
end