Skip to content

Instantly share code, notes, and snippets.

View chbatey's full-sized avatar
🐯
WFH

Christopher Batey chbatey

🐯
WFH
View GitHub Profile
echo "Checking if the commit is already tagged"
if ! git describe --tag --exact-match 2>&1 | grep "fatal";
then
echo "Commit is already tagged"
exit 0
fi
echo "Getting previous tag"
CURRENT_TAG=$$(git describe --tag --abbrev=0)
if [ "$${CURRENT_TAG}" = "" ]
then
@chbatey
chbatey / ExampleWebAppSpecification.groovy
Created February 14, 2014 02:25
Spock: Testing a web application
class ExampleWebAppSpecification extends Specification {
def "Should return 200 & a message with the input appended"() {
setup:
def primerEndpoint = new RESTClient( 'http://localhost:8080/' )
when:
def resp = primerEndpoint.get([ path: 'exampleendpoint', query : [ input : 'Get a hair cut' ]])
then:
with(resp) {
status == 200
contentType == "application/json"
public static <T> void mockIterable(Iterable<T> iterable, T... values) {
Iterator<T> mockIterator = mock(Iterator.class);
when(iterable.iterator()).thenReturn(mockIterator);
if (values.length == 0) {
when(mockIterator.hasNext()).thenReturn(false);
return;
} else if (values.length == 1) {
when(mockIterator.hasNext()).thenReturn(true, false);
when(mockIterator.next()).thenReturn(values[0]);
import akka.actor.{ ActorSystem, PoisonPill }
import akka.util.Timeout
import com.datastax.driver.core.Cluster
import com.typesafe.config.ConfigFactory
import scala.concurrent.duration._
import scala.collection.JavaConverters._
import scala.io.StdIn
object Sandbox extends App {

Keybase proof

I hereby claim:

  • I am chbatey on github.
  • I am chbatey (https://keybase.io/chbatey) on keybase.
  • I have a public key ASC3wj_BGvnrpWZ5ueAiB23oZwUwS3j8ryBhBgZznakvGgo

To claim this, I am signing this object:

CREATE OR REPLACE FUNCTION state_group_and_count( state map<text, int>, type text )
CALLED ON NULL INPUT
RETURNS map<text, int>
LANGUAGE java AS '
Integer count = (Integer) state.get(type); if (count == null) count = 1; else count++; state.put(type, count); return state; ' ;
CREATE OR REPLACE AGGREGATE group_and_count(text)
SFUNC state_group_and_count
STYPE map<text, int>
INITCOND {};
chbatey@desktop:~$ cd /opt/spark/bin/
chbatey@desktop:/opt/spark/bin$ ./spark-shell --help
Usage: ./bin/spark-shell [options]
Spark assembly has been built with Hive, including Datanucleus jars on classpath
Options:
--master MASTER_URL spark://host:port, mesos://host:port, yarn, or local.
--deploy-mode DEPLOY_MODE Whether to launch the driver program locally ("client") or
on one of the worker machines inside the cluster ("cluster")
(Default: client).
--class CLASS_NAME Your application's main class (for Java / Scala apps).
package info.batey.akka.http
import akka.actor.Scheduler
import akka.actor.testkit.typed.scaladsl.TestProbe
import akka.actor.typed.ActorRef
import akka.actor.typed.scaladsl.AskPattern._
import akka.http.scaladsl.server.Directives._
import akka.http.scaladsl.testkit.ScalatestRouteTest
import akka.util.Timeout
import info.batey.akka.http.RouteUnderTest.Ping
CREATE FUNCTION state_group_and_total( state map<text, int>, type text, amount int )
CALLED ON NULL INPUT
RETURNS map<text, int>
LANGUAGE java AS '
Integer count = (Integer) state.get(type); if (count == null) count = amount; else count = count + amount; state.put(type, count); return state; ' ;
CREATE OR REPLACE AGGREGATE group_and_total(text, int)
SFUNC state_group_and_total
STYPE map<text, int>
package info.batey.akka.persistence
import akka.actor.{ActorSystem, Props}
import akka.persistence.PersistentActor
import info.batey.akka.persistence.AutomaticPersist.RealPersistentActor.{PrintName, SayName}
object AutomaticPersist extends App {
trait PersistMe