Skip to content

Instantly share code, notes, and snippets.


Federico Ragona fedragon

View GitHub Profile
fedragon /
Last active August 26, 2021 22:31
Collect total running distance since last Monday from Strava API
from datetime import date, datetime, time, timedelta
import json
import os
import shutil
from urllib import parse, request
from urllib.error import HTTPError
import yaml
def get_new_access_token(ctx):
fedragon / sdkman_with_fish
Last active April 21, 2021 07:50
How to use SDKMan! with Fish shell
View sdkman_with_fish
# Install bass ( to be able to use bash utilities in Fish
fisher add edc/bass
touch ~/.config/fish/functions/
# paste content in ~/.config/fish/functions/, then save
function sdk
bass source ~/.sdkman/bin/ ';' sdk $argv
fedragon / build.sbt
Created May 9, 2017 12:06
sbt: Change dependency version according to scala version
View build.sbt
def myDependencyVersion(scalaVersion: String) = scalaVersion match {
case "2.11.11" => "2.0"
case _ => "1.0"
libraryDependencies ++= Seq(
"my" %% "dependency" % myDependency(scalaVersion.value)
fedragon / HashMapParam.scala
Last active May 2, 2020 10:16
Allows HashMap[String, Int] to be used as accumulators in Spark
View HashMapParam.scala
import org.apache.spark.{AccumulableParam, SparkConf}
import org.apache.spark.serializer.JavaSerializer
import scala.collection.mutable.{ HashMap => MutableHashMap }
* Allows a mutable HashMap[String, Int] to be used as an accumulator in Spark.
* Whenever we try to put (k, v2) into an accumulator that already contains (k, v1), the result
* will be a HashMap containing (k, v1 + v2).
* Would have been nice to extend GrowableAccumulableParam instead of redefining everything, but it's