Skip to content

Instantly share code, notes, and snippets.

@fl64
fl64 / main.go
Created December 24, 2020 07:18
golang prometheus exporter example
package main
import (
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
"log"
"math/rand"
"net/http"
"time"
// The builder pattern makes it really hard to return errors during a build
// step. Consider using functional options instead, which work much better with
// incremental errors.
// Let's say you have the builder pattern.
type T struct { ... }
func (t *T) A(arg string) *T {
// do stuff here with t and arg
return t
@cpbotha
cpbotha / figure.html
Last active February 9, 2024 19:22
Drop-in replacement for Hugo figure shortcode with img srcset support
{{/*
figure with auto-resizing and srcset v2020-05-10
Drop-in replacement for Hugo's figure shortcode as of 2020-05-02 that uses img srcset
to enable browsers to download only the resolution that they need.
The resizing and srcset magic only works for images that are part of the page
bundle. It will fall back to stock Hugo figure behaviour otherwise.
import 'package:flutter/material.dart';
import 'create_connection.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter App',
@radlinskii
radlinskii / pre-commit.sh
Last active October 5, 2022 15:56
pre-commit git hook file for working in Go. Be sure to save this file in your repository as `.git/hooks/pre-commit` and give it right to execute e.g. with command `chmod +x .git/hooks/pre-commit`
#!/bin/sh
STAGED_GO_FILES=$(git diff --cached --name-only | grep ".go$")
if [[ "$STAGED_GO_FILES" = "" ]]; then
exit 0
fi
GOLINT=$GOPATH/bin/golint
GOIMPORTS=$GOPATH/bin/goimports
package main
import (
"fmt"
"log"
"net/http"
)
func init() {
log.SetFlags(log.Lshortfile)
@ParthaSSatpathy
ParthaSSatpathy / FashionMNIST.ipynb
Created August 28, 2017 02:53
Fashion MNIST - Using Tensorflow
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
package com.mmimica;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.stream.Stream;
import org.openjdk.jmh.annotations.*;
@State(Scope.Benchmark)
@BenchmarkMode(Mode.Throughput)
@Warmup(iterations = 10, time = 1, timeUnit = TimeUnit.SECONDS)
@bertrandmartel
bertrandmartel / aggregation_lookup.md
Last active December 22, 2023 13:32
MongoDB $lookup aggregation example

MongoDB $lookup aggregation

SO link

db.votes.aggregate([{
    $lookup: {
        from: "users",
        localField: "createdBy",
        foreignField: "_id",