Skip to content

Instantly share code, notes, and snippets.

View jesseeichar's full-sized avatar

Jesse Eichar jesseeichar

  • POLYPOINT
  • Bern
View GitHub Profile
@jesseeichar
jesseeichar / gist:6387566
Created August 30, 2013 08:27
Thread safe XslProcessingReport
//=============================================================================
//=== Copyright (C) 2001-2013 Food and Agriculture Organization of the
//=== United Nations (FAO-UN), United Nations World Food Programme (WFP)
//=== and United Nations Environment Programme (UNEP)
//===
//=== This program is free software; you can redistribute it and/or modify
//=== it under the terms of the GNU General Public License as published by
//=== the Free Software Foundation; either version 2 of the License, or (at
//=== your option) any later version.
//===
@jesseeichar
jesseeichar / gist:3356853
Created August 15, 2012 06:06
Authentication in Scala-IO
val username = "myusername"
val password = "mypassword".toCharArray()
class MyAuthenticator extends Authenticator {
def getPasswordAuthentication =
new PasswordAuthentication(kuser, password);
}
Authenticator.setDefault(new MyAuthenticator());
// Option 1. Simplest and could be the first implementation
trait ReadBytes {
protected def resource: InputStreamResource
def readHead(bytesCount: Long): Array[Byte] = {
val arr = new Array[Byte](bytesCount)
// I can do better but not worrying about it now
resource.acquireFor(_.read(arr))
arr
}