Skip to content

Instantly share code, notes, and snippets.

View mattnworb's full-sized avatar

Matt Brown mattnworb

View GitHub Profile
override def query(q: String) = {
val responses: Seq[Future[HttpResponse]] = clients.map {client => client.query(q)}
val allResponses: Future[Seq[HttpResponse]] = Future.collect(responses)
val successResponses: Future[Seq[HttpResponse]] = allResponses.map(responses => responses.filter(_.getStatus == HttpResponseStatus.OK))
successResponses.map { responses: Seq[HttpResponse] =>
if (responses.isEmpty) {
errorResponse(HttpResponseStatus.INTERNAL_SERVER_ERROR, "No successful responses")
@mattnworb
mattnworb / Vagrantfile
Created April 7, 2014 19:04
Sample Vagrantfile to run MySQL on a centos vm
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# downloads a CentOS 6.5 base image for the VM from https://vagrantcloud.com/chef/centos-6.5
# although the box is from the people that make Chef, we use Ansible below for provisioning the VM
config.vm.box = "chef/centos-6.5"
public class GenericsTest {
public void doesNotCompile() {
Container<String> container = new Container<String>();
assertThat(container, hasSomethingWhich(is("foo")));
}
public static class Container<T> {
/**
* Testing claims made in
* http://stackoverflow.com/questions/4346521/what-are-the
* -dangers-in-upgrading-to-java-1-5-and-beyond/4346599#4346599
*
* @date Dec 3, 2010
*/
public class ClassLoadingTest {
screen -t 'errors' tail -F current.log | grep -A 3 "ERROR"
@mattnworb
mattnworb / original .screenrc
Created April 14, 2011 16:54
Old .screenrc file
# window 1
chdir /home/matt/code/project/logs
screen -t 'logs'
# window 2
chdir /home/matt/code/project/logs
screen -t 'errors'
# window 3
chdir /home/matt/code/project
screen -t 'logs' tail -F current.log
@mattnworb
mattnworb / final .screenrc
Created April 14, 2011 16:56
final product
screen -t 'errors'
stuff 'tail -F /var/ec/current.log | grep -A 3 "ERROR"^M'
/**
* Code sample for http://stackoverflow.com/questions/5877226/better-way-to-check-if-a-joda-time-interval-spans-exactly-1-calendar-week-accoun
* @author: matt b
* @since: 5/4/11
*/
public class JodaTimeWeekPeriodTest {
public static void main(String[] args) {
DateTime start = new DateTime(2011, 5, 4, 0, 0, 0, 0);
@mattnworb
mattnworb / gist:1405216
Created November 29, 2011 15:38
error in Octave using mean on binary vector
octave-3.4.0:1> a = [ 1 2 3 4]
a =
1 2 3 4
octave-3.4.0:2> mean(a)
ans = 2.5000
octave-3.4.0:3> b = (a == 2)
b =