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.util; | |
| import javassist.util.proxy.MethodFilter; | |
| import javassist.util.proxy.MethodHandler; | |
| import javassist.util.proxy.ProxyFactory; | |
| import javassist.util.proxy.ProxyObject; | |
| import org.slf4j.Logger; | |
| import org.slf4j.LoggerFactory; | |
| import javax.persistence.EntityManager; |
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
| <!-- host2 --> | |
| <servers> | |
| <server name="server-one" group="Group1"> | |
| <socket-bindings port-offset="100"/> | |
| </server> | |
| <server name="server-two" group="Group2"> | |
| <socket-bindings port-offset="200"/> |
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.Random | |
| val random = new Random() | |
| def fiftyFifty[T](a: T): Option[T] = if (Random.nextBoolean) Some(a) else None | |
| def sendTweet(h: String) = println(s"sending tweet to $h") | |
| def sendMail(e: String) = println(s"sending email to $e") | |
| object demo1 { | |
| case class PersonalInfo(email: String) |
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 | |
| /** | |
| * todo | |
| */ | |
| object FutureDemoApp extends App { | |
| import scala.concurrent.Future | |
| import scala.concurrent.ExecutionContext.Implicits.global | |
| object supporting { |
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.{Left, Right} | |
| case class Name(value: String) extends AnyVal { | |
| def +(s: Name) = Name(this.value + s) | |
| override def toString: String = value | |
| } | |
| implicit def strToName(s: String) = Name(s) |
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
| case class PersonalInfo(email: String, twitter: Option[String]) | |
| case class Student(username: String, personalInfo: Option[PersonalInfo]) |
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
| abstract class MyStringBuilder { | |
| def get(): String | |
| def append(s: String) | |
| } | |
| class BasicStringBuilder extends MyStringBuilder { | |
| private var value : String = "" | |
| def get(): String = value | |
| def append(s: String) = value = value + s | |
| } |
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
| <!-- | |
| Source: https://www.scala-lang.org/files/archive/spec/2.13/13-syntax-summary.html | |
| Just some nifty regex search/replace | |
| --> | |
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <title>Title</title> |
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
| char[] buffer = new char[1024]; | |
| String chunk = null; | |
| while ((read = reader.read(buffer)) != -1) { | |
| String s = String.valueOf(buffer, 0, read); | |
| /* process the string: Look for "-", keep the part after it | |
| for the next iteration. Add part before it to previous | |
| chunk | |
| */ | |
| } |
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 org.w3c.dom.Document; | |
| import org.w3c.dom.NodeList; | |
| import org.xml.sax.InputSource; | |
| import org.xml.sax.SAXException; | |
| import javax.xml.parsers.DocumentBuilder; | |
| import javax.xml.parsers.DocumentBuilderFactory; | |
| import javax.xml.parsers.ParserConfigurationException; | |
| import javax.xml.xpath.*; | |
| import java.io.IOException; |