Skip to content

Instantly share code, notes, and snippets.

@devnulled
devnulled / gist:4946216
Created February 13, 2013 17:13
I can never quite remember the form for GitHub Enteprise URLs for published pages. Here is how the URL's are accessed.
GitHub Pages URLs on an Enterprise instance take the form of http(s)://[hostname]/pages/[user]/[repo]
@devnulled
devnulled / idea.vmoptions
Last active May 23, 2018 09:36
Java VM Arguments for IntelliJ + Scala + Grails
-Xms1024m
-Xmx2048m
-XX:MaxPermSize=512m
-XX:ReservedCodeCacheSize=128m
-XX:+UseCodeCacheFlushing
-XX:+UseCompressedOops
-server
-XX:NewSize=128m
-XX:+UseParNewGC
-XX:ParallelGCThreads=8
@devnulled
devnulled / gist:3883718
Created October 13, 2012 07:42
Static File Webserver in Scala
package scalawebserver
import java.net._
import com.sun.net.httpserver._
class Handler extends HttpHandler {
import java.io._
import java.nio._
import scala.io.Source
@devnulled
devnulled / gist:3756734
Created September 20, 2012 15:51
Eclipse JVM Arguments for Speed and Stability
These additional/replacement JVM arguments for Eclipse seem to work pretty well.
I believe I got them from a blog at some point, but no idea where.
Please backup your original config and change at your own peril.
-XX:MaxPermSize=512m
-Xms40m
-Xmx2048m
-XX:+UseParallelGC
@devnulled
devnulled / WrappedLiftJsonResponse.scala
Created September 17, 2012 21:19
Simple Helper Class to return JSON Responses in Lift with a particular HTTP Status Code
package your.mom
import net.liftweb.http.{S, HeaderDefaults, InMemoryResponse, LiftResponse}
import net.liftweb.json.JsonAST.JValue
import net.liftweb.json._
// This is much nicer to use than the native JsonResponse in Lift
case class WrappedLiftJsonResponse(json: JValue, statusCode: Int, respHeaders: List[(String, String)] = Nil) extends LiftResponse with HeaderDefaults {
val headerContentType = "Content-Type"
val headerJsonContentValue = "application/json"
@devnulled
devnulled / Microbenchmark.scala
Created August 30, 2012 18:28
Example Code To Microbenchmark In Scala
def doSomething() = {
val s = System.nanoTime
// do stuff here
println("time: "+(System.nanoTime-s)/1e6+"ms")
}
@devnulled
devnulled / gist:3417585
Created August 21, 2012 17:31
How To Specify an Ivy Style Resolver for sbt
resolvers += Resolver.url("artifactory", url("http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases"))(Resolver.ivyStylePatterns)
@devnulled
devnulled / OptionCheatsheet.scala
Created June 27, 2012 15:45
Scala Option Cheatsheet
// flatMap
// This code is equivalent to:
// option.flatMap(foo(_))
option match {
case None => None
case Some(x) => foo(x)
}
// flatten
// This code is equivalent to:
@devnulled
devnulled / elite.txt
Created May 24, 2012 02:26 — forked from rodhilton/gist:2777936
Secret Awesome Code
* g o a t s e x * g o a t s e x * g o a t s e x *
g g
o / \ \ / \ o
a| | \ | | a
t| `. | | : t
s` | | \| | s
e \ | / / \\\ --__ \\ : e
x \ \/ _--~~ ~--__| \ | x
* \ \_-~ ~-_\ | *
g \_ \ _.--------.______\| | g
@devnulled
devnulled / gist:2407714
Created April 17, 2012 17:42
Parse a Microsoft .NET style JSON Date/Timestamp into a Java Date
package devnulled;
import java.util.Date;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class DateTimeUtils {
/**
* <p>
* Parses a Microsoft .NET style JSON timestamp and returns a Java Date irrespective of time zones (but can parse them)