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 commutative { | |
import scala.language.implicitConversions | |
sealed class =!=[A,B] | |
trait LowerPriorityImplicits { | |
implicit def equal[A]: =!=[A, A] = sys.error("should not be called") | |
} | |
object =!= extends LowerPriorityImplicits { | |
implicit def nequal[A,B](implicit same: A =:= B = null): =!=[A,B] = |
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 charts { | |
import com.redhat.et.silex.util.OptionalArg | |
import OptionalArg.fullOptionSupport | |
import io.continuum.bokeh._ | |
private def defaultTools(plot: Plot) = List( | |
new PanTool().plot(plot), | |
new BoxZoomTool().plot(plot), | |
new ResetTool().plot(plot), | |
new PreviewSaveTool().plot(plot)) |
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
// initialize this with the maximum possible distance: | |
Dbest = M+N; | |
P = 0; | |
while (true) { | |
// the minimum possible distance for the current P value | |
Dmin = 2*(P-1) + delta; | |
// if the minimum possible distance is >= our best-known distance, we can halt | |
if (Dmin >= Dbest) return Dbest; |
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
#include <iostream> | |
using namespace std; | |
#define showsize(tname) cout << #tname << ": " << sizeof(tname) << endl | |
int main(int argv, char** argc) { | |
showsize(char); | |
showsize(short); | |
showsize(int); |
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
[eje@localhost git]$ for dir in `find /home/eje/git -maxdepth 3 -exec test -d \{\}/.git \; -print` ; do echo $dir; cd $dir ; git reset --hard HEAD; done |
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> val f1 = (x:Int, t:Int) => (x > t) | |
f1: (Int, Int) => Boolean = <function2> | |
scala> f1 | |
res22: (Int, Int) => Boolean = <function2> | |
scala> val f2 = (x:Int, t:Int=7) => (x > t) | |
<console>:1: error: ')' expected but '=' found. | |
val f2 = (x:Int, t:Int=7) => (x > t) |
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 scala.collection.mutable | |
import scala.reflect.runtime.universe.{TypeTag, TypeRef, typeOf} | |
// A function that also keeps its domain and range types as a payload | |
class FunctionTP[D: TypeTag, R:TypeTag](f: D=>R) extends Function[D,R] { | |
val domainType = typeOf[D] | |
val rangeType = typeOf[R] | |
val func = f | |
override def apply(x: D):R = func(x) | |
def compose[E:TypeTag](g: E=>D):FunctionTP[E,R] = new FunctionTP(func compose g) |
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
trait CastOptionToV[V] { | |
def cast[T:TypeTag](o:Option[T]):V | |
} | |
class CastOptionToLong extends CastOptionToV[Long] { | |
def cast[T:TypeTag](o:Option[T]):Long = { | |
val tLong = typeOf[Long] | |
typeOf[T] match { | |
case `tLong` => o.asInstanceOf[Option[Long]].get | |
case _ => throw new Exception | |
} |
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
#include <iostream> | |
#include "boost/date_time/posix_time/posix_time_types.hpp" | |
using namespace boost::posix_time; | |
int main(int argc, char** argv) { | |
const int dsec = 5; | |
{ | |
ptime t0 = microsec_clock::local_time(); |
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
# start-slaves wants sshd running | |
# start up master | |
# web ui: http://localhost:8080/ | |
$ ./sbin/start-master.sh | |
# start up 2 slaves | |
# web ui: http://localhost:8081/ (8082, 8083, ...) | |
$ env SPARK_WORKER_INSTANCES=2 ./sbin/start-slaves.sh |
OlderNewer