Skip to content

Instantly share code, notes, and snippets.

@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
}
@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 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 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 highlight-tunnels.js
var lineLayer = L.geoJson().addTo(mapLayer.getMap());
lineLayer.options.style = function (feature) {
var p = feature.properties || {};
return {color:p.color||"gray", weight:p.weight||2, opacity:0.5};
}
var counter = 0;
var timeLimit = 10 * 30;
var Papa = require("papaparse");
Papa.parse("http://127.0.0.1:8989/spt?point=51.351201,12.398071&time_limit="+timeLimit+"&columns=prev_longitude,prev_latitude,longitude,latitude,time,road_environment", {
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.