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 / 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".

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
}
@karussell
karussell / error.txt
Created Jan 30, 2020
graal native image
View error.txt
[hello.helloworld:8352] compile: 31,630.85 ms, 2.08 GB
Fatal error: java.lang.UnsatisfiedLinkError
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
at java.base/java.util.concurrent.ForkJoinTask.getThrowableException(ForkJoinTask.java:603)
at java.base/java.util.concurrent.ForkJoinTask.get(ForkJoinTask.java:1006)
at com.oracle.svm.hosted.NativeImageGenerator.run(NativeImageGenerator.java:456)
at com.oracle.svm.hosted.NativeImageGeneratorRunner.buildImage(NativeImageGeneratorRunner.java:357)
View native-image-gh.diff
diff --git a/core/src/main/java/com/graphhopper/GraphHopper.java b/core/src/main/java/com/graphhopper/GraphHopper.java
index 673b1880c..6207e5f26 100644
--- a/core/src/main/java/com/graphhopper/GraphHopper.java
+++ b/core/src/main/java/com/graphhopper/GraphHopper.java
@@ -82,7 +82,7 @@ public class GraphHopper implements GraphHopperAPI {
private final String fileLockName = "gh.lock";
private final Set<RoutingAlgorithmFactoryDecorator> algoDecorators = new LinkedHashSet<>();
// utils
- private final TranslationMap trMap = new TranslationMap().doImport();
+ private final TranslationMap trMap;
View test.geojson
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View TestDelete.java
public int removeAllOlderThan(int batchSize, DateTime date) {
try (Connection c = dc.getConnection()) {
PreparedStatement s1 = c.prepareStatement(String.format("SELECT %s FROM %s WHERE created_at < ?",
KEY, dc.getTableName(tableName)));
s1.setLong(1, date.getMillis());
ResultSet rs = s1.executeQuery();
List<String> list = new ArrayList<>(batchSize);
PreparedStatement s2 = null;
int executeUpdateCount = 0;
while (true) {
View an_idea_for_vehicle_profiles.md

Loose statements

properties: compact, self-explanatory, declarative "no-loop", native yaml (?)

very specific to influence only the cost and time calculation:

calcMillis:
  time = distance_in_m / speed_in_kmh * 3.6 + delay_in_sec + turn_cost_delay_in_sec
calcWeight:
  if (isInfinity(time)) return infinity
View MyBenchmark.java
/*
* Copyright (c) 2014, Oracle America, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
You can’t perform that action at this time.