Skip to content

Instantly share code, notes, and snippets.

scala> val Title = """(Mrs?).*""".r
Title: scala.util.matching.Regex = (Mrs?).*
scala> "Mr. Belvedere" match {
| case Title(title) => println("hey there " + title)
| case _ => println("who are you?");
| }
hey there Mr
scala> val TitleName = """(Mrs?)(.*)""".r
/* Stack a red cross on top of a white circle to make a marker for hospital points */
* {
mark: symbol(circle), symbol(cross);
}
:nth-mark(1) {
fill: white;
stroke: red;
}
* { fill: blue, symbol('shape://slash'); }
:fill { stroke: red; }
object Combine {
def linear[A](xs: Seq[A]): Seq[Seq[A]] =
xs match {
case Seq() => Seq(Seq())
case Seq(h, t @ _*) =>
linear(t) flatMap { ts => Seq(ts, h +: ts) }
}
def binary[A](xs: Seq[A]): Seq[Seq[A]] =
xs match {
from django.contrib.gis.geos import GEOSGeometry
import json
import sys
bluemarble = r"""{
"fields": {
"fixed": true,
"format": null,
"group": "background",
"layer_params": "{\"args\": [\"bluemarble\", \"http://maps.opengeo.org/geowebcache/service/wms\", {\"layers\": [\"bluemarble\"], \"tiled\": true, \"tilesOrigin\": [-20037508.34, -20037508.34], \"format\": \"image/png\"}, {\"buffer\": 0}], \"type\": \"OpenLayers.Layer.WMS\"}",
[type='store'] {
mark: url("http://example.com/storefront.jpeg");
}
[type='restaurant'] {
mark: url("http://example.com/restaurant.jpeg");
}
* {
label: [strtouppercase(TITLE)];
}
* {
stroke: black, symbol(circle);
stroke-width: 15px;
stroke-linejoin: round;
stroke-linecap: round;
stroke-dasharray: 1 0, 5 35;
stroke-dashoffset: 0;
z-index: 0, 10;
}
def rle[A](as: Seq[A]): Seq[(Int, A)] = as match {
case Seq() => Seq()
case Seq(a, as @ _*) => (1 + as.takeWhile(a ==).length, a) +: rle(as.dropWhile(a ==))
}
rle("AAABBCCCDDDDE") map { case (i, c) => i.toString + c } mkString
public class Sample {
static class A {
private String foo;
private Integer bar
public A(String foo, Integer bar) {
this.foo = foo;
this.bar = bar;
}
}