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
@joshnuss
joshnuss / slow_query_handler.ex
Last active July 9, 2023 09:26
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}")
@timvisee
timvisee / falsehoods-programming-time-list.md
Last active June 27, 2024 17:47
Falsehoods programmers believe about time, in a single list

Falsehoods programmers believe about time

This is a compiled list of falsehoods programmers tend to believe about working with time.

Don't re-invent a date time library yourself. If you think you understand everything about time, you're probably doing it wrong.

Falsehoods

  • There are always 24 hours in a day.
  • February is always 28 days long.
  • Any 24-hour period will always begin and end in the same day (or week, or month).
@gboudreau
gboudreau / AuthyToOtherAuthenticator.md
Last active June 28, 2024 14:47 — forked from Ingramz/AuthyToOtherAuthenticator.md
Export TOTP tokens from Authy
// Copyright 2016 Google Inc. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
// Command caption reads an audio file and outputs the transcript for it.
package main
import (
"fmt"
"io"
@aggrolite
aggrolite / redditbot.md
Last active January 6, 2022 13:44
Writing a reddit bot with Go and OAuth2
@cryptix
cryptix / vineScrape.go
Created August 27, 2014 12:31
extract a javascript object value from a html page using goquery and otto
package main
import (
"errors"
"log"
"os"
"github.com/PuerkitoBio/goquery"
"github.com/robertkrimen/otto"
)
@AviDuda
AviDuda / README.md
Last active April 23, 2024 10:32
Unmuting Twitch VODs
@koenpunt
koenpunt / chosen-bootstrap.css
Last active March 11, 2023 01:01
Bootstrap 3.0 theme for Chosen
select.form-control + .chosen-container.chosen-container-single .chosen-single {
display: block;
width: 100%;
height: 34px;
padding: 6px 12px;
font-size: 14px;
line-height: 1.428571429;
color: #555;
vertical-align: middle;
background-color: #fff;
@christianbundy
christianbundy / random_uniques.js
Last active December 21, 2015 09:49
Generates a set of random unique integers.
// do not use this
function random_uniques(min, max, num) {
if (max-min > num) {
_result = {};
for (i = 1; i<=num; i++) {
_unique=false;
while (!_unique) {
_new = Math.round((Math.random()*max)+min);
for (j = 1; j<=i; j++) {
package main
import (
"fmt"
"time"
)
func main() {
t, err := time.Parse(time.RFC3339Nano, "2013-06-05T14:10:43.678Z")
if err != nil {