This file contains 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
@RunWith(SpringJUnit4ClassRunner.class) | |
@ContextConfiguration | |
public class BookstoreWjugTest { | |
@Resource | |
private BookstoreSEI bookstore; | |
@Test | |
public void shouldReturnTrueForCxfBook() throws Exception { | |
Book book = new Book("Apache CXF Web Service Development", "Naveen Balani & Rajeev Hathi"); |
This file contains 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
4 1 | |
5 3 | |
6 5 | |
7 8 | |
8 12 | |
9 17 | |
10 24 | |
11 32 | |
12 42 | |
13 54 |
This file contains 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.util.concurrent.DelayQueue; | |
import java.util.concurrent.Delayed; | |
import java.util.concurrent.TimeUnit; | |
import static java.lang.System.currentTimeMillis; | |
import static org.apache.commons.lang.time.DateUtils.MILLIS_PER_SECOND; | |
public class DelayQueueMain { | |
public static void main(String[] args) throws InterruptedException { |
This file contains 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
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); | |
DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); | |
Document doc = docBuilder.newDocument(); | |
Element rootElement = doc.createElement("root"); | |
rootElement.appendChild(doc.createTextNode("A\u0000B")); | |
doc.appendChild(rootElement); | |
TransformerFactory transformerFactory = TransformerFactory.newInstance(); | |
Transformer transformer = transformerFactory.newTransformer(); |
This file contains 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
def message(date: DateTime) = | |
messages collectFirst { | |
case (pred, msg) if pred(date) => msg | |
} |
This file contains 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 () { | |
//From: http://yasintrm.blogspot.no/2012/05/how-to-install-syntax-highlighter-on.html | |
var arr, counter = 0, | |
doc = document, | |
len, load, callBack, url = 'http://agorbatchev.typepad.com/pub/sh/3_0_83/'; | |
if (window.SyntaxHighlighter && !window.SyntaxHighlighterLoading) { | |
SyntaxHighlighter.highlight(); | |
} else if (!window.SyntaxHighlighterLoading) { | |
window.SyntaxHighlighterLoading = true; |
This file contains 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.util.HashSet; | |
import java.util.Set; | |
public class MagicalLand { | |
public static void main(String[] args) { | |
for (int i = 0; i < (Math.random() * 500) + 2; i++) { | |
if (Unicorn.pat()) { | |
System.out.println("UNICORN #1: PAT THIS UNICORN ONCE"); | |
} | |
} |
This file contains 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
def peak(list: List[Int]): Option[Int] = | |
list.sliding(3).collectFirst{case(List(x, y, z)) if(y > x && y > z) => y} | |
def raisePeak(list: List[Int]): Option[List[Int]] = | |
peak(list).map(p => List(p + 1)) |
This file contains 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 static org.mockito.Mockito.doAnswer; | |
//... | |
doAnswer(slowly()).when(timeConsumingExternalServiceMock).process(); | |
//... | |
private static Answer<Object> slowly() { | |
return new Answer<Object>() { |
This file contains 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> Stream. | |
iterate("*"){_ + "*"}. | |
take(5). | |
foreach(println) | |
* | |
** | |
*** | |
**** | |
***** |