Skip to content

Instantly share code, notes, and snippets.

@bolerap
bolerap / introrx.md
Created April 12, 2017 13:51 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
@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
*/

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 / 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
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
@bolerap
bolerap / bobp-python.md
Created November 18, 2016 03:25 — forked from sloria/bobp-python.md
A "Best of the Best Practices" (BOBP) guide to developing in Python.

The Best of the Best Practices (BOBP) Guide for Python

A "Best of the Best Practices" (BOBP) guide to developing in Python.

In General

Values

  • "Build tools for others that you want to be built for you." - Kenneth Reitz
  • "Simplicity is alway better than functionality." - Pieter Hintjens
-- define function type signature
inc :: Inc -> Inc
-- define function equation
inc x = x + 1