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
<?php | |
interface Comparable | |
{ | |
public function compare(self $obj); | |
} | |
class A implements Comparable | |
{ | |
public function compare(self $obj) { | |
return $this == $obj; |
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
$ free -m | |
total used free shared buffers cached | |
Mem: 3017 2953 64 0 381 671 | |
-/+ buffers/cache: 1899 1118 | |
^ | |
Available memory (in MB) -------------| | |
The Linux kernel will allocate as much free memory as possible to buffers and caches (e.g. the fs cache) | |
to improve performance. When an application allocates more memory than is "free", the kernel will allocate | |
memory from it's caches. |
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
log4j:ERROR setFile(null,true) call failed. | |
java.io.FileNotFoundException: /usr/lib/hadoop-0.20/logs (Is a directory) | |
at java.io.FileOutputStream.openAppend(Native Method) | |
at java.io.FileOutputStream.<init>(FileOutputStream.java:177) | |
at java.io.FileOutputStream.<init>(FileOutputStream.java:102) | |
at org.apache.log4j.FileAppender.setFile(FileAppender.java:290) | |
at org.apache.log4j.FileAppender.activateOptions(FileAppender.java:164) | |
at org.apache.log4j.DailyRollingFileAppender.activateOptions(DailyRollingFileAppender.java:216) | |
at org.apache.log4j.config.PropertySetter.activate(PropertySetter.java:257) | |
at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:133) |
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
test_connect: | |
if (connect(ptr->fd, | |
(struct sockaddr *)&servAddr, | |
sizeof(servAddr)) < 0) | |
{ | |
switch (errno) | |
{ | |
case EINPROGRESS: | |
case EALREADY: | |
case EINTR: |
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
INFO [NonPeriodicTasks:1] 2011-05-17 20:47:44,725 SSTable.java (line 147) Deleted /var/lib/cassandra/yyy-f-1201 | |
INFO [COMMIT-LOG-WRITER] 2011-05-17 20:56:48,233 CommitLogSegment.java (line 50) Creating new commitlog segment /var/lib/cassandra/commitlog/CommitLog-1305665808233.log | |
INFO [ScheduledTasks:1] 2011-05-17 21:02:14,513 Gossiper.java (line 226) InetAddress /x.x.x.34 is now dead. | |
INFO [GossipStage:1] 2011-05-17 21:02:14,786 Gossiper.java (line 607) InetAddress /x.x.x.34 is now UP | |
INFO [ScheduledTasks:1] 2011-05-17 21:02:21,514 Gossiper.java (line 226) InetAddress /x.x.x.34 is now dead. | |
INFO [HintedHandoff:1] 2011-05-17 21:03:13,676 HintedHandOffManager.java (line 295) Endpoint /x.x.x.34 died before hint delivery, aborting | |
INFO [GossipStage:1] 2011-05-17 21:06:09,884 Gossiper.java (line 628) Node /x.x.x.34 has restarted, now UP again | |
INFO [GossipStage:1] 2011-05-17 21:06:10,552 StorageService.java (line 724) Node /x.x.x.34 state jump to normal | |
INFO [HintedHandoff:1] 2011-05-17 21:06:15,924 Hinte |
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
// pretend this extractor is performance critical | |
object EvenExtractor { | |
def unapply(x: Int): Option[Int] = { | |
println("Testing for EVEN: " + x) | |
if (x % 2 == 0) Option(x) else None | |
} | |
} | |
// when you use it from a PartialFunction, it gets executed TWICE for all applicable values | |
Seq(1, 2, 3, 4) collect { |
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
object Either { | |
def apply[A, B](value: A): Left[A, B] = Left(value) | |
def apply[A, B](value: B): Right[A, B] = Right(value) | |
} | |
val a: Either[Long, String] = Either(123L) | |
// a: Either[Long,String] = Left(123) | |
val b: Either[Long, String] = Either("123") | |
b: Either[Long,String] = Right(123) |
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
object Either { | |
implicit def aToLeft[A, B](value: A): Left[A, B] = Left(value) | |
implicit def bToRight[A, B](value: B): Right[A, B] = Right(value) | |
} | |
import Either._ | |
case class User(id: Either[Long, String]) | |
User(123L) |
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
object Any { | |
implicit def matching[A](a: A): Matchable[A] = new Matchable(a) | |
sealed class Matchable[A](o: A) { | |
// "match" is a reserved word, so lets call it "matchIt" instead | |
def matchIt[B](pf: PartialFunction[A, B]): B = { | |
if(pf.isDefinedAt(o)) { | |
pf(o) | |
} else { | |
throw new MatchError("...") |
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
object App { | |
case class Post(title: String, | |
body: String, | |
tags: List[String]) | |
case class Address(street: String, | |
city: String, | |
state: String, | |
zip: String, | |
tags: List[String]) |
OlderNewer