Skip to content

Instantly share code, notes, and snippets.

@skangmy
Last active November 10, 2022 01:52
Show Gist options
  • Save skangmy/5d2fa3dbc51b7019a80b9d747f7d1b9c to your computer and use it in GitHub Desktop.
Save skangmy/5d2fa3dbc51b7019a80b9d747f7d1b9c to your computer and use it in GitHub Desktop.
Frequently used Flux code
// return default value if v is null
// usage: coalesce(v: r.host, default: "missing")
coalesce = (v, default) => if exists v then v else default
// setting timezone
// needed when using aggregateWindow with period 1d and higher, or date truncate function
import "timezone"
option location = timezone.location(name: "Asia/Kuala_Lumpur")
// http request
import "http/requests"
import "experimental/json"
response = requests.get(url: "http://localhost/api/" + id)
data = json.parse(data: response.body).data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment