Skip to content

Instantly share code, notes, and snippets.

-- 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',
@bolerap
bolerap / tmux-cheatsheet.markdown
Created February 20, 2017 03:09 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname

Reading data before application startup in Angular 2

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'.

@bolerap
bolerap / http.go
Created March 17, 2017 03:26
Dive into net/http in golang
/**
* 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
*/
@bolerap
bolerap / introrx.md
Created April 12, 2017 13:51 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
// 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']