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
#!/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}` |
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
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) |
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
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 } |
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
[TestFixture] | |
public class ExampleTests : InteractionContext<Example> | |
{ | |
private List<string> _inputs; | |
private TestSchedulers _schedulerProvider; | |
[SetUp] | |
public void Setup() | |
{ | |
_inputs = new List<string> |
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
var Rx = require('rx'); | |
var _ = require('lodash'); | |
module.exports = function(minSeconds, maxSeconds) { | |
if (minSeconds >= maxSeconds) { | |
throw new Error('min needs to be less than max'); | |
} | |
var getDueTime = () => _.random(minSeconds, maxSeconds) * 1000; |
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
var React = require('react'); | |
var Input = require('react-bootstrap/src/Input'); | |
var Glyphicon = require('react-bootstrap/src/Glyphicon'); | |
var _ = require('lodash'); | |
var Rx = require('rx'); | |
var canUseDom = require('can-use-dom'); | |
var changeCase = require('change-case'); | |
function events(event) { | |
return canUseDom ? Rx.Observable.fromEvent(document, event) : Rx.Observable.empty; |
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
var React = require('react'); | |
var Input = require('react-bootstrap/src/Input'); | |
var DropdownButton = require('react-bootstrap/src/DropdownButton'); | |
var _ = require('lodash'); | |
var escape = /[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g; | |
function escapeRegExp(str) { | |
return str.replace(escape, "\\$&"); | |
}; |
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
module.exports = function eventStream() { | |
return function *(next) { | |
this.req.setTimeout(0); //no timeout | |
this.type ='text/event-stream; charset=utf-8'; | |
this.set('Cache-Control', 'no-cache'); | |
this.set('Connection', 'keep-alive'); | |
this.set('Transfer-Encoding', 'chunked'); | |
yield* next; | |
} |
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
var spawn = require('child_process').spawn; | |
var eventStream = require('./event-stream'); | |
var compose = require('koa-compose'); | |
//get username / password from somewhere | |
var username = ...; | |
var password = ...; | |
var credential = username + ':' + password; | |
//8 hour timeout |
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
var _ = require('lodash'); | |
module.exports.apply = function lodashFlatMapMixin() { | |
function flatMap (array, selector) { | |
return [].concat.apply([], array.map(selector)); | |
}; | |
_.mixin({flatMap: flatMap}, {chain: true}); |
OlderNewer