Skip to content

Instantly share code, notes, and snippets.

View metakeule's full-sized avatar
💭
I may be slow to respond.

metakeule metakeule

💭
I may be slow to respond.
  • Asunción / Paraguay
View GitHub Profile
@wtask
wtask / functional-options.go
Last active June 17, 2022 22:48
Golang functional options pattern by Dave Cheney with little improvments due to practice.
// optionsptrn - inspired by https://dave.cheney.net/2014/10/17/functional-options-for-friendly-apis
package optionsptrn
import (
"errors"
"time"
// ...
)
// service - to implement SomeInterface.
@gbitten
gbitten / go2draft-generics-proposal.md
Last active February 28, 2019 15:04
Go 2 Generics - Contract with methods

Contracts with methods

Abstract

This proposal is based on Lance Taylor and Robert Griesemer's proposal for Go 2 "generics" (Contracts — Draft Design). It is identical of the original regarding type parameters, but gives a different solution for contracts.

Generic functions

According the Contracts proposal, "generic code is code that is written using types that will be specified later". To achieve that, it defines generic functions using an unspecified type called type parameter. When the code is used, the type parameter is set to a type argument.

@Splizard
Splizard / Go2GenericType.go
Last active June 10, 2020 16:53
Go 2 generics without syntax changes, 1 new type, 1 new builtin.
//A generics proposal for Go, introducing one new type (generic) and one new builtin function (typeof), no syntax changes.
//Function add takes arguments of any type.
//The return value is automatically inferred based on the arguments, can be inlined by the compiler.
//Both arguments must be the same type and addable or else a compiler error will be raised.
//It's the developer's responsibility to document which types can be passed to this function.
func add(a, b generic) generic {
return a+b
}
@rivo
rivo / postgres.go
Last active August 6, 2023 22:39
A demo Go application (a PostgreSQL database browser) highlighting the use of the rivo/tview package. See https://github.com/rivo/tview/wiki/Postgres
package main
import (
"database/sql"
"fmt"
"net/url"
"os"
"reflect"
"regexp"
"strconv"
@cfillion
cfillion / main.cpp
Last active April 10, 2023 04:07
Bare-bone REAPER extension (prints Hello World! using the API)
// Bare-bone REAPER extension
//
// 1. Grab reaper_plugin.h from https://github.com/justinfrankel/reaper-sdk/raw/main/sdk/reaper_plugin.h
// 2. Grab reaper_plugin_functions.h by running the REAPER action "[developer] Write C++ API functions header"
// 3. Grab WDL: git clone https://github.com/justinfrankel/WDL.git
// 4. Build then copy or link the binary file into <REAPER resource directory>/UserPlugins
//
// Linux
// =====
//
@mshafiee
mshafiee / .gitlab-ci.yml
Last active June 8, 2021 13:43
Gitlab CI Template For Cross Compile Golang Source Code
image: golang:latest
variables:
REPO_NAME: gitlab.com/***/***
before_script:
- go version
- echo $CI_BUILD_REF
- echo $CI_PROJECT_DIR
@aturley
aturley / pony-considerations.md
Last active March 17, 2023 03:21
Information about Pony based on the items outlined in https://twitter.com/casio_juarez/status/898706225642086400

Pony Considerations

If you're thinking of checking out the Pony programming language, here's a list of things that I think are important to know. This list is based on a Tweet that I wrote.

Editor/IDE support

There are Pony packages for several popular editors.

@wojteklu
wojteklu / bayes.go
Created February 28, 2017 20:58
Multinomial naive Bayes classifier
package bayes
// Classifier implements the Naive Bayes Classifier.
type Classifier struct {
classPerWordCount map[string]int
classPerDocument map[string]int
wordClassCount map[string]map[string]int
documentsCount int
}
@xeoncross
xeoncross / smoothing.go
Created February 9, 2017 18:37
Peak detection "Smoothed z-score algo" (in Golang) from http://stackoverflow.com/a/22640362/99923
/*
Settings (the ones below are examples: choose what is best for your data)
set lag to 5; # lag 5 for the smoothing functions
set threshold to 3.5; # 3.5 standard deviations for signal
set influence to 0.5; # between 0 and 1, where 1 is normal influence, 0.5 is half
*/
// ZScore on 16bit WAV samples
func ZScore(samples []int16, lag int, threshold float64, influence float64) (signals []int16) {
//lag := 20
@disq
disq / gcd.sh
Last active January 2, 2017 07:46
gcd: cd in GOPATH
# Put this in ~/.bash_profile
# https://gist.github.com/disq/42459b522836b25f30469b3acb5500bf
gcd() {
if [[ "$1" == "" || "$2" != "" ]]; then
echo "Usage: gcd <dir in gopath>"
return 1
fi
FINDIN=${GOPATH}/src