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
package daily | |
object BaumSweetSequence extends App { | |
def baumSweet(n: Int) = | |
if (n != 0 && n.toBinaryString | |
.split("1") | |
.exists(_.length % 2 == 1)) 0 | |
else 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
object Euler3 extends App { | |
val a = 600851475143l | |
def primes(n: Long, div: Long = 2, found: Vector[Long] = Vector.empty): Vector[Long] = | |
if (n % div == 0) | |
primes(n / div, div, found :+ div) | |
else if (div > (n / 2)) | |
found :+ n | |
else | |
primes(n, div + 1, found) |
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 Euler2_imperative extends App { | |
var a = 0 | |
var b = 1 | |
var sum = 0 | |
while (a + b < 4000000) { | |
if ((a + b) % 2 == 0) { | |
sum += 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 Euler2 extends App { | |
def fibs(a: Int, b:Int): Stream[Int] = | |
b #:: fibs(b, a + b) | |
val res = fibs(1, 1). | |
filter(_ % 2 == 0). | |
takeWhile(_ < 4000000).sum | |
println(res) |
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
package com.msvaljek | |
import java.io.File | |
import org.apache.flink.api.scala._ | |
object FindAndGroupStandingLocations { | |
def main(args: Array[String]) { | |
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
if ("skinny-3of12".equalsIgnoreCase(operation)) { | |
Select query = QueryBuilder. | |
select("activity_id", "start_time", "end_time"). | |
from("activities"). | |
where(eq("activity_id", bindMarker())).limit(1); | |
PreparedStatement select = session.prepare(query); | |
BoundStatement bstmt = new BoundStatement(select); | |
bstmt.bind(UUID.fromString("72b493f0-e59d-11e3-9bd6-0050568317e1")); |
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
if ("skinny-3of12".equalsIgnoreCase(operation)) { | |
Select select = QueryBuilder.select(new String[] { "activity_id", "start_time", "end_time" }).from("activities"); | |
select.where(QueryBuilder.eq("activity_id", | |
UUID.fromString("72b493f0-e59d-11e3-9bd6-0050568317e1"))); | |
Activity3of12 a; | |
startTime = System.currentTimeMillis(); | |
for (int i = 0; i < count; i++) { | |
a = cassandraOps.selectOne(select, Activity3of12.class); |
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
// standard shim | |
window.requestAnimFrame = (function(){ | |
return window.requestAnimationFrame || | |
window.webkitRequestAnimationFrame || | |
window.mozRequestAnimationFrame || | |
function( callback ) { | |
window.setTimeout(callback, 1000 / 60); | |
}; | |
})(); |
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
var html = (function () {/* | |
<!DOCTYPE html> | |
<html> | |
<body> | |
<h1>Hello, world!</h1> | |
</body> | |
</html> | |
*/}).toString().match(/[^]*\/\*([^]*)\*\/\}$/)[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
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01//EN” “http://www.w3.org/TR/html4/strict.dtd”> | |
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “http://www.w3.org/TR/html4/loose.dtd”> | |
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”> | |
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”> |
NewerOlder