Skip to content

Instantly share code, notes, and snippets.

@kgorskowski
kgorskowski / coreos-ecs-agent-cloudformation.template
Last active December 31, 2017 14:35
AWS CloudFormation Template for CoreOS stable including AWS ECS Agent. Provide ECS - Cluster and IAM Role, otherwise the ECS service will not work
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "CoreOS on EC2: http://coreos.com/docs/running-coreos/cloud-providers/ec2/",
"Mappings" : {
"RegionMap" : {
"eu-central-1" : {
"AMI" : "ami-487d4d55"
},
@kgorskowski
kgorskowski / gist:101512270c5d6e17012f
Created January 24, 2015 12:41
remove dockercontainer per name in CoreOs Unit within ExecStart or ExecPreStart:
ExecStart=/usr/bin/bash -c '/usr/bin/docker kill $(/usr/bin/docker ps -aq —filter="name=containername") || true'
[Unit]
Description=Demonstrate Bash
[Service]
ExecStartPre=/usr/bin/bash -c "/usr/bin/systemctl set-environment MYVAR=$(( 2 + 2 ))"
ExecStart=/usr/bin/ech "2 + 2 = ${MYVAR}"
@kgorskowski
kgorskowski / mysqlbackup.sh
Created March 19, 2015 15:02
mysqldum script with sync to s3
#!/bin/bash
#Variables
MySQLUser="root"
TIMESTAMP=$(date +"%Y-%m-%d-%H-%M")
LOGDIR=
LOGFILE=
FILENAME=backup_$TIMESTAMP.sql.gz
# export database
@kgorskowski
kgorskowski / secret.rb
Created March 19, 2015 22:50
create encrypted data bags for chef manually
require 'rubygems'
require 'chef/encrypted_data_bag_item'
secret = Chef::EncryptedDataBagItem.load_secret('chef_secret')
data = {"id" => "name_of_secret_goes_here", "key" => 'secret_goes_here'}
encrypted_data = Chef::EncryptedDataBagItem.encrypt_data_bag_item(data, secret)
FileUtils.mkpath('data_bags/passwords')
File.open('data_bags/passwords/name_of_secret_goes_here.json', 'w') do |f|
f.print encrypted_data.to_json
@kgorskowski
kgorskowski / lsyncd.conf.lua
Created March 25, 2015 15:11
server to server synchronisation with lsyncd
settings {
logfile = "/var/log/lsyncd/lsyncd.log",
statusFile = "/var/log/lsyncd/lsyncd.status"
}
sync {
default.rsyncssh,
source = "/sites/",
host = "x.x.x.x",
targetdir = "/sites/",
exclude = {"*.bak" , "*.tmp" , "*.log" },
@kgorskowski
kgorskowski / iptables_mysql_drop
Last active August 29, 2015 14:17
iptables drop external mysql access
iptables -A INPUT -p tcp --dport 3306 -i eth0 -j DROP
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:GetBucketLocation",
"s3:ListBucket"
],
"Resource": [
{
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:Get*",
"s3:List*"
],
"Resource": [
"arn:aws:s3:::BUCKET",
@kgorskowski
kgorskowski / gist:6534fcfb591d91c47f3a
Last active August 29, 2015 14:18
ffmpeg for audiowavelength conversion
ffmpeg -i audioinput.mp3 -loop 1 -i backgroundpic.png -filter_complex "[0:a]channelsplit[a1][a2];[a1]showwaves=s=960x270:mode=p2p:rate=15,format=yuv420p,colorbalance=gs=0.49,colorbalance=bs=0.34,colorbalance=rm=1,colorbalance=gm=1,colorbalance=bm=1,scale=1920x540[bottom];[1:v][bottom]overlay=shortest=1:main_h/2[vid]" -map "[a2]" -c:a /dev/null -map "[vid]" -map 0:a -codec:v libx264 -crf 18 -tune animation -preset fast -r 15 -codec:a aac -strict -2 -b:a 192k output.mp4