Skip to content

Instantly share code, notes, and snippets.

javi santana javisantana

Block or report user

Report or block javisantana

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@javisantana
javisantana / summing_merge_tree.sql
Created Jan 17, 2020
SummingMergetree multiple keys in nested maps
View summing_merge_tree.sql
MacBook-Pro-de-javi.local :) create table multiple_keys (tmp Int32, testMap Nested (a Int32, bKey Int32, value Int32)) Engine=SummingMergeTree() order by (tmp);
CREATE TABLE multiple_keys
(
`tmp` Int32,
`testMap` Nested(
a Int32,
bKey Int32,
value Int32)
)
@javisantana
javisantana / compile clickhouse on mojave.md
Last active Mar 11, 2020
compile clickhouse on mojave
View compile clickhouse on mojave.md

clickhouse on osx

These are the steps I followed to compile clickhouse on OSX mojave (10.4.3). These might not be the best way to make it compile on OSX, my knowledge about C++ and build tooling is really limited but they do the work.

clickhouse sha-1: 2ad4df1d6a

compile command (apply the patch below before running cmake)

@javisantana
javisantana / res.sql
Last active Jun 20, 2019
filter ourside the join vs inside the join in clickhouse
View res.sql
MacBook-Pro-de-javi.local :) select cityHash64(groupArray(cityHash64(*))) from A a asof inner join (select * from B where ts<toDateTime('1970-01-01 02:00:00')) b on a.id=b.id and a.ts=b.ts where a.ts<toDateTime('1970-01-01 02:00:00');
SELECT cityHash64(groupArray(cityHash64(*)))
FROM A AS a
ASOF INNER JOIN
(
SELECT *
FROM B
WHERE ts < toDateTime('1970-01-01 02:00:00')
) AS b ON (a.id = b.id) AND (a.ts = b.ts)
View charla
https://docs.google.com/presentation/d/1vURI9yYJvAm0couPbFeKz09sr8bvQuSzCfcTEBow7ec/edit#slide=id.g5294e95553_0_101
@javisantana
javisantana / clickhouse_osx.md
Last active May 21, 2019
how to build clickhouse on osx high sierra
View clickhouse_osx.md

IMPORTANT, this worked with CH stable (76629e9) version on 2019/02/14

install requirements

from the original osx build doc page https://clickhouse.yandex/docs/en/development/build_osx.html

build clickhouse

Add /usr/local/include to the default path for gcc (for some reason gcc-7 was not using that folder on osx)

@javisantana
javisantana / mercator_numpy.py
Created Jan 20, 2018
mercator projection using numpy
View mercator_numpy.py
"""
projects a numpy array with (lon, lat) to (x, y) in mercator coordinates using numpy
license: MIT
adapted from https://github.com/mapbox/mercantile
"""
import numpy as np
import math
View haversine_numpy.py
"""haversine function adapted to work with numpy arrays
Adapted from https://github.com/mapado/haversine/blob/master/haversine/__init__.py
License: MIT
"""
import math
import numpy as np
AVG_EARTH_RADIUS = 6371 * 1000 # m
View .vimrc
set nocompatible
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
let g:ackprg = 'ag --nogroup --nocolor --column'
map <F6> :%s/>\s*</>\r</g<CR>ggVG=
"colorscheme koehler
View mercator.js
// license: BSD3
const WEBMERCATOR_R = 6378137.0;
const DIAMETER = WEBMERCATOR_R * 2 * Math.PI;
class Mercator {
static project(lon, lat) {
var x = DIAMETER * lon/360.0;
var sinlat = Math.sin(lat * Math.PI/180.0);
var y = DIAMETER *Math.log((1+sinlat)/(1-sinlat)) / (4*Math.PI);
return { x, y };
}
View carto.py
import urllib,sys,csv;
print reduce(lambda p, new: (p[0] + (new - p[0])/p[1], p[1] + 1), map(float, (x['tip_amount'] for x in csv.DictReader(urllib.urlopen(sys.argv[1])))), (0, 1))
You can’t perform that action at this time.