Skip to content

Instantly share code, notes, and snippets.

View kyxap1's full-sized avatar

Oleksandr Kukhar kyxap1

View GitHub Profile
#!/usr/bin/perl -w
use strict;
use warnings;
chomp( my $OS = qx(uname -o) );
die "Not FreeBSD OS!" if ! $OS =~ /FreeBSD/;
$ENV{'PATH'} = "/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin";
my $DEV = "/dev/pass";
ondocker() {
local -a cmd=( ${@} )
# is $DOCKER forced?
[[ ${DOCKER:-} ]] || [[ ${cmd:-} ]]
# when $DOCKER not found, then try to inspect init
local re="init (1, #threads: 1)"
[[ $(head -n1 /proc/1/sched) =~ ${re} ]] || \
{ [[ -f /.dockerenv ]] || false; }
@kyxap1
kyxap1 / putty-monokai.reg
Created August 11, 2016 00:05 — forked from gdvalle/putty-monokai.reg
Monokai style theme for PuTTY; colors copied from ST2's theme
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\Sessions\monokai]
"Colour21"="255,255,255"
"Colour20"="245,222,179"
"Colour19"="200,240,240"
"Colour18"="0,217,217"
"Colour17"="179,146,239"
"Colour16"="174,129,255"
"Colour15"="122,204,218"
@kyxap1
kyxap1 / s3-curl-backups.md
Created August 11, 2016 13:18 — forked from jareware/s3-curl-backups.md
Simple, semi-anonymous backups with S3 and curl

⇐ back to the gist-blog at jrw.fi

Simple, semi-anonymous backups with S3 and curl

Backing stuff up is a bit of a hassle, to set up and to maintain. While full-blown backup suites such as duplicity or CrashPlan will do all kinds of clever things for you (and I'd recommend either for more complex setups), sometimes you just want to put that daily database dump somewhere off-site and be done with it. This is what I've done, with an Amazon S3 bucket and curl. Hold onto your hats, there's some Bucket Policy acrobatics ahead.

There's also a tl;dr at the very end if you just want the delicious copy-pasta.

Bucket setup

@kyxap1
kyxap1 / cassandra.sh
Created August 11, 2016 21:25 — forked from ixaxaar/cassandra.sh
Simple bash script to install cassandra cluster
#!/usr/bin/env bash
# A script to install cassandra
# Add the seed nodes here
SEEDS[0]='10.1.1.1'
SEEDS[1]='10.1.1.2'
SEEDS[2]='10.1.1.3'
mapfile -t SRC_PROPS < <( find ${REPO_DIR} -name "${SRC_ENV}.properties")
for file in "${SRC_PROPS[@]}"
do
mapfile -t CONTENT < "${file}"
printf "####%b\n" "${file}"
printf "%b\n" "${CONTENT[@]}" | perl -pne "s/((?=[^\W])[\w.]+)\s?=\s?(.+)/\1 = \2/"
done
server {
listen 8000;
aws_access_key your_aws_access_key;
aws_key_scope scope_of_generated_signing_key;
aws_signing_key signing_key_generated_using_script;
aws_s3_bucket your_s3_bucket;
location / {
aws_sign;
@kyxap1
kyxap1 / mdadm.sh
Last active March 12, 2017 21:55
AWS EC2: ebs instance-store: mdadm raid0 stripe in pure bash. Keep your eyes out - now you're warned.
#!/usr/bin/env bash
set -e
# Usage:
# DEVICES=(/dev/xvdf /dev/xvdg) MOUNTPOINT="/var/lib/postgresql" \
# MOUNTOPTS="relatime,nofail" CONF="/etc/mdadm/mdadm.conf" LABEL="PGDATA" \
# MD="/dev/md127" FS="xfs" RAID="ebs" /path/to/mdadm.sh
# Opts:
# FS=<xfs|ext4>
# RAID=<ebs|ephemeral|noraid>
resource "aws_route53_record" "app_cluster_reverse" {
count = "${var.app_cluster_count}"
zone_id = "${aws_route53_zone.reverse.zone_id}"
name = "${format("%s.%s.16.172.in-addr.arpa", element(split(".", element(aws_instance.app_cluster.*.private_ip, count.index)), 3), element(split(".", element(aws_instance.app_cluster.*.private_ip, count.index)), 2) )}"
type = "PTR"
ttl = "300"
records = ["${format("app-cluster-%02d.myapp.internal", count.index + 1)}"]
}
variable "aws" {
description = "Hacky switch beetween AWS default resolver and Consul."
default = {
use_consul = false
consul_domain = "service.consul"
consul_nameserver = "127.0.0.1"
aws_nameserver = "AmazonProvidedDNS"
}
}