Skip to content

Instantly share code, notes, and snippets.

@arturaz
arturaz / Capfile
Created December 5, 2012 15:32
Deploying Play application with capistrano
load 'deploy'
# Uncomment if you are using Rails' asset pipeline
# load 'deploy/assets'
Dir['vendor/gems/*/recipes/*.rb','vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }
load 'deploy/config'
scalaVersion := "2.10.0",
//scalaVersion in Test := "2.10.0",
scalaBinaryVersion := "2.10",
scalacOptions := Seq("-deprecation", "-unchecked", "-feature"),
resolvers := Seq(
// For scala-io & Akka dependencies.
"Typesafe" at "http://repo.typesafe.com/typesafe/releases/"
),
libraryDependencies := Seq(
// Java libraries
package com.wierd
import org.openqa.selenium
import org.scalatest.selenium.Firefox
object FFTest extends Firefox {
def main(args: Array[String]): Unit = {
webDriver.manage.window.setSize(new selenium.Dimension(1200, 800))
@arturaz
arturaz / json.scala
Last active December 14, 2015 00:38
object Model {
trait Mutation[A]{
val doc: A
}
case class Upsert[A](doc: A) extends Mutation[A]
case class Delete[A](doc: A) extends Mutation[A]
// Json format
@arturaz
arturaz / gist:5007515
Created February 21, 2013 19:41
Serialising case class with Either to JSON in play framework 2.1 scala
package models
import play.api.libs.json._
import play.api.libs.json.Json._
import play.api.libs.functional.syntax._
import org.apache.commons.codec.binary.Base64
/**
* Created with IntelliJ IDEA.
* User: arturas
case class ViewRow[K, V, D](id: String, key: K, value: V, doc: Option[D])
def viewRowFormat[K : Format, V : Format, D : Format] = (
(__ \ 'id).format[String] ~
(__ \ 'key).format[K] ~
(__ \ 'value).format[V] ~
(__ \ 'doc).formatNullable[D]
).apply(ViewRow.apply, unlift(ViewRow.unapply[K, V, D]))
@arturaz
arturaz / ubuntu-install-java7.yml
Last active December 15, 2015 10:09
Ansible task file for installing java7 on ubuntu.
---
- name: ensuring add-apt-repository is installed
apt: pkg=python-software-properties state=latest
- name: adding webupd8 ppa for java7 installer
apt_repository: repo=ppa:webupd8team/java
- name: updating apt cache
apt: update_cache=yes
@arturaz
arturaz / gist:6112400
Created July 30, 2013 12:13
Scala project preparation for dist archive
val chiShape = RootProject(file("vendor/chi-shape"))
val kdTree = RootProject(file("vendor/kdtree"))
val messaging = RootProject(file("vendor/messaging"))
val datadog = RootProject(file("vendor/datadog-metrics-client"))
val logbackLayout = RootProject(file("vendor/logback-layout"))
dist <<= (
dist,
packageBin in Compile in chiShape,
using System;
using UnityEngine;
namespace com.tinylabproductions.u3d_gps_bridge {
public class ConnectionCallbacks : AndroidJavaProxy {
public ConnectionCallbacks() :
base("com.tinylabproductions.u3d_gps_bridge.ConnectionCallbacks")
{}
public Action OnConnected = delegate {};
using System;
using UnityEngine;
class TestCallback {
public static AndroidJavaObject apply<T1, T2>(Action<T1, T2> action) {
var cb = new AndroidJavaObject("TestCallback");
cb.Call("setRunnable", new AndroidJavaRunnable(() => {
var p1 = cb.Call<T1>("getParam1");
var p2 = cb.Call<T2>("getParam2");
action.Invoke(p1, p2);