Skip to content

Instantly share code, notes, and snippets.

@karussell
karussell / copy-to-bashrc.sh
Last active Jun 10, 2020
append to foreign pull request
View copy-to-bashrc.sh
# Here is how to append commits to a pull request from a foreign repository without (slow) cloning
# When you put the function in .bashrc you can use it via:
# cd graphhopper # go into your local copy of the repo where the pull request was made
# pranch graphhopper msbarry:sample-and-3d-simplify
# The first argument is your organisation and the second argument is "foreign_organisation:foreign_branch" e.g. copied from the pull request
pranch()
{
forbranch=${2#*:} # == foreign branch
fororg=${2%%:*} # == foreign organisation
locbranch=${fororg}_${forbranch}
@karussell
karussell / MiniGraphUI.java
Last active May 25, 2020
Alternative Roads to Rome
View MiniGraphUI.java
/*
* Licensed to GraphHopper and Peter Karich under one or more contributor
* license agreements. See the NOTICE file distributed with this work for
* additional information regarding copyright ownership.
*
* GraphHopper licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
@karussell
karussell / Query-DSL-elasticsearch.txt
Last active May 7, 2020
Bird's Eye View on ElasticSearch its Query DSL
View Query-DSL-elasticsearch.txt
Several times in a month there pop up questions regarding query structure on the ElasticSearch user group.
Although there are good docs explaining this in depth probably the bird view of the Query DSL is necessary to
understand what is written there. There is even already some good external documentation available:
http://www.elasticsearch.org/tutorials/2011/08/28/query-dsl-explained.html
And there were attempts to define a schema:
http://groups.google.com/group/json-schema/browse_thread/thread/ae498ee818155d50
https://gist.github.com/8887766ca0e7052814b0
View geotester-init.sh
sudo apt-get install python3-venv
python3 -m venv ~/.python-venv/
source ~/.python-venv/bin/activate
git clone https://github.com/geocoders/geocoder-tester
cd geocoder-tester
pip install -r requirements.txt
py.test ...
View test-dedicated.sh
wget -q https://raw.githubusercontent.com/graphhopper/directions-api-js-client/master/route-optimization-examples/vrp_lonlat_new.json -O vrp.json
JOB_ID=$(curl -X POST -H "Content-Type: application/json" "http://localhost:8080/optimize" --data @vrp.json | cut -d'"' -f4)
sleep 2
curl -X GET "http://localhost:8080/solution/$JOB_ID"
View PostLargeProblem.java
// for more than 4K locations or for slow network you need to gzip the body
OkHttpClient client = new OkHttpClient();
client.setConnectTimeout(20, TimeUnit.SECONDS);
client.setReadTimeout(20, TimeUnit.SECONDS);
client.interceptors().add(new GzipRequestInterceptor());
....
@karussell
karussell / price.md
Last active Apr 1, 2020
hetzner pricing for 256GB RAM servers and beyond
View price.md
name CPU 256GB-price max GB max-price price/1GB
SB (auction) Xeon® E5-1650 v3 Hexa-Core ~100€ 256 ~100€ 0.31-0.43
AX161 EPYC™ 7502P 32-Core Zen2 167.00€ 512 263.00€ 0.514-0.652
PX92 Xeon® W-2145 Octa-Core 174.93€ 256 174.93€ 0.683
DX152 Xeon® SP Silver 10-Core 274.89€ 786 503.37€ 0.640-1.074
SX292 Xeon® E5-1650 v3 Hexa-Core 308.21€ 256 308.21€ 1.204

The Xeon SP Silver is likely the "Xeon Silver 4210".

@karussell
karussell / backup.sh
Created Jul 10, 2011
Backup ElasticSearch with rsync
View backup.sh
# TO_FOLDER=/something
# FROM=/your-es-installation
DATE=`date +%Y-%m-%d_%H-%M`
TO=$TO_FOLDER/$DATE/
echo "rsync from $FROM to $TO"
# the first times rsync can take a bit long - do not disable flusing
rsync -a $FROM $TO
# now disable flushing and do one manual flushing
View truck.yml
# Specify a vehicle (FlagEncoder) or another custom profile like
base: car
# in meter
vehicle_height: 3.8
vehicle_width: 2.5
# in tons
vehicle_weight: 4.5
# The formula is defined in CustomWeighting, where the speed_factor can be used to increase and decrease speed.
View request.json
{
"configuration" : {
"routing" : {
"profile" : "car"
},
"clustering" : {
"max_quantity" : 10,
"min_quantity" : 5,
"num_clusters" : 5
}
You can’t perform that action at this time.