Skip to content

Instantly share code, notes, and snippets.

View denisbrodbeck's full-sized avatar

Denis Brodbeck denisbrodbeck

View GitHub Profile
#!/bin/vbash
# CONFIG
wan=dhcp
lan=192.168.1.1
lan_segment=192.168.1.0
vpn_segment=192.168.5.0
domain=apertoire.org
lease_start=192.168.1.200
lease_stop=192.168.1.245
@denisbrodbeck
denisbrodbeck / fetch.go
Created June 27, 2018 11:08 — forked from hriddhidey/fetch.go
Fetch makes network calls using the method (POST/GET..), the URL // to hit, headers to add (if any), and the body of the request. This function can serve as a singular resource for all your network calls to pass through, thus becoming an http interceptor. You may add a lot of n/w layer related customizations here as you wish - headers, auth, red…
// Fetch makes network calls using the method (POST/GET..), the URL // to hit, headers to add (if any), and the body of the request.
// Feel free to add more stuff to before/after making the actual n/w call!
func Fetch(method string, url string, header map[string]string, body io.Reader) (*http.Response, err) {
// Create client with required custom parameters.
// Options: Disable keep-alives, 30sec n/w call timeout.
client := &http.Client{
Transport: &http.Transport{
DisableKeepAlives: true,
},
Timeout: time.Duration(10 * time.Second),
@denisbrodbeck
denisbrodbeck / postgresql.md
Last active June 6, 2018 03:53
Notes on Postgresql

Notes on PostgreSQL

Most notes have been taken from the book PostgreSQL: Up and Running which I highly recommend. Buy it, loads of little gems inside.

Database Administration

Database Creation

The minimum SQL command to create a database is:

@denisbrodbeck
denisbrodbeck / howto.md
Created September 25, 2017 11:32
How to measure execution time of functions in golang

How to measure execution time of functions in golang

Nice snippet from Stathat:

func timeTrack(start time.Time, name string) {
    elapsed := time.Since(start)
    log.Printf("%s took %s\n", name, elapsed)
}
func tracked() {
@denisbrodbeck
denisbrodbeck / setup-dev-vm.md
Last active November 13, 2017 13:23
Setup dev environment for golang and nodejs on ubuntu 16.04 vm.

How to create my dev environment for golang and nodejs on an Ubuntu 16.04 VM.

  • update os and install vm tools, git and fish
  • setup fish with oh-my-fish and theme bobthefish (bobthefish is a theme similar to agnoster)
  • install nodejs 8.x and yarn
  • fix npm permission issues
  • install go
  • install vs code

Setup base system

<?
// <readme>
/*
This is a lite version of Olark's and Intercom's functionality (without the chat part).
It lets you get feedback from users on your site to your email.
And you won't have to rely on another company anymore!
#killyourdependencies
@denisbrodbeck
denisbrodbeck / how_to_install_pgadmin4_on_ubuntu_1604_in_desktop_mode.md
Created June 2, 2017 07:51
How to install pgadmin 4 on Ubuntu 16.04 in desktop mode

How to install pgadmin 4 on Ubuntu 16.04 in desktop mode

mkdir -p ~/apps/pgadmin4
cd ~/apps/pgadmin4
virtualenv venv -p /usr/bin/python2.7
source ./venv/bin/activate
wget https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v1.5/pip/pgadmin4-1.5-py2.py3-none-any.whl
pip install six
pip install pgadmin4-1.5-py2.py3-none-any.whl
@denisbrodbeck
denisbrodbeck / main.go
Last active February 2, 2023 22:35
How to generate secure random strings in golang with crypto/rand.
// License: MIT
package main
import (
"crypto/rand"
"fmt"
"math/big"
)
// GenerateRandomASCIIString returns a securely generated random ASCII string.
@denisbrodbeck
denisbrodbeck / main.go
Created March 13, 2017 10:25
Minimal fsm (finite state machine) in golang.
package main
import "fmt"
// State provides the minimal state machine
type State func() (next State)
func tick() State {
fmt.Println("tick...")
return tock
@denisbrodbeck
denisbrodbeck / sh
Last active February 24, 2017 17:26
Delete directories based on find results in Linux
# Search directories with name node_modules
find . -name 'node_modules' -type d
# Displays parent folders and child folders
./laravel/passport/node_modules (parent)
./laravel/passport/node_modules/yargs-parser/node_modules (child)
./laravel/passport/node_modules/gauge/node_modules (child)
./hapi/hapi-auth-jwt2/node_modules (parent)
./hapi/hapi-auth-jwt2/node_modules/acorn-jsx/node_modules (child)
./hapi/hapi-auth-jwt2/node_modules/optimist/node_modules (child)