Skip to content

Instantly share code, notes, and snippets.

@dwins
dwins / prose.vim
Created April 25, 2012 13:08
Custom command for switching to "prose" editing mode
command Prose set background=light wrap linebreak
def powerSet[A](xs: List[A]): List[List[A]] =
xs.foldLeft(List(Nil: List[A]))((accum, elem) => accum.flatMap(l => Seq(l, elem :: l)))
def countChange(money: Int, coins: List[Int]): Int =
if (money < 0 || coins.isEmpty)
0
else if (money == 0)
1
else
countChange(money - coins.head, coins) + countChange(money, coins.tail)
def fetch[R : Fetchable](s: SQLCursor): R = implicitly[Fetchable[R]].fetch(s)
trait Fetchable[R] {
def fetch(s: SQLCursor): R
}
implicit object IntIsFetchable extends Fetchable[Int] {
def fetch(s: SQLCursor): Int = s.getInt
}
scala> val params = (1, "Dan", "H")
params: (Int, String, String) = (1,Dan,H)
scala> case class Person(id: Int, name: String, initial: String)
defined class Person
scala> Person.tupled(params)
res0: Person = Person(1,Dan,H)
@dwins
dwins / architecture.dot
Created January 23, 2013 14:29
Quick Graphviz diagram for GeoServer's codebase
digraph {
node [shape=box,fontname=Sans]
edge [fontname=Sans,fontsize=6]
Catalog
subgraph {
OWSDispatcher
WebMapService
WebFeatureService
WebCoverageService
WebProcessingService
abstract class Printer {
public static String message;
}
class FormalPrinter extends Printer {
static {
message = "Why hello good sir!";
}
}
#!/bin/sh
set -e # Bail out as soon as any command fails
git for-each-ref --format='%(objectname) %(refname)' refs/remotes |
# sort | uniq -w20 | # uncomment for deduplication, but this doesn't account for multiple branches pointing to the same commit
while read line;
do
ref=${line%\ *}
count=$(git log --oneline --since="-1week" $ref | wc -l)
org.neo4j.graphdb.TransactionFailureException: Index creation failed for identifiers, {provider=lucene, type=exact}
at org.neo4j.kernel.IndexManagerImpl.getOrCreateIndexConfig(IndexManagerImpl.java:233)
at org.neo4j.kernel.IndexManagerImpl.getOrCreateNodeIndex(IndexManagerImpl.java:312)
at org.neo4j.kernel.IndexManagerImpl.forNodes(IndexManagerImpl.java:300)
at org.neo4j.kernel.IndexManagerImpl.forNodes(IndexManagerImpl.java:294)
at org.geogit.storage.Neo4JGraphDatabase.getOrAddNode(Neo4JGraphDatabase.java:209)
at org.geogit.storage.Neo4JGraphDatabase.put(Neo4JGraphDatabase.java:169)
at org.geogit.storage.ObjectDatabasePutInterceptor.putRevObjectInterceptor(ObjectDatabasePutInterceptor.java:112)
at org.geogit.storage.ObjectDatabasePutInterceptor.invoke(ObjectDatabasePutInterceptor.java:47)
at org.geogit.api.porcelain.CommitOp.call(CommitOp.java:300)
[dwins@localhost dst]$ geogit remote list -v
osm http://localhost:8080/geogit/repo (fetch)
osm http://localhost:8080/geogit/repo (push)
[dwins@localhost dst]$ geogit fetch osm master
java.lang.IllegalStateException: Remote could not be resolved.
at com.google.common.base.Preconditions.checkState(Preconditions.java:149)
at org.geogit.api.porcelain.FetchOp.addRemote(FetchOp.java:94)
at org.geogit.api.porcelain.FetchOp.addRemote(FetchOp.java:84)
at org.geogit.cli.porcelain.Fetch.runInternal(Fetch.java:70)