Skip to content

Instantly share code, notes, and snippets.

/** Represents a value of one of two possible types (a disjoint union.)
* Instances of Either are either an instance of [[scala.Left]] or [[scala.Right]].
*
* A common use of Either is as an alternative to [[scala.Option]] for dealing
* with possible missing values. In this usage, [[scala.None]] is replaced
* with a [[scala.Left]] which can contain useful information.
* [[scala.Right]] takes the place of [[scala.Some]]. Convention dictates
* that Left is used for failure and Right is used for success.
*
* For example, you could use ``Either[Exception, Int]`` to safely parse a String:
@dwins
dwins / fonts.js
Created October 13, 2011 19:38
What fonts can Java find which are able to render Chinese text?
// Run with 'jrunscript fonts.js' or just copy/paste in the jrunscript interactive interpreter
var GraphicsEnvironment = Packages.java.awt.GraphicsEnvironment;
var fonts =
GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
var test = "\u4e00"; // a String, you can replace it with your own test text if you care about a different language.
// this value came from http://www.chinesecomputing.com/programming/java.html regarding Chinese text handling in Java
for (var i = 0; i < fonts.length; i++)
import org.geoscript._
import layer.Shapefile, support.math.Interpolation, style.combinators._,
style.io.SLD, io.Sink
import org.geotools.filter.text.ecql.ECQL.{ toFilter => cql }
import java.awt.Color
val states = Shapefile("geoscript/src/test/resources/data/states.shp")
val buckets =
(states.features.map(_.get[Double]("PERSONS")).toSeq
@dwins
dwins / fetch.sh
Created September 22, 2011 22:40
MN2GT Support Scripts
wget \
http://developer.mapquest.com/content/static/geotiffs/mercator_tiffs.tar \
http://tile.openstreetmap.org/world_boundaries-spherical.tgz \
http://tile.openstreetmap.org/processed_p.tar.bz2 \
http://tile.openstreetmap.org/shoreline_300.tar.bz2
#!/usr/bin/env python
from geoserver.catalog import Catalog
cat = Catalog("http://localhost:8080/geoserver/rest/")
for r in cat.get_resources():
print "Resource %s %s %s" % (r.workspace, r.store, r.name)
for name in dir(r):
print "\t", name + ":", getattr(r, name)
from django.core.management.base import BaseCommand
from django.db import transaction
from geonode.maps.models import MapLayer
import json
class Command(BaseCommand):
help = """
Changes the OWS url for all layers in geonode maps, useful for when a map
server changes. If you use an absolute URL for the GEOSERVER_URL setting
this simplifies the process of changing the hostname for your GeoNode site.
sealed trait Breakfast {
def beverage: String
def dish: String
}
object LumberJack extends Breakfast {
val beverage = "black coffee"
val dish = "ham and eggs
}
Missing File: file:/usr/share/opengeo-suite-data/geoserver_data/data/styles/symbols/POI.svg
Missing File: file:/usr/share/opengeo-suite-data/geoserver_data/data/styles/symbols/cul_de_sac.15.png
Missing File: file:/usr/share/opengeo-suite-data/geoserver_data/data/styles/symbols/cul_de_sac.16.png
Missing File: file:/usr/share/opengeo-suite-data/geoserver_data/data/styles/symbols/cul_de_sac.17.png
Missing File: file:/usr/share/opengeo-suite-data/geoserver_data/data/styles/symbols/cul_de_sac.18.png
Missing File: file:/usr/share/opengeo-suite-data/geoserver_data/data/styles/symbols/exit-freeway.svg
Missing File: file:/usr/share/opengeo-suite-data/geoserver_data/data/styles/symbols/exit.svg
Missing File: file:/usr/share/opengeo-suite-data/geoserver_data/data/styles/symbols/ferry.svg
Missing File: file:/usr/share/opengeo-suite-data/geoserver_data/data/styles/symbols/golf.svg
Missing File: file:/usr/share/opengeo-suite-data/geoserver_data/data/styles/symbols/golf_small.svg
@dwins
dwins / filter.scala
Created August 18, 2011 19:02
unfiltered + servlet
package dwins.web
class Unfiltered extends unfiltered.filter.Planify ({
case GET(Path("/")) => Ok ~> TextContent ~> Text("Hello")
})
@dwins
dwins / upload-styles.py
Created July 19, 2011 13:38
Upload a directory of SLDs
import geoserver.catalog
import os, os.path
cat = geoserver.catalog.Catalog(
'http://localhost:8080/geoserver/rest',
"admin", "geoserver")
style_dir = "/home/dwins/Downloads/graphite/"
suffix = 'graphite'
extant_styles = set(s.name for s in cat.get_styles())