Skip to content

Instantly share code, notes, and snippets.

View eed3si9n's full-sized avatar

eugene yokota eed3si9n

View GitHub Profile
package scalaz
package typelevel
/**
* Represents a function `A => F[B]` where `[F: TC]`.
*/
trait Func[F[_], TC[F[_]] <: Functor[F], A, B] { self =>
def runA(a: A): F[B]
implicit def TC: KTypeClass[TC]
implicit def F: TC[F]
@eed3si9n
eed3si9n / contravariant.scala
Created October 8, 2012 03:11
implementation of Equal and Show typeclass using contravariance.
trait CanEqual[-A] {
def equals(a1: A, a2: A): Boolean
}
object CanEqual {
def apply[A](implicit ev: CanEqual[A]): CanEqual[A] = ev
def equals[A](f: (A, A) => Boolean): CanEqual[A] = new CanEqual[A] {
def equals(a1: A, a2: A): Boolean = f(a1, a2)
}
}
trait CanEqualOps[A] {
gnome-cups-manager
------------------
Once upon a time there was a printer who lived in the woods. He was a
lonely printer, because nobody knew how to configure him. He hoped
and hoped for someone to play with.
One day, the wind passed by the printer's cottage. "Whoosh," said the
wind. The printer became excited. Maybe the wind would be his
friend!
package rt {
object `package` extends StandardInstances {
def something[A](implicit format: Format[A]) = format.str
}
trait StandardInstances {
implicit val intFormat = new Format[Int] { val str = "Int" }
implicit def dataRecordFormat[A: Format] = new Format[DataRecord[A]] {
val str = "DataRecord[" + rt.something[A] + "]"
}
}
package encoding
import org.specs2.Specification
import org.specs2.mock.Mockito
import org.apache.commons.codec.binary.Base64
import scalaxb.Base64Binary
import scalax.io.Resource
import scalax.file.Path
import org.specs2.specification.Step
@eed3si9n
eed3si9n / OTA_AllRQ.xsd
Created November 28, 2012 15:58
Open Travel Alliance 2010B specification
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.opentravel.org/OTA/2003/05" targetNamespace="http://www.opentravel.org/OTA/2003/05">
<xsd:include schemaLocation="OTA_PingRQ.xsd" />
<xsd:include schemaLocation="OTA_VehAvailRateRQ.xsd" />
<xsd:include schemaLocation="OTA_VehRetResRQ.xsd" />
<xsd:include schemaLocation="OTA_VehResRQ.xsd" />
<xsd:include schemaLocation="OTA_VehModifyRQ.xsd" />
<xsd:include schemaLocation="OTA_VehCancelRQ.xsd" />
<xsd:include schemaLocation="OTA_VehLocDetailRQ.xsd" />
<xsd:include schemaLocation="OTA_VehLocSearchRQ.xsd" />

scalaxb XML Web Services

user stories

US-1: generate simple SOAP service

Mike provides a class marked with attributes @WebService and some method marked @WebMethod. For the sake of simiplicity, all returns types are String, Int, Double, and Boolean.

trait DefaultVcloudVCloudExtensibleTypeFormat extends scalaxb.XMLFormat[com.vmware.api.vcloud.VCloudExtensibleType] {
def reads(seq: scala.xml.NodeSeq, stack: List[scalaxb.ElemName]): Either[String, com.vmware.api.vcloud.VCloudExtensibleType] = seq match {
case node: scala.xml.Node =>
scalaxb.Helper.instanceType(node) match {
case (Some("http://www.vmware.com/vcloud/v1.5"), Some("ProviderVdcCapacityType")) => Right(scalaxb.fromXML[com.vmware.api.vcloud.ProviderVdcCapacityType](node, stack))
case (Some("http://www.vmware.com/vcloud/v1.5"), Some("RootComputeCapacityType")) => Right(scalaxb.fromXML[com.vmware.api.vcloud.RootComputeCapacityType](node, stack))
case (Some("http://www.vmware.com/vcloud/v1.5"), Some("NetworkPoolReferencesType")) => Right(scalaxb.fromXML[com.vmware.api.vcloud.NetworkPoolReferencesType](node, stack))
case (Some("http://www.vmware.com/vcloud/v1.5"), Some("UsersListType")) => Right(scalaxb.fromXML[com.vmware.api.vcloud.User
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Net;
using System.Net.Http.Formatting;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using System.Web;
using System.Net.Http;