Skip to content

Instantly share code, notes, and snippets.

class Foo {
var bar: String = ""
}
val instance = new Foo
locally {
import instance._
bar = "Special value"
}
trait MySelf[A <: MySelf[_]] {
def me: A
}
class Me extends MySelf[Me] {
def me: Me = this
}
class I extends MySelf[I] {
def me: I = this
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.Serializable;
import java.net.URL;
import java.util.HashMap;
import javax.imageio.ImageIO;
$ git checkout master
$ git merge feature_branch
$ git checkout synth
$ git merge master
$ git checkout master
$ git push origin master synth
import org.geoscript._
import style_new._
import filter.Expression.enrichString
// import enrichString for spiffy "".cql method, otherwise strings are treated as literals
// alternatively: import org.geotools.filter.text.ecql.ECQL.{ toExpression => cql }
// to use cql("")
val states = layer.Shapefile("geoscript/src/test/resources/data/states.shp")
val theme =
import logging
for _module in ["geonode.maps.views"]:
_logger = logging.getLogger(_module)
_logger.addHandler(logging.FileHandler("geonode.log"))
_logger.setLevel(logging.DEBUG)
* {
mark: url("http://example.com/example.jpg");
mark-size: [ATTR * 6];
}
@dwins
dwins / sh.py
Created November 3, 2010 13:51
run virtualenv-sandboxed commands from a python script running outside the venv
import os
def vexec(cmd):
os.system("source bin/activate && DJANGO_SETTINGS_MODULE=geonode.settings " + cmd)
@dwins
dwins / fixup_styles.py
Created November 19, 2010 14:16
Find layers using default styles and generate independent styles for each
#!/usr/bin/env python
from geoserver.catalog import Catalog
from itertools import cycle, izip
import re
_punc = re.compile(r"[\.:]") #regex for punctuation that confuses restconfig
_foregrounds = ["#ffbbbb", "#bbffbb", "#bbbbff", "#ffffbb", "#bbffff", "#ffbbff"]
_backgrounds = ["#880000", "#008800", "#000088", "#888800", "#008888", "#880088"]
val orig = xml.XML.load("OSM_Roads.sld")
val ftypes = orig \\ "FeatureTypeStyle"
val printer = new xml.PrettyPrinter(80, 2)
for (name <- Seq("railway", "aeroway", "highway")) {
val nodes =
<StyledLayerDescriptor xmlns="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0.0" xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd">
<UserStyle>