Skip to content

Instantly share code, notes, and snippets.

View refs's full-sized avatar
🤖
Another pointless day where I accomplish nothing 🍸

Alex Unger refs

🤖
Another pointless day where I accomplish nothing 🍸
View GitHub Profile

Terms

Data Structures and variables

Literal

It is a value written exactly as it's meant to be interpreted. In contrast, a variable is a name that can represent different values during the execution of the program. And a constant is a name that represents the same value throughout a program. But a literal is not a name -- it is the value itself.

In the expression x = 3 x is a variable and 3 is the literal.

Benchmarking in Go

Steps

go get golang.org/x/tools/cmd/benchcmp

write a benchmark for the function:

package main

Haskell

Lists Comprehension

They are equivalent to set comprehension

Anatomy of a list comprehension:

@refs
refs / custom_json.go
Created October 19, 2018 09:14 — forked from mdwhatcott/custom_json.go
Example of implementing MarshalJSON and UnmarshalJSON to serialize and deserialize custom types to JSON in Go. Playground: http://play.golang.org/p/7nk5ZEbVLw
package main
import (
"bytes"
"encoding/json"
"fmt"
"strconv"
)
func main() {
@refs
refs / help.md
Last active November 18, 2018 12:33

Postgres

init / stop postgres daemon (9.6)

# 1. prepare the destination directory
sudo mkdir /usr/local/pgsql
sudo chmod 775 /usr/local/pgsql
sudo chown $(whoami) /usr/local/pgsql
// ==UserScript==
// @name PR Files Collapser
// @namespace http://tampermonkey.net/
// @version 0.1
// @description It collapses files on Github PR view
// @author Alex. U
// @match https://github.com/*
// @require https://code.jquery.com/jquery-2.1.4.min.js
// @grant none
// @noframes
@refs
refs / curry.js
Created January 8, 2019 21:33
Function Curry in Javascript
// curry functions with up to 2 arguments
function cTwo(fn) {
return x => {
return y => {
return fn(x, y)
}
}
}
function cThree(fn) {
@refs
refs / Postgres-stuff.md
Created March 19, 2019 12:32
things collected along the learning highway

System Monitoring Queries

SELECT pg_size_pretty( pg_database_size('dbname') ); prettified database size.

// curry functions with up to 2 arguments
function cTwo(fn) {
return x => {
return y => {
return fn(x, y)
}
}
}
function cThree(fn) {
@refs
refs / go-stdlib-interface-selected.md
Created July 18, 2019 08:49 — forked from asukakenji/go-stdlib-interface-selected.md
Go (Golang) Standard Library Interfaces (Selected)

Go (Golang) Standard Library Interfaces (Selected)

This is not an exhaustive list of all interfaces in Go's standard library. I only list those I think are important. Interfaces defined in frequently used packages (like io, fmt) are included. Interfaces that have significant importance are also included.

All of the following information is based on go version go1.8.3 darwin/amd64.