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 | |
class A { | |
public $somePropertyWithReasonablyLongName = 1; | |
} | |
class B { | |
public $somePropertyWithReasonablyLongName = 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
#include <stdio.h> | |
#include <string.h> | |
#include <time.h> | |
#include <math.h> | |
#include <stdlib.h> | |
#include <stdint.h> | |
#include <immintrin.h> | |
#include "sys/param.h" | |
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
/** Idiosyncratic dictionary mapping strings to ints specialized for english | |
* words and other short alphanumeric strings. Long strigns are packed into | |
* one continuous char array, short alphanumeric strings are inlined into the | |
* structure that normally points into the array of long strings. This has the | |
* effect that strings shorter than 9 characters need only 12 bytes per mapping | |
* and lookup causes only one cache miss. | |
* | |
* Warning: Might contains subtle and not-so-soubtle errors. | |
*/ | |
class StringIntDictionary { |
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
/** | |
* Decodes a JSON string. | |
* @param string | |
* @param boolean | |
* @param integer | |
* @return mixed | |
*/ | |
public static function decode($json, $assoc = FALSE, $depth = 512) | |
{ | |
$json = (string) $json; |
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 breeze.linalg._ | |
import breeze.stats | |
import breeze.numerics._ | |
val dataFile = new File(???) | |
val userItems: Array[SparseVector[Double]] = loaderUserItemsWithRatings(dataFile, """[ ,:]""".r) | |
val itemUsers: Array[SparseVector[Double]] = transpose(userItems) map { vec => normalize(vec, 2) } | |
// weights | |
val N = DenseVector.fill[Double](itemIndex.size)(userIndex.size) // vector where total numbers of users is repeated |
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 breeze._ | |
import breeze.linalg._ | |
import breeze.numerics._ | |
import java.awt.image.BufferedImage | |
import javax.imageio.ImageIO | |
val f = ??? | |
val img = javax.imageio.ImageIO.read(new File(f)) | |
val gray = new BufferedImage(img.getWidth, img.getHeight, BufferedImage.TYPE_BYTE_GRAY) | |
val g = gray.createGraphics() |
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
// min-hash | |
val fs: Vector[Int => Int] // hash funkce | |
items map { it => fs map { f => f(it) } } fold (vectorPairwise(min), initialValue = Vector.fill(infinity)) | |
// HyperLogLog |
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
// size = (1 << 25), time = 800 ms | |
// size = (1 << 25) - 1999, time = 400 ms ??? | |
// size = (1 << 24), time = 700 ms | |
val size = 1 << 25 | |
val randos = new util.Random() | |
val arr = Array.fill(size)(randos.nextInt) | |
java.util.Arrays.sort(arr) |
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
scalaVersion := "2.9.0-1" | |
libraryDependencies += "commons-codec" % "commons-codec" % "1.4" | |
libraryDependencies += "oauth.signpost" % "signpost-core" % "1.2.1.1" | |
libraryDependencies += "org.jdom" % "jdom" % "1.1" | |
libraryDependencies += "rome" % "rome" % "0.9" |
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 fib[A](n: Int, k: Int => A): A = { | |
if (n < 2) k(1) | |
else fib(n-1, (x: Int) => | |
fib(n-2, (y: Int) => | |
k(x+y))) | |
} | |
fib(10, println) |