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.util | |
| class LongSet { | |
| val buckets = scala.collection.mutable.HashMap[Int, util.BitSet]() | |
| private def position(n: Long): (Int, Int) = | |
| ( (n / Int.MaxValue).toInt, (n % Int.MaxValue).toInt) | |
| def set(n: Long): Unit = { |
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
| class ProtoBufEncoder(props: VerifiableProperties = null) extends Encoder[com.google.protobuf.GeneratedMessage] { | |
| override def toBytes(protoBufMessage: com.google.protobuf.GeneratedMessage): Array[Byte] = protoBufMessage.toByteArray | |
| } |
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
| // Currying: f(f1,...,fn) -> f(f1,...,fk)(fk+1,...,fn) | |
| // Usage: f.curry(f1,...,fk) -> g(fk+1,...fn) == f(f1,...,fn) | |
| Function.prototype.curry = function() { //f(f1,...,fk) | |
| if( arguments.length == 0 ) | |
| return this; | |
| var args = arguments; | |
| var fn = this; | |
| return function() { // g(fk+1,...,fn) | |
| var prefix = Array.prototype.slice.call(args); | |
| var suffix = Array.prototype.slice.call(arguments); |
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
| app.directive('ngEnter', function () { | |
| return function (scope, element, attrs) { | |
| element.bind("keydown keypress", function (event) { | |
| if(event.which === 13) { | |
| scope.$apply(function (){ | |
| scope.$eval(attrs.ngEnter); | |
| }); | |
| event.preventDefault(); | |
| } | |
| }); |
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
| app.directive('showFocus', function($timeout) { | |
| return function(scope, element, attrs) { | |
| scope.$watch(attrs.showFocus, | |
| function (newValue) { | |
| $timeout(function() { | |
| newValue && element.focus(); | |
| }); | |
| },true); | |
| }; | |
| }); |
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 repl; | |
| import java.util.HashMap; | |
| import java.util.Map; | |
| import java.util.function.Function; | |
| public class Tools { | |
| public static final boolean CACHE_ON = true; | |
| public static final boolean TIMER_ON = true; |
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
| Files.walkFileTree(Paths.get(dir), new SimpleFileVisitor<Path>() { | |
| public FileVisitResult visitFile(Path path, BasicFileAttributes attrs) | |
| throws IOException{ | |
| // insert code here | |
| return FileVisitResult.CONTINUE; | |
| } | |
| }); |