Skip to content

Instantly share code, notes, and snippets.

View denisbrodbeck's full-sized avatar

Denis Brodbeck denisbrodbeck

View GitHub Profile
@denisbrodbeck
denisbrodbeck / IAmDisposable.cs
Created December 15, 2015 21:04 — forked from jcdickinson/IAmDisposable.cs
Disposers done right.
class IAmDisposable : IDisposable
{
private int _isDisposed;
private SomeDisposableThing _disposable1;
private SomeDisposableBar _disposable2;
private SomeDisposableBaz _disposable3;
// Only if you **need** it. You don't though, use SafeHandle.
//~IAmDisposable()
//{
@denisbrodbeck
denisbrodbeck / docker_rm_containers_images.sh
Created February 8, 2017 07:18
docker: remove all images and containers
#!/bin/bash
# Delete all containers
docker rm $(docker ps -a -q)
# Delete all images
docker rmi $(docker images -q)
# Some images might still exist
# check with: docker images
# delete with: docker rmi --force 0482a5fd046c
@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)
@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 / 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 / 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
<?
// <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 / 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

@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 / postgresql.md
Last active August 30, 2024 12:01
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: