Skip to content

Instantly share code, notes, and snippets.

Avatar
💻
Man At Work 🚜

Eduardo Pereira eduardonunesp

💻
Man At Work 🚜
View GitHub Profile
@faiface
faiface / .md
Last active Jan 23, 2020
Go 2 generics counterproposal: giving up restricting types
View .md

Go 2 generics counterproposal: giving up restricting types

"I want to make a generic function which works on any type that satisfies these and these constraints."

When we think about generics, this is the sort of problem that pops up into our minds. The critical part is restricting the set of types our function intends to work on. Trying to solve this problem of restriction has led people to what I call reasons why we hesitate to have generics in Go.

C++ templates with horrific error messages, or even it's new concepts, Java's T extends Comparable<T>, Rust's generic traits, Haskell's type classes, and sadly even contracts from the [original generics proposal by the Go Team](https://go.googlesource.com/proposal/+/master/desig

@douglasrizzo
douglasrizzo / apple-kb-manjaro.md
Last active Aug 13, 2020
Connect Apple Keyboard to Manjaro Linux
View apple-kb-manjaro.md

Blueman does not help when connecting the Apple Keyboard to Manjaro. In the future, follow these steps to fully configure it. This needs package bluez-utils.:

  1. Get the device's MAC Address:
$ bluetoothctl
[bluetooth]$ power on
Changing power on succeeded
[bluetooth]$ devices
Device 00:11:22:33:44:55 Apple Wireless Keyboard
@imyourm8
imyourm8 / bip39-loom.cs
Last active Jun 20, 2018
Generate Private Key for Loom Using BIP39
View bip39-loom.cs
// Add this function to Loom SDK CryptoUtils.cs
public static byte[] GeneratePrivateKey(byte[] seed) {
byte[] publicKey32;
byte[] privateKey64;
Ed25519.KeyPairFromSeed(out publicKey32, out privateKey64, seed);
return privateKey64;
}
// You can use any BIP39 implementation. In this example i used https://github.com/ByronAP/BIP39.NET-Portable
var mnemonic = "spin sunset pact nature enhance include fatigue occur blind wire inner foot";
@giannisp
giannisp / gist:ebaca117ac9e44231421f04e7796d5ca
Last active Sep 29, 2020
Upgrade PostgreSQL 9.6.5 to 10.0 using Homebrew (macOS)
View gist:ebaca117ac9e44231421f04e7796d5ca
After automatically updating Postgres to 10.0 via Homebrew, the pg_ctl start command didn't work.
The error was "The data directory was initialized by PostgreSQL version 9.6, which is not compatible with this version 10.0."
Database files have to be updated before starting the server, here are the steps that had to be followed:
# need to have both 9.6.x and latest 10.0 installed, and keep 10.0 as default
brew unlink postgresql
brew install postgresql@9.6
brew unlink postgresql@9.6
brew link postgresql
@tscholl2
tscholl2 / aes.go
Last active Sep 26, 2020
simple AES encryption/decryption example with PBKDF2 key derivation in Go, Javascript, and Python
View aes.go
package main
import (
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"crypto/sha256"
"encoding/hex"
"fmt"
"strings"
@denvaar
denvaar / traversal.go
Created Feb 12, 2017
Depth and Breadth-first traversal in a binary tree, implemented in Golang
View traversal.go
package main
import "fmt"
type node struct {
value string
left *node
right *node
}
@kipcole9
kipcole9 / Map.Helpers
Last active Sep 23, 2020
Helpers for Elixir Maps: underscore, atomise and stringify map keys
View Map.Helpers
defmodule Map.Helpers do
@moduledoc """
Functions to transform maps
"""
@doc """
Convert map string camelCase keys to underscore_keys
"""
def underscore_keys(nil), do: nil
@jakexks
jakexks / aws.go
Created Aug 2, 2016
Proxy in AWS SDK GO
View aws.go
package main
import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"net/http"
"net/url"
)
@ThadeuLuz
ThadeuLuz / dddsBrasileiros.json
Last active Sep 26, 2020
Objeto JSON com Estados Brasileiros por DDD e lista de DDDs por Estados.
View dddsBrasileiros.json
{
"estadoPorDdd": {
"11": "SP",
"12": "SP",
"13": "SP",
"14": "SP",
"15": "SP",
"16": "SP",
"17": "SP",
"18": "SP",
@ezimuel
ezimuel / sign.sh
Created Mar 14, 2016
Sign and verify a file using OpenSSL command line tool. It exports the digital signature in Base64 format.
View sign.sh
#!/bin/bash
# Sign a file with a private key using OpenSSL
# Encode the signature in Base64 format
#
# Usage: sign <file> <private_key>
#
# NOTE: to generate a public/private key use the following commands:
#
# openssl genrsa -aes128 -passout pass:<passphrase> -out private.pem 2048
# openssl rsa -in private.pem -passin pass:<passphrase> -pubout -out public.pem
You can’t perform that action at this time.