Skip to content

Instantly share code, notes, and snippets.

View rnkoaa's full-sized avatar

Richard Agyei rnkoaa

View GitHub Profile
@rnkoaa
rnkoaa / .tmux.conf.local
Created May 28, 2021 14:33
My tmux config
# prevent vim from losing colors
# set -g default-terminal "xterm"
set -g default-terminal "screen-256color"
tmux_conf_theme_24b_colour=true
tmux_conf_theme_focused_pane_bg='default'
tmux_conf_theme_pane_border_style=thin
tmux_conf_theme_left_separator_main='\uE0B0'
tmux_conf_theme_left_separator_sub='\uE0B1'
tmux_conf_theme_right_separator_main='\uE0B2'
package main
import (
"fmt"
"net"
"strings"
"time"
"github.com/fatih/color"
"github.com/google/go-cmp/cmp"
@rnkoaa
rnkoaa / compress_tar_gzip.go
Created January 27, 2021 00:58 — forked from mimoo/compress_tar_gzip.go
How to compress a folder in Golang using tar and gzip (works with nested folders)
package main
import (
"archive/tar"
"bytes"
"compress/gzip"
"fmt"
"io"
"os"
"path/filepath"
package main
import (
"fmt"
"strings"
)
var (
app = `db.username=hello
db.password=world
@rnkoaa
rnkoaa / main.go
Last active September 15, 2020 16:38
Golang Interfaces and Dependency Injection
package main
import (
"encoding/json"
"fmt"
"os"
)
type NotificationState int
@rnkoaa
rnkoaa / go-concurrency-context.go
Created September 7, 2020 20:51
Handling multiple goroutines with context
package main
// Here we show how to properly terminate multiple go routines by using a context.
// Thanks to WaitGroup we'll be able to end all go routines gracefully before the main function ends.
import (
"context"
"fmt"
"math/rand"
"os"
@rnkoaa
rnkoaa / pwgen.sh
Created August 14, 2020 13:37
generate random password on cli
#!/bin/bash
LENGTH=25
if [ ! -z "$1" ] && [ $1 -gt 1 ]; then
LENGTH=$1
fi
NUMBYTES=`echo $LENGTH | awk '{print int($1*1.16)+1}'`
openssl rand -base64 $NUMBYTES | tr -d "=+/" | cut -c1-$LENGTH
import React, { useReducer, useEffect, useContext, createContext } from "react";
import "./App.css";
import {
BrowserRouter as Router,
Switch,
Route,
Link,
useParams,
} from "react-router-dom";
@rnkoaa
rnkoaa / main.go
Created April 13, 2020 20:15
go-concurrency downloads
// https://gist.github.com/fracasula/b579d52daf15426e58aa133d0340ccb0
// https://blog.afoolishmanifesto.com/posts/golang-concurrency-patterns/
package main
import (
"context"
"errors"
"fmt"
"io/ioutil"
"net/http"
@rnkoaa
rnkoaa / main.go
Created March 17, 2020 01:39
using viper and cobra to build cli's that use custom config.yml file or take configs from the flags
package main
import (
"fmt"
"os"
"strings"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)