Skip to content

Instantly share code, notes, and snippets.

@caoilte
caoilte / gist:2781601
Created May 24, 2012 13:41
Stubble: Unit Test
describe("Build Packager", function(){
var Stubble, mockConfig, realpathSyncMock, writeFileMock, fsMock, writePackageCallback, mapAllFilesSpy,
folderMock, zipAddFilesMock, zipMock, stub, packager, DIRECTORY_TO_ZIP;
beforeEach(function() {
Stubble = require('stubble'),
mockConfig = {
commandArgs: {
product: "mobile"
}
@caoilte
caoilte / gist:5241423
Created March 25, 2013 22:29
When I compile and run https://github.com/wordnik/swagger-core/tree/master/samples/scala-scalatra/ and look at the API doc URI for Pet http://localhost:8080/api-docs/pet I get
{
resourcePath: "/pet",
listingPath: "/api-docs/pet",
description: "Pet API",
apis: [
{
path: "/pet/",
description: "",
secured: false,
operations: [
@caoilte
caoilte / jaxb-in-scala-1_01.scala
Last active August 29, 2015 14:06
Bending JAXB to the will of Scala [1/2]
case class EntryType(entrytypeoption: Seq[scalaxb.DataRecord[Any]] = Nil,
attributes: Map[String, scalaxb.DataRecord[Any]]) extends FeedTypeOption
case class EntryType(entrytypeoption: Seq[scalaxb.DataRecord[Any]] = Nil,
xmlbase: Option[java.net.URI] = None,
xmllang: Option[String] = None,
attributes: Map[String, scalaxb.DataRecord[Any]]) extends FeedTypeOption
@caoilte
caoilte / jaxb-in-scala-2_01.scala
Last active August 29, 2015 14:06
Bending JAXB to the will of Scala [2/2]
import scala.annotation.target.field
import javax.xml.bind.annotation._
import javax.xml.bind.annotation.adapters._
type xmlElement = XmlElement @field
type xmlTypeAdapter = XmlJavaTypeAdapter @field
/**
* NB As with the CustomOptionAdapter we've had to modify the type signature here,
//import Foo._
object Foo {
case class /\(name: String)
case class Bar(name: String)
}
object Test {
@caoilte
caoilte / latest_rpm_release_in_artifactory.sh
Created March 5, 2016 21:20
How to get the latest version of an RPM from an Artifactory Repository
echo 'items.find(
{
"repo":{"$eq":"<REPO_NAME>"},
"name":{"$match":"<RPM_NAME>*"}
}
).include("name", "@rpm.metadata.release").sort({"$desc" : ["name"]}).limit(1)' > aql.json
curl -X POST -Taql.json --user <USER>:<PASSWORD> "https://<ARTIFACTORY>/api/search/aql" | python -c "import json,sys;obj=json.load(sys.stdin);print obj['results'][0]['properties'][0]['value'];"
@caoilte
caoilte / InfiniteBatchProcessor.scala
Created June 10, 2016 08:52
Infinite Batch Processing Walking Skeleton using scalaz-stream
import java.util.concurrent.Executors
import scalaz.concurrent.{Strategy, Task}
import scalaz.stream._
import scalaz.stream.async.mutable.Queue
object MercuryPlayabilityUpdater {
implicit val DefaultStrategy: Strategy = Strategy.Executor(
Executors.newFixedThreadPool(10, Strategy.DefaultDaemonThreadFactory)
@caoilte
caoilte / QueueExample.scala
Last active June 13, 2016 13:48
scalaz-stream example of problem for Stack Overflow question
import java.util.concurrent.Executors
import scalaz.concurrent.{Strategy, Task}
import scalaz.stream._
import scalaz.stream.async.mutable.Queue
object Processes {
val source: Process[Task, String] = Process.emitAll(0 until 10).map(_.toString())
val slowProcessor1: Channel[Task, String, String] =
{
"_embedded": {
"promotions": [{
"type": "url",
"contentfulName": "15 minute container",
"position": "primary",
"title": "Mark's First URL Promo",
"subtitle": "It's the first one I tell ya",
"_links": {