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 | |
Matcher::multi('div.article', [ | |
'title' => 'h2' | |
'date' => 'span.date' | |
])->fromHtml(new CssMatcherContext) |
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
val runes = "ᚨᛒᚳᛞᛖᚠᚷᚺᛁᛃᚲᛚᛗᚾᛟᛈᛩᚱᛋᛏᚣᚢᚹᛤᛣᛉ" | |
def runize(str: String) = str.toLowerCase map (l => if (runes.isDefinedAt(l-'a')) runes(l-'a') else ' ') |
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
<?php | |
// really really fast loop (0.008s) | |
$arr = range(1, pow(2, 24)+1); | |
for ($i = 1; $i < 200000; $i++) { | |
unset($arr[$i]); | |
$arr[] = 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
./ext/date/lib/parse_date.c:10272 | |
./Zend/zend_language_scanner.c:1533 | |
./Zend/zend_ini_scanner.c:1350 | |
./ext/sqlite3/libsqlite/sqlite3.c:636 | |
./sapi/phpdbg/phpdbg_lexer.c:373 | |
./ext/date/lib/parse_iso_intervals.c:250 | |
./ext/standard/var_unserializer.c:189 | |
./ext/mbstring/oniguruma/regexec.c:157 | |
./ext/pcre/pcrelib/pcre_compile.c:119 | |
./ext/standard/url_scanner_ex.c:100 |
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 main | |
import ( | |
"fmt" | |
"image" | |
"image/color" | |
"os" | |
"math" | |
"path/filepath" | |
_ "image/gif" |
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 <stdlib.h> | |
#include <immintrin.h> | |
// gcc -std=c99 -D IS_RAND=0 branch-test.c ; for i in -1 -2 1 3 2 4 8 16; do echo '### ' $i; perf stat -r5 -o _stats_pred_base --append ./a.out $i; echo; done | |
// gcc -O3 -std=c99 -D IS_RAND=0 branch-test.c ; for i in -1 -2 1 3 2 4 8 16; do echo '### ' $i; perf stat -r5 -o _stats_pred_o3 --append ./a.out $i; echo; done | |
// gcc -std=c99 -D IS_RAND=1 branch-test.c ; for i in 8 16 32 64 128 256; do echo '### ' $i; perf stat -r5 -o _stats_rand_base --append ./a.out $i; echo; done | |
// gcc -O3 -std=c99 -D IS_RAND=1 branch-test.c ; for i in 8 16 32 64 128 256; do echo '### ' $i; perf stat -r5 -o _stats_rand_o3 --append ./a.out $i; echo; 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
<?php | |
$m = Matcher::multi('//table[@id="egmFixtureList"]/tr[@class]', [ | |
'datum' => 'td[@colspan]', | |
'spielnr' => 'td[1]', | |
'anpfiff' => 'td[2]', | |
'team1' => 'td[3]/a/text()', | |
'team2' => 'td[5]/a/text()', | |
'spielbericht' => 'td[7]/a/@href', | |
])->fromHtml()->map(function ($rows) { |
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
let yetAnotherPoint = (1, -1) | |
switch yetAnotherPoint { | |
case let (x, y) where x == y: | |
println("(\(x), \(y)) is on the line x == y") | |
case let (x, y) where x == -y: | |
println("(\(x), \(y)) is on the line x == -y") | |
case let (x, y): | |
println("(\(x), \(y)) is just some arbitrary point") | |
} |
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() |