Skip to content

Instantly share code, notes, and snippets.

Avatar
🍌
I AM A BANANA

David Kowis dkowis

🍌
I AM A BANANA
View GitHub Profile
@dkowis
dkowis / HttpServletRequestRapper.scala
Created Jul 15, 2015
This is all I'd do, honestly
View HttpServletRequestRapper.scala
private def getPreferredHeader(headerName: String, getFun: String => List[String]): List[String] = {
case class HeaderValue(headerValue: String) {
val value = headerValue.split(";").head
val quality = {
try {
val headerParameters: Array[String] = headerValue.split(";").tail
val qualityParameters: Option[String] = headerParameters.find(param => "q".equalsIgnoreCase(param.split("=").head.trim))
qualityParameters.map(_.split("=", 2)(1).toDouble).getOrElse(1.0)
} catch {
case e: NumberFormatException => throw new QualityFormatException("Quality was an unparseable value", e)
View gist:1a82791b8a215daa865a
# set it to use ctrl-a instead of ctrl b
unbind C-b
set -g prefix C-a
# less escape time, because tmux waits for one
# book recommends 1
set -s escape-time 1
# start stuff at 1, not 0
set -g base-index 1
View TimeoutExceptionProof.groovy
import org.spockframework.runtime.SpockAssertionError
import spock.lang.Specification
import spock.util.concurrent.PollingConditions
class TimeoutExceptionProof extends Specification {
final def pollingConditions = new PollingConditions(timeout: 10, initialDelay: 1)
def "why does it fail"() {
View maven config.xml
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>xml-maven-plugin</artifactId>
<version>1.0</version>
<executions>
<execution>
<goals>
<goal>transform</goal>
</goals>
</execution>
View Sample.scala
def parseDelegationValues(delegationValues: Seq[String]): Seq[HttpDelegationHeaderBean] = {
// TODO: Performance concerns
delegationValues.map(parseDelegationHeader).filter {
case Success(_) =>
true
case Failure(e) =>
LOG.warn("Failed to parse a delegation header: " + e.getMessage)
false
}.map(_.get)
View keybase.md

Keybase proof

I hereby claim:

  • I am dkowis on github.
  • I am dkowis (https://keybase.io/dkowis) on keybase.
  • I have a public key whose fingerprint is 98EC 7077 CB97 00A1 F2E7 3834 C9DF FAF4 70EB 739B

To claim this, I am signing this object:

@dkowis
dkowis / wrapped.scala
Created Nov 19, 2014
An example to wrap it instead of copy/pasting try/finally on each one. Same effect as calling a function in try/finally, but you can do more
View wrapped.scala
def withContext(f: LoggingServiceImpl => Unit) = {
val loggingService = new LoggingServiceImpl()
val context = LogManager.getContext(false).asInstanceOf[LoggerContext]
try {
f(loggingService)
} finally {
System.clearProperty(ConfigurationFactory.CONFIGURATION_FILE_FACTORY)
context.reconfigure
StatusLogger.getLogger.reset
}
View ConfigurationObjects.scala
package org.openrepose.spring
import java.net.URL
import org.openrepose.commons.config.parser.ConfigurationParserFactory
import org.openrepose.commons.config.resource.impl.BufferedURLConfigurationResource
import org.openrepose.core.container.config.ContainerConfiguration
import org.openrepose.core.systemmodel.SystemModel
import scala.reflect.ClassTag
View war Extraction.txt
$  unzip -l war-1.NOPE.war
Archive: war-1.NOPE.war
Length Date Time Name
--------- ---------- ----- ----
0 2014-09-23 12:05 META-INF/
25 2014-09-23 12:05 META-INF/MANIFEST.MF
0 2014-09-23 12:05 WEB-INF/
0 2014-09-23 12:05 WEB-INF/classes/
0 2014-09-23 11:29 WEB-INF/classes/org/
0 2014-09-23 11:29 WEB-INF/classes/org/protorepose/
@dkowis
dkowis / Project Structure.md
Last active Aug 29, 2015
Repose Project Structure Proposal
View Project Structure.md

Existing project structure

  • repose
    • documentation
    • repose-aggregator
      • commons
        • classloader
        • configuration
        • jetty
        • utilities
You can’t perform that action at this time.