This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This playbook installs and configure corosync and pacemaker on a set of nodes part of a given group. | |
--- | |
# See the file /etc/ansible/hosts where the group is actually defined. There might be a way to define groups in a file 'closer' to this playbook. | |
- hosts: clusternodes | |
vars: | |
mcastport : 5405 | |
tasks: | |
# It would be better to use Ansible to change the IP tables config to allow corosync/pacemaker on the nodes part of the cluster. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- name: Downloading and enable the EPEL repository definitions. | |
action: command rpm -Uvh --replacepkgs http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val n = 40 | |
// Measure in milliseconds how long it takes to compute a Fibonacci sequence. | |
timeThis(msecs){ | |
println ("Naive recursion fib of " + n + ": " + fib(n)) | |
} | |
// Measure in nanoseconds how long it takes to compute a Fibonacci sequence. | |
timeThis(nanosecs){ | |
println ("Tail recursion fib of " + n + ": " + fib2(n)) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Naive recursion fib of 40: 102334155 | |
It took 9911 msecs to execute the operation. | |
Tail recursion fib of 40: 102334155 | |
It took 151000 nanosecs to execute the operation. | |
I am going to sleep... | |
Nice to wake up | |
It took 1000 msecs to execute the operation. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait TimeUnit | |
case object msecs extends TimeUnit | |
case object nanosecs extends TimeUnit | |
object Watch{ | |
/* A hashmap to map a time unit to a tuple containing: | |
* - a description of the time unit in english. | |
* - a function invoked to measure the time in the given unit | |
*/ | |
val timeUnits = Map[TimeUnit,Tuple2[String,() => Long]] ( | |
msecs -> ("msecs",System.currentTimeMillis _), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.kafecho.learning.akka | |
import java.net.InetSocketAddress | |
import akka.actor.Actor | |
import akka.actor.ActorLogging | |
import akka.actor.ActorSystem | |
import akka.actor.Props | |
import akka.actor.actorRef2Scala | |
import akka.io.IO | |
import akka.io.UdpFF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.kafecho.learning.akka | |
import akka.util.ByteString | |
import org.slf4j.LoggerFactory | |
object Timer{ | |
def timeThis[T](fn : => T) : T = { | |
val start = System.currentTimeMillis() | |
val t = fn | |
val stop = System.currentTimeMillis() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.kafecho.learning.midi | |
import javax.sound.midi.MidiSystem | |
import javax.sound.midi.ShortMessage | |
import scala.util.Random | |
object MidiTest extends App { | |
val rcvr = MidiSystem.getReceiver | |
while (true) { | |
val myMsg = new ShortMessage | |
myMsg.setMessage(ShortMessage.NOTE_ON, 8, Random.nextInt.abs % 127, 93) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.kafecho.learning.monad | |
import java.util.UUID | |
/** My attempt at implementing the Reader Monad concept. | |
* The Reader Monad encapsulates a computation which: | |
* - requires a dependency of type D | |
* - produces values of type A. | |
*/ | |
case class Reader[D, A](computation: D => A) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- hosts: cd-servers | |
gather_facts: no | |
sudo: true | |
user: deploy | |
tasks: | |
- name: Install Couchdb dependencies | |
yum: name={{ item }} state=installed | |
with_items: | |
- autoconf |
OlderNewer