Skip to content

Instantly share code, notes, and snippets.

View chgeuer's full-sized avatar
🏠
Working from Düsseldorf

Dr. Christian Geuer-Pollmann chgeuer

🏠
Working from Düsseldorf
View GitHub Profile
@petelacey
petelacey / one_drive.ex
Created February 24, 2024 23:02
Sample Elixir code to upload large documents to OneDrive via the MS Graph API
defmodule OneDrive
require Logger
@graph_api_url "https://graph.microsoft.com/v1.0/"
# The parent_drive_item is a Graph API driveItem object representing the root folder the file it to be uploaded to.
# There are many other representations left as an exercise to the reader
#
# The remote_file_path variable has the complete path to the file on the OneDrive side, e.g. /foo/bar/baz.txt
# If either the /foo or /bar folders are not already there, they will be created. They do not have to be created
defmodule Todo do
import String, only: [split: 3, trim: 1];
@t :todos
@d :dets
def prompt() do IO.write("todo> "); split(trim(IO.binread(:line)), " ", parts: 2) end
def run(:start) do @d.open_file(@t, type: :set); run(">") end
def run(:goodbye), do: @d.close(@t)
def run(_) do
case prompt() do
[c] when c in ["", "ls"] -> @d.match_object(@t, {:"$1", false})
@ninjarobot
ninjarobot / tracing-intro-appinsights.md
Last active August 17, 2023 15:17
Correlated tracing in F# with Application Insights

Tracing with Application Insights

Application logging is ubiquitous and invaluable for troubleshooting. Structured logging enables you to log formatted messages and the data fields separately so that you can see the messages but also filter on the data fields. Tracing takes this a step further, where you can correlate many log entries together as you follow a trace of execution through an application. Traces also include additional information about the execution process, such as the sequence of calls to dependencies and how long any given call may take.

Application Insights lets you see all of this data correlated together in an application. You can search for an error log and then see in the execution flow that the log entry was added right after a failed call to another service. Or you can see that a certain web request is slower than others because it spends a lot of time on many redundant data access calls.

What about OpenTelemetry?

@tall3n
tall3n / md
Created April 20, 2022 14:24
Steps to auto sync IOS + windows Logseq.
I am a windows destkop user and Iphone user. and have come up with this workflow that is completley automatic and works really really well.
Pre-reqs.
- Git repo access
- Paid version of workign copy
- logseq
- Shortcuts app on Iphone
# Windows Side
You can use the https://github.com/logseq/git-auto to do your auto pushes on a schedule.
open System
/// A train carriage can have a number of different features...
type Feature = Quiet | Wifi | Toilet
/// Multiple classes
type CarriageClass = First | Second
/// Carriages can be either for passengers or the buffet cart
type CarriageKind =
# This is the proper BEAM test for https://github.com/uber/denial-by-dns. The Erlang test in that repo is sequential
# (https://github.com/uber/denial-by-dns/blob/b809cc561a691d9d6201d06d38d06c33c9c9f9ec/erlang-httpc/main.erl)
# which is not consistent with the test description (https://github.com/uber/denial-by-dns/tree/b809cc561a691d9d6201d06d38d06c33c9c9f9ec#how-it-works)
# and also differs from e.g. go test in the same repo which issues requests concurrently.
#
# Consequently, the conclusion in that repo as well as the original article (https://eng.uber.com/denial-by-dns/) is incorrect.
# A properly written Erlang test would pass, as demonstrated by this Elixir script.
#
# This code performs a slightly refined and a correct version of that tests in Elixir:
#
@TeaDrivenDev
TeaDrivenDev / FsAdvent2019.md
Last active December 29, 2019 19:52
FsAdvent post for 2019

Paying It F#rward

This article is an entry in the 2019 F# Advent Calendar in English. Thanks to Sergey Tihon for organizing it, as always!

Note: This belongs on my blog, but some things are broken there right now, probably due to changes to GitHub Pages in recent years, so I'm publishing this here for now to at least get a reliable output.

The F# community, while small compared to those of many other languages, is known to be exceedingly open and helpful to beginners. I experienced this myself when I started learning the language nearly six years ago, and people (especially the F# MVPs) were always quick and eager to answer my newbie questions on Twitter, or wrote extensive answers on Stack Overflow or Code Review. Havi

@keathley
keathley / stateful_server.ex
Last active May 9, 2019 03:58
stateful_server example
defmodule Demo do
def demo do
_once_per_second = Demo.start(:once, 200)
_ten_per_second = Demo.start(:ten, 220)
_hundret_per_second = Demo.start(:hundret, 250)
IO.puts("Launced processes")
Process.sleep(1_500)
[:once, :ten, :hundret] |> show() |> IO.inspect()
@nilaydshah
nilaydshah / ASEPreRegistration.py
Last active July 12, 2019 07:59
ASE Pre-Registration Script
import argparse
import sys
import grp
import pwd
import subprocess
import os
import json
class PreRegistration: