start new:
tmux
start new with session name:
tmux new -s myname
| -- Example haskell binder | |
| -- David Nguyen, Nov 2016 | |
| -- | |
| -- This module for illustration purpose only | |
| module BinderExample | |
| where | |
| import Prelude hiding (pi) |
| articles = [ | |
| { | |
| 'id': 1111, | |
| 'contexts': [ | |
| { | |
| 'name': 'Football', | |
| 'weight': 80 | |
| }, | |
| { | |
| 'name': 'Counting', |
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'.
| /** | |
| * 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 | |
| */ |
(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.
| // Routes | |
| api := router.Group("/api/v1") | |
| { | |
| api.POST("/card", func(c *gin.Context) { | |
| // Gather data from post form | |
| var poem Poem | |
| c.BindJSON(&poem) | |
| // Read image | |
| im, err := gg.LoadImage("frames/f1.png") |
| // model | |
| type Poem struct { | |
| Title string `json:"title" binding:"required"` | |
| Body []string `json:"body" binding:"required"` | |
| Author string `json:"author" binding:"required"` | |
| } |
| // Use middleware to serve static | |
| router.Use(static.Serve("/", static.LocalFile("./frontend/dist", true))) | |
| router.Use(static.Serve("/download", static.LocalFile("./output", true))) |
| import { Component, OnInit } from '@angular/core'; | |
| import {Router} from '@angular/router'; | |
| import {Poem} from '../shared/poem'; | |
| import {PoemService} from '../shared/poem.service'; | |
| @Component({ | |
| selector: 'app-home', | |
| templateUrl: './home.component.html', | |
| styleUrls: ['./home.component.css'] |