Skip to content

Instantly share code, notes, and snippets.

@tkhn
tkhn / LearnGoIn5mins.md
Created January 4, 2021 21:47 — forked from prologic/LearnGoIn5mins.md
Learn Go in ~5mins
@tkhn
tkhn / 00-clamav-notes.sh
Created February 14, 2020 18:39 — forked from AfroThundr3007730/00-clamav-notes.sh
My notes on getting ClamAV working on CentOS 7
# How to get ClamAV working on CentOS 7
yum -y install epel-release && yum -y update
yum -y install clamav clamav-data clamav-scanner clamav-scanner-systemd clamav-server clamav-server-systemd clamav-unofficial-sigs clamav-update
# Add /etc/clamd.d/freshclam.conf
# Add /usr/lib/systemd/system/clamav-freshclam.service
systemctl enable clamav-freshclam.service && systemctl start clamav-freshclam.service
@tkhn
tkhn / commands-channel.go
Created November 28, 2019 19:56 — forked from proudlygeek/commands-channel.go
Golang Commands in Goroutines
package main
import (
"fmt"
"log"
"os/exec"
"runtime"
)
type Worker struct {
package main
import ("fmt"; "math")
// interfaces
type Shaper interface {
area() float64
perimeter() float64
}
@tkhn
tkhn / linux.sh
Created November 4, 2019 17:10 — forked from josephspurrier/linux.sh
Install Go
# Download Go (use any of the latest versions)
curl -O https://storage.googleapis.com/golang/go1.8.linux-amd64.tar.gz
# Extract Go
tar -xvf go*.tar.gz
# Install Go
sudo mv go /usr/local
# Create a workspace folder
@tkhn
tkhn / structs_interface.go
Created November 4, 2019 17:06 — forked from josephspurrier/structs_interface.go
Golang - Understand Structs and Interfaces
// Also available at: https://play.golang.org/p/yTTpB5gB6C
package main
import (
"fmt"
)
// *****************************************************************************
// Example 1 - Struct vs Struct with Embedded Type
@tkhn
tkhn / export-node-stats.md
Created October 21, 2019 16:33 — forked from ScriptingSquirrel/export-node-stats.md
Setup prometheus-node-exporter and push stats to Pushgateway with cron job

(Assuming a Debian 8-like system)

  • Install prometheus-node-exporter

    $ sudo apt update && sudo apt install prometheus-node-exporter
  • Configure prometheus-node-exporter to expose metrics only to localhost, not on to all networks. Modify file /etc/default/prometheus-node-exporter:

    # Set the command-line arguments to pass to the server.
@tkhn
tkhn / example_flask_googlecaptcha.py
Created October 2, 2019 18:46 — forked from sameerkumar18/example_flask_googlecaptcha.py
A Simple Python Flask Example for Google Recaptcha (implemented on http://ipusearch.herokuapp.com)
RECAPTCHA_PUBLIC_KEY = '<public key>'
RECAPTCHA_PRIVATE_KEY = '<private key>'
def checkRecaptcha(response, secretkey):
url = 'https://www.google.com/recaptcha/api/siteverify?'
url = url + 'secret=' + str(secretkey)
url = url + '&response=' +str(response)
@tkhn
tkhn / map_reduce_sorting.py
Created June 20, 2019 19:14 — forked from mkowoods/map_reduce_sorting.py
An example of how to use map reduce logic to sort a file that is greater than the size of memorey
import random
import os
random.seed(42)
F_PATH = "data.csv"
OUTPUT_PATH_TEMPLATE = "tmp_%d.csv"
CHUNK_SIZE = 5