Skip to content

Instantly share code, notes, and snippets.

@bobpace
bobpace / ExampleTests.cs
Last active January 3, 2016 05:19
Testing Rx Observables
[TestFixture]
public class ExampleTests : InteractionContext<Example>
{
private List<string> _inputs;
private TestSchedulers _schedulerProvider;
[SetUp]
public void Setup()
{
_inputs = new List<string>
@bobpace
bobpace / prime-stream.scala
Last active January 2, 2016 18:59
streams
lazy val primes: Stream[Int] =
2 #:: Stream.from(3).filter(n => primes.takeWhile(p => p * p <= n).forall(p => n % p > 0))
lazy val fib: Stream[BigInt] = 0 #:: 1 #:: fib.zip(fib.tail).map { case(x,y) => x + y }
@bobpace
bobpace / fizzbuzz.scala
Last active January 2, 2016 18:59
fizzBuzzer in scala
def fizzBuzzer(entries: Map[Int, String])(nums: Seq[Int]) = {
def fizzBuzzify(n: Int) =
(n, entries collect { case (key, value) if n % key == 0 => value })
nums map fizzBuzzify collect {
case (num, words) if !words.isEmpty => num + ": " + words.mkString(" ")
}
}
val answer = fizzBuzzer(Map(3 -> "fizz", 5 -> "buzz"))(0 to 100)
@bobpace
bobpace / checkForTickets
Created April 27, 2013 17:39
Script to check blizzcon ticket site until tickets are available.
#!/bin/ruby
require 'open-uri'
url = "http://us.blizzard.com/store/blizzcon-tickets.xml"
ticketsAvailable = false
begin
contents = open(url).read
unless contents =~ /Currently unavailable/
`start #{url}`