Skip to content

Instantly share code, notes, and snippets.

View nesizer's full-sized avatar

Mikkel H Madsen nesizer

  • ProLøn A/S
  • Denmark
View GitHub Profile
@nesizer
nesizer / slow_query_handler.ex
Created January 16, 2022 20:37 — forked from joshnuss/slow_query_handler.ex
Output slow Ecto queries to logs
defmodule MyApp.Telemetry do
require Logger
def handle_event([:my_app, :repo, :query], measurements, metadata, _config) do
milliseconds = System.convert_time_unit(measurements.total_time, :native, :millisecond)
# did the query take longer than 100ms?
if milliseconds > 100 do
# log it as a warning
Logger.warn("SLOW QUERY: ms: #{milliseconds}, query: #{metadata.query}")
@nesizer
nesizer / AuthyToOtherAuthenticator.md
Created December 9, 2020 15:41 — forked from gboudreau/AuthyToOtherAuthenticator.md
Export TOTP tokens from Authy

Generating Authy passwords on other authenticators


There is an increasing count of applications which use Authy for two-factor authentication. However many users who aren't using Authy, have their own authenticator setup up already and do not wish to use two applications for generating passwords.

Since I use 1Password for all of my password storing/generating needs, I was looking for a solution to use Authy passwords on that. I couldn't find any completely working solutions, however I stumbled upon a gist by Brian Hartvigsen. His post had a neat code with it to generate QR codes for you to use on your favorite authenticator.

His method is to extract the secret keys using Authy's Google Chrome app via Developer Tools. If this was not possible, I guess people would be reverse engineering the Android app or something like that. But when I tried that code, nothing appeared on the screen. My guess is that Brian used the

@nesizer
nesizer / rocketguide.md
Created June 11, 2018 17:19 — forked from belst/rocketguide.md
Deploy Rocket in production

Deploy Rocket using Letsencrypt and nginx

Information

This guide uses the domain your-domain.tld and its www. prefixed version. It starts the rocket application on 127.0.0.1:1337 and as the user www-data. The proxy listens on port 80 and 443 though.
If you need other values, update them accordingly in your nginx and systemd configs.

Prerequisites

You need to have nginx, certbot and rust installed.

@nesizer
nesizer / Gulpfile.js
Created October 13, 2015 20:38
Building Web Applications in Golang With Gulp and LiveReload (http://bit.ly/1ELbcl1)
/*
* Copyright (c) 2015 Martin Donath
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
public static class AutofacScanningExtensions
{
public static IRegistrationBuilder<object, ScanningActivatorData, DynamicRegistrationStyle>
RegisterAssemblyTypesFromPath(this ContainerBuilder builder, string path)
{
return RegisterAssemblyTypesFromPath(builder, path, null, a => true);
}
public static IRegistrationBuilder<object, ScanningActivatorData, DynamicRegistrationStyle>
RegisterAssemblyTypesFromPath(this ContainerBuilder builder, string path, Predicate<Assembly> Assemblyfilter)