Skip to content

Instantly share code, notes, and snippets.

View sporto's full-sized avatar

Sebastian Porto sporto

  • Melbourne, Australia
View GitHub Profile
@sporto
sporto / interactor.rb
Created July 22, 2017 03:35
A pattern for interactors
class DoSomething
def self.build(dep:)
->(user:) {
self.new(dep: dep, user: user).call
}
end
def initialize(dep:, user:)
@dep = dep
@user = user
@sporto
sporto / clipboard.history.json
Last active August 27, 2021 03:58
Visual Studio Code Settings Sync Gist
{
"version": 2,
"clips": [
{
"value": " {{ collection.pages }}",
"createdAt": 1630036485337,
"copyCount": 1,
"useCount": 0,
"language": "html",
"createdLocation": {
@sporto
sporto / library-design.md
Created March 11, 2017 04:04
Library Design in Elm

This is an example reusable element I made for our application https://github.com/sporto/elm-select

My current API is not great as it requires a lot of boilerplate to hook init, state, update and view.

But in summary this library requires:

  • Some configuration
  • App state: Some state that the application manages e.g. currently selected thing
  • Hidden state: Some state that the component cares about, that can be hidden from the app
@sporto
sporto / feedback.md
Last active March 7, 2017 03:13
Reusable view feedback

This is an example reusable element I made for our application https://github.com/sporto/elm-select

It is an input field with auto suggestions.

This element needs three pieces of state:

  • List of things to search for
  • Current selected thing
  • And the query the user is typing (At the moment this is in "hidden" state)
@sporto
sporto / thoughts.md
Last active February 14, 2017 00:12
Extreme programming language aficionados

https://twitter.com/markdalgleish/status/830557687779700736

Extreme is very vague. I assume you are comparing JS vs Elm / PureScipt.

You get a lot more than purity i.e. robust, speed of development, confidence.

You give up less than you say.

Convenience: Depends on what are you used to, Haskell, PS can be have a lot of 'convenience' after you learn them. Is just different type.

@sporto
sporto / Elm.md
Last active September 6, 2017 04:41
Thoughts on Elm is Wrong

http://reasonablypolymorphic.com/blog/elm-is-wrong

Haskell dev writes some Elm, concludes that the language should be avoided. Writes an article about it.

JS developer then reads and thinks, oh Elm is bad, I better stick to JS then.

We just made a huge disservice to the programming community. That article might be right in several things (how the lack of Typeclasses hurts expressiveness), but it totally missed the point of Elm.

As an industry we want to move to more robust languages. Haskell has been around for many year, but we are still mostly using mediocre programming languages. Haskell is great but it has a huge learning curve, so people don't adopt it.

@sporto
sporto / forward-pipes.md
Last active August 26, 2016 00:51
Forward pipes

A common way is to chain operations using method calls:

collection
    .map(f1)
    .filter(f2)

However this only works if collection has the methods we want e.g map, filter. There is no way to chain something that doesn't exist in collection in the first place.

@sporto
sporto / sample.elm
Last active February 17, 2018 11:10
Pipelines
import Html exposing (text)
multBy x =
(*) x
biggerThan x =
(<) x
nums =
[1,2,3]

We have two components, parent and child. When user hovers over the parent we want to change an attribute on the child. We achieve this we are using a global class in the child so the parent can select it. But this breaks the modularity of css modules.

Is there a way to solve this in a nicer way without using global?

@sporto
sporto / programming-languages.md
Last active May 31, 2016 04:28
Thoughts on programming languages

I think we need to adopt a more robust programming language in the future than ruby. Ruby has been great in terms of letting us build things fast up to now. But Ruby falls shorts in speed and robutness.

At the moment we do thinks like:

  • Guard for the type of an argument functions, we raise if incorrect
  • Use Json.schema to validate hashes
  • Check for nils and return nils if nil
  • Create unit test that check what would happen when an input is nil