Skip to content

Instantly share code, notes, and snippets.

@vwrs
vwrs / ndcg-bq-udf.sql
Last active March 28, 2024 13:06
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
@bshishov
bshishov / forecasting_metrics.py
Last active April 20, 2024 04:29
Python Numpy functions for most common forecasting metrics
import numpy as np
EPSILON = 1e-10
def _error(actual: np.ndarray, predicted: np.ndarray):
""" Simple error """
return actual - predicted
@sliminality
sliminality / frontend-resources.md
Last active November 23, 2016 15:33
resources for preparing for front-end development interviews

Front-end Interview Preparation

Generally useful

  • JSBin (jsbin.com) -- really helpful tool for messing around in HTML/CSS/JS. Make sure to log in with your GitHub account (and make a GitHub if you don't already have one) so that all your work is saved

  • The Code Player (http://thecodeplayer.com/) -- nifty site with "screencast"-style animations to watch how web apps and effects are built

  • Mozilla Developer Network (MDN) documentation (https://developer.mozilla.org/en-US/docs/Web) -- if you need to reference anything related to web technology, like looking up JavaScript functions or CSS properties, use this website. You should never ever ever ever use W3Schools.org -- they are bad and wrong and always use MDN instead

HTML

@simgislab
simgislab / modis1l-prepare4mrtswath.py
Created June 27, 2015 03:12
Run MRT Swath for MOD02/MOD03 files
#!/usr/bin/env python -u
# -*- coding: utf-8 -*-
# ---------------------------------------------------------------------------
# modis1l-prepare4mrtswath.py
# Author: Maxim Dubinin (sim@gis-lab.info)
# About: Run MRT Swath for MOD02/MOD03 files
# Created: 26.06.2014
# Usage example: python modis1l-prepare4mrtswath.py
# ---------------------------------------------------------------------------
import glob
anonymous
anonymous / SlideDown-Menu.markdown
Created October 1, 2014 10:58
A Pen by mp_graphic.
@irazasyed
irazasyed / Install Composer using MAMP's PHP.md
Last active April 2, 2024 18:45
Instructions on how to change preinstalled Mac OS X PHP to MAMP's PHP Installation and then install Composer Package Management

Change default Mac OS X PHP to MAMP's PHP Installation and Install Composer Package Management


Instructions to Change PHP Installation


First, Lets find out what version of PHP we're running (To find out if it's the default version).

To do that, Within the terminal, Fire this command:

which php

@mbostock
mbostock / README.md
Last active June 7, 2023 18:33
Underscore’s Equivalents in D3

Collections

each(array)

Underscore example:

_.each([1, 2, 3], function(num) { alert(num); });