Skip to content

Instantly share code, notes, and snippets.

View johntbush's full-sized avatar

john bush johntbush

View GitHub Profile
newValue = transformField(newValue, fieldName, displayName)
@johntbush
johntbush / gist:81d01375b8bb91dacb89
Last active August 29, 2015 14:05
either this or that
def getExceptionTemplateByEnv(templateId: String) = Action {
Core.getExceptionTemplatesByEnv(templateId).fold (
outputDataStoreResponse,
(templates) => Ok(Json.toJson(templates))
)
}
def outputDataStoreResponse: (DataStoreResponse) => Result = {
(dataStoreResponse) => NotFound(dataStoreResponse.jsValue)
}
@johntbush
johntbush / gist:535eda37ff0ea3a34afa
Created August 15, 2014 07:44
this is how we do it
def getEntitiesByKeyFromDatastore[T](
entityName: String,
lookupKey: (String, String),
reads: Reads[T]): Either[DataStoreResponse, List[T]]
@johntbush
johntbush / gist:a2b17af518d3f5e8469f
Created October 8, 2014 23:11
validation json for cost allocation
{
"CA_ELEM_1": [
{
"ruleId": "235c8202-4f3f-11e4-9e35-164230d1df67",
"type": "regex",
"expression": "[0-9].*",
"description": "must be a valid number"
},
{
"ruleId": "5186bc7e-4f3f-11e4-9e35-164230d1df67",
@johntbush
johntbush / gist:4c7376969d2cf7286eb0
Created October 8, 2014 23:16
validation request
[
{
"CA_ELEM_1": "{value}"
},
{
"CA_ELEM_2": "{value}"
}
]
@johntbush
johntbush / gist:7fd8877e5be163dd2978
Created October 8, 2014 23:21
response to validate call
{
"CA_ELEM_1": [
{
"ruleId": "{uuid}",
"valid": true
},
{
"ruleId": "{uuid}",
"valid": false,
"message": "must be a valid number"
@johntbush
johntbush / gist:4d853608fafc80a61c14
Last active August 29, 2015 14:14
exception agg on lsp name
curl -X POST -H "Content-Type: application/json" -H "Cache-Control: no-cache" -H "Postman-Token: 3de837bf-3f1a-4882-c538-22025f1e1c3f" -d '{
"aggs" : {
"name" : {
"terms" : { "field" : "Invoice.InvNorm.LspRootOrgName.raw" }
}
}
}' http://elasticsearch.s03.filex.com/fps-exceptions_c94c36b8-e425-4bb8-b291-4b34f96d74ca_b/_search?size=0
{
"took": 2,
import org.elasticsearch.monitor.jvm.HotThreads
import play.api.mvc._
object HotThreadsController extends BaseController {
def getHotThreads = Action {
Ok(new HotThreads().detect())
}
}
@annotation.tailrec
final def retry[T](n: Int)(fn: => T): T = {
util.Try { fn } match {
case util.Success(x) => x
case _ if n > 1 => retry(n - 1)(fn)
case util.Failure(e) => throw e
}
}
@johntbush
johntbush / gist:e107d937429a308ba062
Last active August 29, 2015 14:16
retry example
retry(10) {
// to some stuff that might need a few kicks in the butt before it works
}