This file contains hidden or 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
| /* | |
| * A typed, purely functional, sequential state machine modeling a cake | |
| * | |
| * The cake has these states | |
| * | |
| * Started => Poured => Mixed => Baked | |
| * | |
| * Shows how to deal with state functionally and how impossible operations | |
| * are compile time errors rather than runtime errors. | |
| * |
This file contains hidden or 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
| import numpy.random as npr | |
| SIZE=3030 | |
| LOOPS=1000000 | |
| TIE=SIZE/2 | |
| ties=0 | |
| for i in range(1, LOOPS): | |
| p = npr.random() |
This file contains hidden or 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
| Modeling a binomial process with the beta binomial | |
| Case 1: You have no information | |
| This requires using a non-informative prior for the beta distribution. Normally this is done | |
| with a uniform prior for all values of p, which corresponds to alpha = beta = 1. | |
| Case 2: You have some prior information in terms of the mean and variance of p | |
| You calculate alpha and beta, like in this post: http://stats.stackexchange.com/questions/12232/calculating-the-parameters-of-a-beta-distribution-using-the-mean-and-variance |
This file contains hidden or 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
| Sparked by recent event in politics a lot of debate and controversy has occurred on the spanish blogosphere | |
| around a seemingly simple question of probability: | |
| What is the probability that a Yes/No election with 3030 voters results in a tie? | |
| Before suggesting answers, let me make it clear that the main controversy has ocurred | |
| when trying to answer this question in its barest form, without any additional | |
| information besides its simplest formulation above, _plus_ a binomial model for | |
| voter choices. |
This file contains hidden or 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
| length mismatch for ip 212.8.74.234 | |
| ([148993L, 149003L, 149099L], ['28c740f48d6ee8f065c3904137ab00748155992ce9abb1baffa7568bfae074f2', 'd2da4a8a2740a45f1c57bbc54a3d33d71e3bc515725a6fc2ee9118854b828cd2']) | |
| length mismatch for ip 82.116.160.50 | |
| ([148329L, 148475L, 149693L, 149765L, 149778L], ['2e8c92a28103273b94d961a73ac8bf067dff4e6549274d103347807ef7a0de48', '68e611796ba83de1f2cae38fb067afecff44b0930f63bf2537dbb387f1a562f6', '9e683b11b857b7bf1d4e4fbc88d1fee8f8a87c29b3711bc2176d1f1b4eee9397', 'ad3c500a911fa13dc3640c7c41e1adaa08ea71654f490d54b7c65d5fd3a8bae7']) | |
| Ip not in database 85.60.60.155 | |
| length mismatch for ip 82.116.165.84 | |
| ([148121L, 148310L, 148322L, 149515L, 149520L], ['dc6910616a56cf57b779b8de4104183265271dae269fac3fa981ed3542ec6852', '666dbec4c768f33840b1ff1a7b868487d98e0af582fbd802c8547153e106862b', '78883c91f6180f79a4bc7d6ca0680f87387af113301d00d910d21bc3a599c73e', '78883c91f6180f79a4bc7d6ca0680f87387af113301d00d910d21bc3a599c73e']) | |
| length mismatch for ip 213.98.84.22 | |
| ([148363L, 148376L, 148384L], ['ba |
This file contains hidden or 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
| machine bb_orchestrator_machine sees bb_orchestrator_context | |
| variables config config_signatures shares shares_signatures public_key public_key_signatures | |
| vote_started votes mixes mixes_signatures decryptions decryptions_signatures | |
| plaintext plaintext_signatures process_end | |
| invariants | |
| @inv0 config ∈ BOOL @inv1 config_signatures ∈ ℙ(1 ‥ privacy_level) | |
| @inv2 shares ∈ ℙ(1 ‥ privacy_level) @inv3 shares_signatures ∈ ℙ(1 ‥ privacy_level) | |
| @inv4 public_key ∈ BOOL @inv5 public_key_signatures ∈ ℙ(1 ‥ privacy_level) |
This file contains hidden or 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
| object E extends App { | |
| println(E(args(0).toInt, 1)) | |
| def E(vars: Int, minVar: Int) : String = { | |
| if(vars == 1) { | |
| "T" | |
| } | |
| else if(vars == 2) { | |
| s"!(a$minVar && a${minVar + 1})" | |
| } |
This file contains hidden or 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
| import java.io.File | |
| import akka.actor.ActorSystem | |
| import akka.stream.ActorMaterializer | |
| import play.api.libs.ws.WSClient | |
| import play.api.libs.ws.WSConfigParser | |
| import scala.concurrent.Future | |
| import scala.util.{Success, Failure} | |
| import play.api.{Environment, Mode} | |
| import play.api.Configuration |
This file contains hidden or 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
| play.ws.ssl { | |
| trustManager = { | |
| stores = [ | |
| { type = "PEM", path = "server.crt" } | |
| ] | |
| } | |
| keyManager = { | |
| stores = [ | |
| { type="PKCS12", path="client.p12", password="client" } | |
| ] |
This file contains hidden or 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
| /* | |
| * | |
| * Copyright (c) 1994, 2004, Oracle and/or its affiliates. All rights reserved. | |
| * | |
| * Redistribution and use in source and binary forms, with or | |
| * without modification, are permitted provided that the following | |
| * conditions are met: | |
| * | |
| * -Redistribution of source code must retain the above copyright | |
| * notice, this list of conditions and the following disclaimer. |