(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
| /** | |
| * net/http has two major components for processing HTTP request: | |
| * 1. ServerMux: is a multiplexor (or simply an HTTP request router) that compares incoming HTTP requests against | |
| * a list of predefined URI resources and then calls the associated handler for the resource requested by HTTP client. | |
| * 2. Handler: The ServerMux provided a multiplexor and calls corresponding handlers for HTTP requests. Handlers are | |
| * responsible for writing response headers and response bodies. In Go, any object can become a handler by implement | |
| * http.Handler interface (to implement an interface, we must implement all methods in the list methods signature | |
| * defined in the interface, here http.Handler interface has only one ServeHTTP method). | |
| * There are some ways to do it as below | |
| */ |
In this demonstration I will show you how to read data in Angular2 final release before application startup. You can use it to read configuration files like you do in other languages like Java, Python, Ruby, Php.
This is how the demonstration will load data:
a) It will read an env file named 'env.json'. This file indicates what is the current working environment. Options are: 'production' and 'development';
b) It will read a config JSON file based on what is found in env file. If env is "production", the file is 'config.production.json'. If env is "development", the file is 'config.development.json'.
| articles = [ | |
| { | |
| 'id': 1111, | |
| 'contexts': [ | |
| { | |
| 'name': 'Football', | |
| 'weight': 80 | |
| }, | |
| { | |
| 'name': 'Counting', |
| -- Example haskell binder | |
| -- David Nguyen, Nov 2016 | |
| -- | |
| -- This module for illustration purpose only | |
| module BinderExample | |
| where | |
| import Prelude hiding (pi) |
| -- define max function accept two number and return greater number | |
| max :: Ord a => a -> a -> a | |
| -- single line function equation | |
| max x y = if x >= y then x else y | |
| -- multiple line function equation (Guard style -> this is idiomatic haskell) | |
| max x y | x >= y = x | |
| | otherwise = y | |
| -- signum function (Ord a, Num a) meant type variable a can belong both type class Ord and Num | |
| signum :: (Ord a, Num a) => a -> Int |
| -- Example module in haskell | |
| -- Mr ABC, Sept 2016 | |
| -- | |
| -- Define a simple module | |
| module Simple | |
| where | |
| -- calculates the arithmetic of two numbers | |
| arithmetic :: Fractional a => a -> a -> a | |
| arithmetic x y = (x + y) / 2 |
| -- define function type signature | |
| inc :: Inc -> Inc | |
| -- define function equation | |
| inc x = x + 1 |