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:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ] |
Wednesday, March 15, 2017
Resources about elm, the programming language
- http://elm-lang.org/assets/blog/0.18/todomvc.html#/active todos with debugger
- http://elm-lang.org/blog Official elm blog
- http://elm-lang.org/blog/blazing-fast-html-round-two elm performances
- http://elm-lang.org/blog/farewell-to-frp Making signals unnecessary with The Elm Architecture
- http://elmprogramming.com/ Beginners elm guide
- http://elmrepl.cuberoot.in/ An online repl (Read–Eval–Print Loop) for elm
- http://faq.elm-community.org/ FAQ elm
- http://krisajenkins.github.io/elm-rays/ A raycasting hack in elm based on http://ncase.me/sight-and-light/
- http://ohanhi.com/base-for-game-elm-017.html Revisiting the "hard way": Base for a game in Elm 0.17
- http://vincent.jousse.org/en/tech/interacting-with-dom-element-using-elm-audio-video/
- https://auth0.com/blog/creating-your-first-elm-app-part-1/
- https://ellie-app.com/new Ellie is the Elm platform in your browser.
- https://gist.github.com/staltz/868e7e9bc2a7b8c1f754 The introduction to Reactive Programming you've been missing
- https://github.com/Bogdanp/elm-route/tree/4.0.0 elm-route
- https://github.com/evancz/elm-html-and-js This project illustrates how to embed an Elm program in an HTML page and how to communicate with JavaScript.
- https://github.com/sporto/elm-tutorial-app An example SPA in Elm
- https://guide.elm-lang.org/interop/javascript.html#customs-and-border-protection JavaScript Interop
- https://learnxinyminutes.com/docs/elm/
- https://mbylstra.github.io/html-to-elm/ Convert html to elm
- https://medium.com/@rgoomar/why-i-think-elm-is-the-future-of-front-end-development-21e9b091fa05#.nc4hzrmhn
- https://medium.com/the-ahead-story/move-fast-and-dont-break-things-running-a-startup-on-elm-b5491082fe8b#.yx8hr7utl
- https://www.elm-tutorial.org/en/ elm tutorial
- https://www.youtube.com/channel/UCOpGiN9AkczVjlpGDaBwQrQ elm-conf channel
- https://www.youtube.com/watch?v=EDp6UmaA9CM Toward a Better Front End Architecture: Elm - Codemash 2017
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/
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.
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
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
Subscribe to:
Posts
(
Atom
)