Thursday, March 30, 2017

Simple ecommerce and shopping cart written in Elm




Repository

https://github.com/lucamug/elm-ecommerce-cart-test

Installation

Clone the repo, run `npm install` and `npm run dev` and accept elm-package's prompt in the cli. Changes to your styles and elm modules under the `src` directory will auto-transpile to css and js respectively.

Based on https://github.com/xavierelopez/elm-cart-example

Wednesday, March 29, 2017

Elm flow in the console

Try this code if you want to see how elm behave in the console:
module Main exposing (..)
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onInput)
-- import Debug exposing (..)
main =
Html.beginnerProgram
{ model = model
, view = view
, update = update
}
-- MODEL
type alias Model =
{ name : String
, password : String
, passwordAgain : String
}
model : Model
model =
Model "" "" ""
-- UPDATE
type Msg
= Name String
| Password String
| PasswordAgain String
update : Msg -> Model -> Model
update msg model =
let
_ = Debug.log "msg" msg
_ = Debug.log "model before update" model
in
case msg of
Name name ->
{ model | name = name }
Password password ->
{ model | password = password }
PasswordAgain password ->
{ model | passwordAgain = password }
-- VIEW
view : Model -> Html Msg
view model =
let
_ = Debug.log "model to view" model
in
div []
[ input [ type_ "text", placeholder "Name", onInput Name ] []
, input [ type_ "password", placeholder "Password", onInput Password ] []
, input [ type_ "password", placeholder "Re-enter Password", onInput PasswordAgain ] []
, viewValidation model
]
viewValidation : Model -> Html msg
viewValidation model =
let
(color, message) =
if model.password == model.passwordAgain then
("green", "OK")
else
("red", "Passwords do not match!")
in
div [ style [("color", color)] ] [ text message ]
view raw main.elm hosted with ❤ by GitHub

Wednesday, March 15, 2017

Resources about elm, the programming language

Tuesday, January 24, 2017

Search Testing with React and Redux

I have been working on a Vanilla JS filter that you can find at http://www.rakuten.co.uk/?filter

I am considering about moving to React/Redux so I have made a quick test for the same functionality. I like the idea of one centralised status store. If interested you can find the test at https://github.com/lucamug/search-testing-react-redux

To install the test just clone the repo then run

$ git clone https://github.com/lucamug/search-testing-react-redux.git
$ cd search-testing-react-redux/
$ npm install
$ npm start

Then point the browser to http://localhost:3000/

The test is based on http://jpsierens.com/tutorial-react-redux-webpack/

Sunday, January 15, 2017

Functional Programming - Couple of Videos

Among several videos that I have been watching about functional programming, I found these two quite interesting and entertaining:


Tuesday, January 3, 2017

DEC64 - Douglas Crockford's Decimal Notation

Today, watching an old Douglas Crockford's video I was interested in his proposal of a new way of defining a new number type called DEC64.

Even though I have not enough understand of low level of storing numbers (I guess I studied this stuff at school) I tend to agree to Douglas's idea that application languages should have one numeric type and the type should not behave like:

0.1 + 0.2 === 0.3 // return false

Someone believe that Douglas proposal is not good enough. I believe that one on the goal of the proposal was also to start a discussion about this topic.

I wonder if after two years anybody has implemented this system somewhere.


Monday, January 2, 2017

Bilingual or multilingual blog on Google Blogger

Script to add a language button to set up a bilingual or multilingual blog on Google Blogger.

This way of adding other languages to google bolgger is inspired by http://www.broculos.net/2013/05/how-to-create-multilingual-blog-in.html

You can find a real blog example at http://www.girelloni.com/

Here the script: https://github.com/lucamug/bilingual-google-blogger