Skip to content

Instantly share code, notes, and snippets.

View bforchhammer's full-sized avatar

Benedikt Forchhammer bforchhammer

View GitHub Profile
@bforchhammer
bforchhammer / datadog_propagator.ex
Last active November 1, 2023 08:04
Opentelemetry propagator for datadog tracing headers
defmodule DatadogPropagator do
@moduledoc """
Opentelemetry context propagator for spandex / datadog traces.
This propagator adds support for datadog tracing headers (eg. x-datadog-trace-id), which is the
format supported by the Spandex library to enable distributed tracing.
Notes:
- The x-datadog-origin header is currently not supported
- The value of the x-datadog-sampling-priority header is currently simply mapped to "1" for
@bforchhammer
bforchhammer / k8sauth_exec.ex
Last active December 6, 2019 16:06
Exec authentication provider for k8s elixir library
defmodule K8sAuth.Exec do
@moduledoc false
alias K8sAuth.Exec
alias K8s.Conn.RequestOptions
@behaviour K8s.Conn.Auth
defstruct [:command, :env, :args]
@type t :: %__MODULE__{
@bforchhammer
bforchhammer / eprof.ex
Last active May 15, 2019 08:46
Profiling Elixir Processes
:eprof.start()
process_pids_or_names = [self()]
:eprof.start_profiling(process_pids_or_names)
# do work which causes calls on the traced PIDs
:eprof.stop_profiling()
# output generated
Verifying my Blockstack ID is secured with the address 1JfsD38bV1RnRi8CnyWJZQfAmC86gctnbi https://explorer.blockstack.org/address/1JfsD38bV1RnRi8CnyWJZQfAmC86gctnbi
@bforchhammer
bforchhammer / lazy_batching.py
Last active February 18, 2017 08:56
Graphene lazy batched requests
from graphql.execution.executors.sync import SyncExecutor
"""
Usage example:
from functools import partial
class MyServiceCache(BulkRequestCache):
def __init__():
self.requested_values = set()
@bforchhammer
bforchhammer / setup_labels.py
Created August 30, 2016 09:37
Github Labeler
import github3
try:
prompt = raw_input
except NameError:
prompt = input
def two_factor():
code = ''
while not code:
@bforchhammer
bforchhammer / keybase.md
Last active December 29, 2019 11:09
Keybase

Keybase proof

I hereby claim:

  • I am bforchhammer on github.
  • I am bforchhammer (https://keybase.io/bforchhammer) on keybase.
  • I have a public key ASCugvqVBlojF61o5BhdbdQ7jK7fzJ5OVHgLuyvNAr_zZAo

To claim this, I am signing this object:

@bforchhammer
bforchhammer / gist:51e1d09ec4e39a826730
Created October 31, 2014 11:12
Notice: Undefined index: country in AddressfieldFormat\Address->format()
Notice: Undefined index: country in Drupal\addressfield\Plugin\AddressfieldFormat\Address->format() (line 209 of modules/addressfield/src/Plugin/AddressfieldFormat/Address.php).
Drupal\addressfield\Plugin\AddressfieldFormat\Address->format(Array, Array, Array)
Drupal\addressfield\Plugin\Field\FieldWidget\AddressFieldStandardWidget->formElement(Object, 0, Array, Array, Object)
Drupal\Core\Field\WidgetBase->formSingleElement(Object, 0, Array, Array, Object)
Drupal\Core\Field\WidgetBase->formMultipleElements(Object, Array, Object)
Drupal\Core\Field\WidgetBase->form(Object, Array, Object)
Drupal\Core\Entity\Entity\EntityFormDisplay->buildForm(Object, Array, Object)
Drupal\Core\Entity\ContentEntityForm->form(Array, Object)
Drupal\node\NodeForm->form(Array, Object)
@bforchhammer
bforchhammer / pre-commit
Created August 14, 2014 13:39
Pre-commit hook for pep8 + pyflakes check (.git/hooks/pre-commit)
#!/usr/bin/python
import sys
import re
import subprocess
modified = re.compile('^(?:M|A)..(?P<name>.*\.py)')
def main():
p = subprocess.Popen(['git', 'status', '--porcelain'],