Skip to content

Instantly share code, notes, and snippets.

View boutros's full-sized avatar

Petter Goksøyr Åsen boutros

  • Oslo Public Library
  • Oslo
View GitHub Profile
@boutros
boutros / caller.go
Created March 26, 2021 13:45 — forked from ribice/caller.go
A robust rabbitmq client for Go
go func() {
for {
err = rmq.Stream(cancelCtx)
if errors.Is(err, rabbitmq.ErrDisconnected) {
continue
}
break
}
}()
@boutros
boutros / http.md
Created November 28, 2018 08:03 — forked from icholy/http.md

Experiments with the http.Handler interface

When using net/http, handling errors is kinda annoying.

http.HandleFunc("/foo", func(w http.ResponseWriter, r *http.Request) {
	thing, err := storage.Get("thing")
	if err != nil {
		http.Error(w, err.Error(), 500)
@boutros
boutros / notes.md
Created May 9, 2018 07:24 — forked from calebamiles/notes.md
Notes on Open Source Governance Models

Node.js Foundation

  • Healthy Open Source
    • explicit goal to be a lightweight process
    • concrete ability to scale to hundreds of contributors
    • good fundamental goals
      • transparency
      • participation
      • efficacy
    • ecosystem projects encouraged but not required to adopt foundation governance templates
  • creation of projects under TSC explicity delegates authority from TSC to project TC
@boutros
boutros / gist:8fe39b09e5d5df29012b17a86194e5e2
Created July 10, 2017 11:22 — forked from drkarl/gist:739a864b3275e901d317
Ask HN: Best Linux server backup system?

Linux Backup Solutions

I've been looking for the best Linux backup system, and also reading lots of HN comments.

Instead of putting pros and cons of every backup system I'll just list some deal-breakers which would disqualify them.

Also I would like that you, the HN community, would add more deal breakers for these or other backup systems if you know some more and at the same time, if you have data to disprove some of the deal-breakers listed here (benchmarks, info about something being true for older releases but is fixed on newer releases), please share it so that I can edit this list accordingly.

  • It has a lot of management overhead and that's a problem if you don't have time for a full time backup administrator.
@boutros
boutros / main.go
Created June 26, 2017 06:36 — forked from hnakamur/main.go
An example Go web app which prints localized messages
package main
import (
"context"
"html"
"log"
"net/http"
"golang.org/x/text/language"
"golang.org/x/text/message"
@boutros
boutros / translate.go
Created May 24, 2017 04:28 — forked from hvoecking/translate.go
Golang reflection: traversing arbitrary structures
// Traverses an arbitrary struct and translates all stings it encounters
//
// I haven't seen an example for reflection traversing an arbitrary struct, so
// I want to share this with you. If you encounter any bugs or want to see
// another example please comment.
//
// The MIT License (MIT)
//
// Copyright (c) 2014 Heye Vöcking
//
@boutros
boutros / Api.elm
Created March 19, 2017 07:49 — forked from kspeakman/Api.elm
JsonStuff - Elm native module to auto-encode/decode JSON
port module Api exposing (..)
import JsonStuff exposing (ToJson, FromJson, getEncoder, getDecoder)
import Http
helpPostJson : String -> ToJson a msg -> FromJson b msg -> a -> Http.Request b
helpPostJson url toJson fromJson o =
Http.request
{ method = "POST"
, headers = []
@boutros
boutros / subcommands.go
Created February 22, 2017 05:01 — forked from poy/subcommands.go
Simple Subcommands in Go
package subcommands
import (
"fmt"
"log"
"os"
"strings"
)
type Command interface {
PATH_TO_JAR="node_modules/superstartup-closure-compiler/build"
JAR="${PATH_TO_JAR}/compiler.jar"
ELM_JS_FILE="app/scripts/elm_components/elm.js"
TMP_FILE=".tmp/elm.js"
if [ ! -f ${JAR} ]; then
echo "google-closure-compiler JAR not found, make sure you `npm install` the `superstartup-closure-compiler` package"
else
java -jar ${JAR} --compilation_level=ADVANCED_OPTIMIZATIONS --js="${ELM_JS_FILE}" --js_output_file="${TMP_FILE}" --language_in=ECMASCRIPT5
mv ${TMP_FILE} ${ELM_JS_FILE}
#!/bin/bash
# This scripts scans the elasticsearch source code for all the registered REST endpoints
# It will put the formatted output in $DEFINITIONOUTPUTFILE
# [MethodName] [HttpVerb] [Route]
ESFOLDER="../elasticsearch"
DEFINITIONOUTPUTFILE="src/Generated/rest-actions.txt"
# Find all the lines that registerHandlers