This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function base64url(source) { | |
// Encode in classical base64 | |
encodedSource = CryptoJS.enc.Base64.stringify(source); | |
// Remove padding equal characters | |
encodedSource = encodedSource.replace(/=+$/, ''); | |
// Replace characters according to base64url specifications | |
encodedSource = encodedSource.replace(/\+/g, '-'); | |
encodedSource = encodedSource.replace(/\//g, '_'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
/// An abstract class that makes building simple asynchronous operations easy. | |
/// Subclasses must implement `execute()` to perform any work and call | |
/// `finish()` when they are done. All `NSOperation` work will be handled | |
/// automatically. | |
open class AsynchronousOperation: Operation { | |
// MARK: - Properties |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object TestEnum extends Enumeration { | |
case class MyEnum(name: String) extends Val(name) | |
val ENUM_1 = MyEnum("0100") | |
val ENUM_2 = MyEnum("0200") | |
} | |
//defined module TestEnum | |
TestEnum.values | |
//res0: TestEnum.ValueSet = TestEnum.ValueSet(0100, 0200) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.concurrent.duration._ | |
import scala.concurrent.ExecutionContext | |
import scala.concurrent.Future | |
import akka.pattern.after | |
import akka.actor.Scheduler | |
/** | |
* Given an operation that produces a T, returns a Future containing the result of T, unless an exception is thrown, | |
* in which case the operation will be retried after _delay_ time, if there are more possible retries, which is configured through | |
* the _retries_ parameter. If the operation does not succeed and there is no retries left, the resulting Future will contain the last failure. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Resources : | |
http://www.scala-lang.org/files/archive/spec/2.11/08-pattern-matching.html#pattern-binders | |
Bug on SCALA for comprehension + pattern matching | |
https://issues.scala-lang.org/browse/SI-900 | |
*/ | |
import scala.concurrent.Future | |
import scala.concurrent.ExecutionContext.Implicits.global |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scala> :paste | |
// Entering paste mode (ctrl-D to finish) | |
val a : Option[String] = Some("Shit") | |
val b : Option[String] = Some("LetterB") | |
for (av <- a;bv <- b){ | |
println(s"AV -> $av") | |
println(s"BV -> $bv") | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.net.URI | |
import scala.concurrent.{ExecutionContext, Await} | |
import scala.concurrent.duration.Duration | |
import slick.backend.DatabaseConfig | |
import slick.driver.JdbcProfile | |
import slick.util.ConfigExtensionMethods.configExtensionMethods | |
import slick.codegen.SourceCodeGenerator | |
class CustomizedCodeGenerator(model: slick.model.Model) extends SourceCodeGenerator(model) { | |
override def code = super.code + indent(""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package demo | |
import scala.slick.model.Model | |
import scala.slick.jdbc.meta.createModel | |
import scala.slick.driver.H2Driver | |
import Config._ | |
/** | |
* This customizes the Slick code generator. We only do simple name mappings. | |
* For a more advanced example see https://github.com/cvogt/slick-presentation/tree/scala-exchange-2013 | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.util.{ Failure, Success } | |
import scala.language.implicitConversions | |
import scala.concurrent.ExecutionContext.Implicits.global | |
import scala.concurrent.Future | |
val a = Future{println("a"); "a"} | |
val b = Future{println("b"); "b"} | |
val c = Future{throw new Exception("Test")} | |
val d = Future{ | |
Thread.sleep(3000) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javax.xml.xpath._ | |
import org.xml.sax.InputSource | |
import java.io.StringReader | |
import javax.xml.parsers._ | |
import javax.xml.transform.dom.DOMSource | |
import java.io.StringWriter | |
import javax.xml.transform.stream.StreamResult | |
import javax.xml.transform.TransformerFactory | |
import javax.xml.namespace.NamespaceContext | |
import java.io.ByteArrayInputStream |
NewerOlder