(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.
| package com.firebase.client; | |
| import com.firebase.client.core.Constants; | |
| import rx.Observable; | |
| import rx.Subscriber; | |
| import rx.functions.Action0; | |
| import rx.functions.Func1; | |
| import rx.subscriptions.Subscriptions; | |
| public class RxFirebase { |
| import com.sun.net.httpserver.HttpExchange; | |
| import com.sun.net.httpserver.HttpServer; | |
| import java.io.IOException; | |
| import java.net.InetSocketAddress; | |
| public class WebMain { | |
| public static void main(String[] args) throws IOException { | |
| WebServer.serve(8080, "/").withRoute( |
| object Money { | |
| // Equation: x = 1*foo + 7*bar + 11*qix + 21*bar | |
| val FOO = 1; val BAR = 7; val QIX = 11; val BAZ = 21; | |
| def change(cents: Int): List[Map[String, Int]] = { | |
| lazy val tuple = for ( | |
| foo <- 0 to cents; bar <- 0 to (cents - FOO * foo) / BAR; | |
| qix <- 0 to (cents - FOO * foo - BAR * bar) / QIX; | |
| baz <- 0 to (cents - FOO * foo - BAR * bar - QIX * qix) / BAZ | |
| ) yield (foo, bar, qix, baz) | |
| Stream(tuple: _*) |
"For comprehension" is a another syntaxe to use map, flatMap and withFilter (or filter) methods.
yield keyword is used to aggregate values in the resulting structure.
This composition can be used on any type implementing this methods, like List, Option, Try, Future...
| Copyright (c) 2015 - Xavier Cambar <@ xcambar_gmail.com> | |
| Permission is hereby granted, free of charge, to any person obtaining a copy | |
| of this software and associated documentation files (the "Software"), to deal | |
| in the Software without restriction, including without limitation the rights | |
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| copies of the Software, and to permit persons to whom the Software is | |
| furnished to do so, subject to the following conditions: | |
| The above copyright notice and this permission notice shall be included in |
#Play2 : Les Iteratees expliqués aux humains... francophones!
Disclaimer : Ce qui suit est la traduction d'un article anglophone paru sur le blog mandubian.com
Vous pouvez retrouver l'article original ici
Vous avez probablement remarqué une nouvelle fonctionnalité intrigante de Play2 nommée Iteratee (ainsi que ses compagnons Enumerators et Enumeratee).
Le but de cet article est d'essayer de rendre le concept d'Iteratee compréhensible pour le plus grand nombre avec des arguments simples, en évitant l'approche mathématique / fonctionnelle.
Cet article ne prétend pas tout expliquer à propos des Iteratee / Enumerator / Enumeratee mais traite plutôt les idées qui se cachent derrière.
| // Source: https://groups.google.com/forum/#!topic/angular/hVrkvaHGOfc | |
| // jsFiddle: http://jsfiddle.net/pkozlowski_opensource/PxdSP/14/ | |
| // author: Pawel Kozlowski | |
| var myApp = angular.module('myApp', []); | |
| //service style, probably the simplest one | |
| myApp.service('helloWorldFromService', function() { | |
| this.sayHello = function() { | |
| return "Hello, World!" |
Handlebars.js is a template framework for Javascript environments. It allows the construction of HTML elements using HTML and expressions wrapped in {{ }}
One of the conditional block helpers Handlebars offers is the {{#if}}.
For example:
<div class="entry">| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <title>Multicelldesign CSS Ribbon</title> | |
| <!-- Don't forget to add an HTML5 polyfill for IE --> | |
| </head> | |
| <body> | |
| <div class="wrapper"> | |
| <nav role="navigation" aria-label="main menu"> |