Skip to content

Instantly share code, notes, and snippets.

object Main {
def main(args: Array[String]) {
val date = new Deserializer().deserialize[java.util.Date]("2014-02-15")
val ints = new Deserializer().deserialize2[Int]("[1, 2, 3]")
}
}
class Deserializer {
import scala.reflect.{ ClassTag, Manifest }
@arkadijs
arkadijs / params.rb
Created February 20, 2014 10:43
How to write this nicely?
def f(params)
puts params
end
opt = {}
opt[:config] = 1
f (:p1 => 'x', :p2 => ( [{ :r => 'const', :t => opt[:config] }] if opt[:config] ))
# {:p1=>"x", :p2=>[{:r=>"const", :t=>1}]}
@arkadijs
arkadijs / _README.md
Last active August 29, 2015 13:57
Hackathon: Write your own dynamic language today - with PyPy http://ldn.lv/events/141429062 http://goo.gl/rdS0dz

PyPy environment

Download and build PyPy as described here. It will take about 1 hour of modern machine time. The pre-built PyPy archive does not have all the stuff we need.

Instead, I supply you with a powerful Linux VM in case you choose to work in the cloud:

$ ssh hacker01@pypy-workshop.hosting.lv

pypy binary is in your PATH. And PYPY env var is also set to the path of unpacked and already built PyPy sources.

java ee (v1.4, and partly 5) cf / bosh
(proprietary) deployment descriptor bosh manifest
xml yaml
ear(-s) bosh release
ee app server, "fits all purposes" cloudfoundry elastic runtime
transparent clustering, availability multi-az deployment, resurrector
statefull stateless

j2ee ship sunk ~9 years ago.

@arkadijs
arkadijs / compute.groovy
Last active August 29, 2015 14:05
Authentication to Google Compute Engine example
// compile 'com.github.groovy-wslite:groovy-wslite:1.1.0'
// compile 'com.google.apis:google-api-services-compute:v1-rev29-1.19.0'
// compile 'com.google.http-client:google-http-client-jackson2:1.19.0'
// compile 'com.google.oauth-client:google-oauth-client-jetty:1.19.0'
import com.google.api.services.compute.Compute
import com.google.api.services.compute.model.*
import wslite.rest.ContentType
import wslite.http.HTTPClient
import wslite.rest.RESTClient

Docker

Docker-enabled environment

Cloud

ssh -i workshop.pem ubuntu@lxc-1-01.eu.r53.acp.io

Replace 01 in lxc-1-01 with index assigned to you. Download workshop key below.

@arkadijs
arkadijs / sse.scala
Last active August 29, 2015 14:09
Server-sent events in Play2 / Iteratee for Hystrix console
import play.api.libs.concurrent._
import play.api.libs.concurrent.Execution.Implicits._
import play.api.libs.iteratee._
import scala.concurrent.duration._
def circuitBreakers = Action {
Ok.stream(Enumerator.generateM {
val promise = Promise[String]()
Akka.system.scheduler.scheduleOnce(1 second) {
promise.completeWith(circuitBreakers)
@arkadijs
arkadijs / _README.md
Last active August 29, 2015 14:09
Global Day of Coderetreat 2014, Riga, Latvia http://ldn.lv/events/209047582
@arkadijs
arkadijs / pypy-bootstrap.sh
Created November 23, 2014 20:29
PyPy bootstrap from sources on Debian
#!/bin/sh
sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get install -y \
gcc g++ make python-dev libffi-dev libsqlite3-dev pkg-config \
libz-dev libbz2-dev libncurses-dev libexpat1-dev \
libssl-dev libgc-dev python-sphinx python-greenlet \
time less htop bzip2 unzip zip git mercurial nano rsync vim
sudo apt-get clean
wget https://bitbucket.org/pypy/pypy/downloads/pypy-2.2.1-src.tar.bz2
def zookeeper: Future[Map[String, String]] = async {
val writeback = ZooKeeper.WritebackPathPrefix.split("/").filterNot(_.isEmpty).toSeq
def join(l: Seq[String]) = l.mkString("/")
def nodes(parent: Seq[String], node: String): Seq[Seq[String]] = {
(parent :+ node) match {
case `writeback` => Seq()
case path => path +: ZooKeeper.getChildren(join(path)).flatMap(node => nodes(path, node))
}
}
nodes(Seq(), services.ZooKeeperService.BasePath.stripPrefix("/"))