Skip to content

Instantly share code, notes, and snippets.

@max-mapper
max-mapper / upload.sh
Created March 27, 2019 00:43
upload large file to zenodo from command line (curl)
# in zenodo ui create a deposition. get the id
curl -H "Accept: application/json" -H "Authorization: Bearer $TOKEN" "https://www.zenodo.org/api/deposit/depositions/$DEPOSITION"
# get the bucket id from above
curl --progress-bar -o /dev/null --upload-file ./$FILE https://www.zenodo.org/api/files/$BUCKET/$FILE?access_token=$TOKEN
@pavlov99
pavlov99 / haversine.scala
Created December 19, 2016 07:52
Spherical distance calcualtion based on latitude and longitude with Apache Spark
// Based on following links:
// http://andrew.hedges.name/experiments/haversine/
// http://www.movable-type.co.uk/scripts/latlong.html
df
.withColumn("a", pow(sin(toRadians($"destination_latitude" - $"origin_latitude") / 2), 2) + cos(toRadians($"origin_latitude")) * cos(toRadians($"destination_latitude")) * pow(sin(toRadians($"destination_longitude" - $"origin_longitude") / 2), 2))
.withColumn("distance", atan2(sqrt($"a"), sqrt(-$"a" + 1)) * 2 * 6371)
>>>
+--------------+-------------------+-------------+----------------+---------------+----------------+--------------------+---------------------+--------------------+------------------+
|origin_airport|destination_airport| origin_city|destination_city|origin_latitude|origin_longitude|destination_latitude|destination_longitude| a| distance|