Skip to content

Instantly share code, notes, and snippets.

View AugustKarlstedt's full-sized avatar
☮️

August Karlstedt AugustKarlstedt

☮️
View GitHub Profile
@AugustKarlstedt
AugustKarlstedt / ndcg-bq-udf.sql
Created May 7, 2024 19:34 — forked from vwrs/ndcg-bq-udf.sql
calculate NDCG in BigQuery
create temp function ndcg(rels array<int64>, k int64) returns float64 as (
(
with gain as (
select
(pow(2, rel) - 1) / log(i + 2) as g,
(pow(2, rel_sorted) - 1) / log(i + 2) as g_ideal
from
unnest(rels) as rel with offset as i
left join unnest((
select
// Cognitive Service containers don't currently handle Cross-origin resource sharing (CORS) headers. This means that for user agents
// that enforce CORS (browsers, typically), requests will fail. The following code is an example of how you might work around this,
// temporarily, until the containers are fixed. This code is provided as-is, with no guarantees.
//
// The following is a modified version of code found here: https://github.com/ccoenraets/cors-proxy.
var express = require('express'),
request = require('request'),
bodyParser = require('body-parser'),
app = express();
@AugustKarlstedt
AugustKarlstedt / Dockerfile
Created November 2, 2018 18:56 — forked from gyndav/Dockerfile
install Scala and sbt on Alpine Linux
FROM openjdk:8u151-jre-alpine
ENV SCALA_VERSION=2.12.4 \
SCALA_HOME=/usr/share/scala
# NOTE: bash is used by scala/scalac scripts, and it cannot be easily replaced with ash.
RUN apk add --no-cache --virtual=.build-dependencies wget ca-certificates && \
apk add --no-cache bash curl jq && \
cd "/tmp" && \
wget --no-verbose "https://downloads.typesafe.com/scala/${SCALA_VERSION}/scala-${SCALA_VERSION}.tgz" && \