Skip to content

Instantly share code, notes, and snippets.

View fedragon's full-sized avatar

Federico Ragona fedragon

View GitHub Profile
@fedragon
fedragon / get_weekly_mileage.py
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
fedragon / sdkman_with_fish
Last active November 20, 2024 22:46
How to use SDKMan! with Fish shell
# Install bass (https://github.com/edc/bass) to be able to use bash utilities in Fish
fisher add edc/bass
touch ~/.config/fish/functions/sdk.fish
# paste content in ~/.config/fish/functions/sdk.fish, then save
function sdk
bass source ~/.sdkman/bin/sdkman-init.sh ';' sdk $argv
end
@fedragon
fedragon / build.sbt
Created May 9, 2017 12:06
sbt: Change dependency version according to scala version
def myDependencyVersion(scalaVersion: String) = scalaVersion match {
case "2.11.11" => "2.0"
case _ => "1.0"
}
Project(...)
.settings(
libraryDependencies ++= Seq(
...,
"my" %% "dependency" % myDependency(scalaVersion.value)
@fedragon
fedragon / HashMapParam.scala
Last active May 2, 2020 10:16
Allows HashMap[String, Int] to be used as accumulators in Spark
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