Skip to content

Instantly share code, notes, and snippets.

# Check services every 5mins
set daemon 300
# logfile location
set logfile /var/log/monit.log
# Email notifications
#set mailserver localhost # A local mailserver may be down, better to use gmail
set mailserver smtp.gmail.com port 587
username "googleuser@gmail.com" password "googlepass"
@daledude
daledude / mysql-innodb-bulk-inserts.sql
Created June 3, 2016 18:26 — forked from kbsali/mysql-innodb-bulk-inserts.sql
Mysql InnoDB + MyIsam bulk insert statements
LOCK TABLES `table_name` WRITE;
SET autocommit=0;
SET foreign_key_checks=0;
SET unique_checks=0;
/*....
INSERT ... ON DUPLICATE KEY UPDATE
INSERT IGNORE INTO
....*/
#!/bin/bash
## Copyright (C) 2009 Przemyslaw Pawelczyk <przemoc@gmail.com>
##
## This script is licensed under the terms of the MIT license.
## https://opensource.org/licenses/MIT
#
# Lockable script boilerplate
### HEADER ###
@daledude
daledude / xdp_load_balancer.c
Created November 12, 2017 09:22 — forked from summerwind/xdp_load_balancer.c
XDP based load balancer with L3DSR support
#define KBUILD_MODNAME "load_balancer"
#include <uapi/linux/bpf.h>
#include <linux/in.h>
#include <linux/if_ether.h>
#include <linux/if_packet.h>
#include <linux/if_vlan.h>
#include <linux/ip.h>
#include <linux/ipv6.h>
BPF_HASH(counter, uint32_t, long);
@daledude
daledude / clickhouse_build_centos.sh
Created April 1, 2019 23:43 — forked from filimonov/clickhouse_build_centos.sh
Clickhouse build on Centos 6/ Centos 7 / RedHat
# Tested on Centos 6.9 and Centos 7.4. ClickHouse vesion 1.1.54236
# Official build instructions:
# https://github.com/yandex/ClickHouse/blob/master/doc/build.md
# See also https://github.com/redsoftbiz/clickhouse-rpm
# and https://github.com/Altinity/clickhouse-rpm
export THREADS=$(grep -c ^processor /proc/cpuinfo)
# Determine RHEL major version
RHEL_VERSION=`rpm -qa --queryformat '%{VERSION}\n' '(redhat|sl|slf|centos|oraclelinux|goslinux)-release(|-server|-workstation|-client|-computenode)'`
@daledude
daledude / type_conversion.go
Created July 14, 2020 05:05 — forked from stupidbodo/type_conversion.go
Golang Type Conversion
// Playbook: http://play.golang.org/p/kp5uL_mMGk
// Note: Type assertion like "someVariable.(string)" is useful when you are dealing with interface{} (empty interface)
package main
import (
"fmt"
"strconv"
)
cni-bash-plugin
files:
/etc/rkt/net.d/bridge.sh.conf
/etc/rkt/net.d/bridge-dhcp.sh
/etc/rkt/net.d/bridge.sh
usage:
rkt run \
--insecure-options=all \
@daledude
daledude / iptables-cheatsheet.md
Created February 10, 2022 06:48 — forked from mcastelino/iptables-cheatsheet.md
iptables-cheatsheet

The netfilter hooks in the kernel and where they hook in the packet flow

The figure below calls out

  • The netfilter hooks
  • The order of table traversal
@daledude
daledude / gopowerseries.go
Created June 10, 2022 17:43
go concurrency power series
// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Test concurrency primitives: power series.
// Power series package
// A power series is a channel, along which flow rational
@daledude
daledude / Caddyfile.tmpl
Created December 10, 2023 05:42 — forked from optiz0r/Caddyfile.tmpl
Caddy with Nomad + Consul
{{- range services -}}
{{- if .Name | contains "sidecar" | not -}}
{{- $groupedServices := (service .Name | byMeta "caddy_enable") -}}
{{- $enabledServices := (index $groupedServices "true" ) -}}
{{- range $enabledServices -}}
{{- $vhost := index .ServiceMeta "caddy_vhost" -}}
{{- scratch.MapSetX "vhosts" $vhost . -}}
{{- end -}}
{{- end -}}
{{- end -}}