Skip to content

Instantly share code, notes, and snippets.

View srkiNZ84's full-sized avatar

Srđan (Serge) Đukić srkiNZ84

View GitHub Profile

Keybase proof

I hereby claim:

  • I am srkiNZ84 on github.
  • I am srdandukic (https://keybase.io/srdandukic) on keybase.
  • I have a public key whose fingerprint is 6F8B 56EE 24F4 D493 08C7 8373 EFF4 107E 29A3 A3C7

To claim this, I am signing this object:

@srkiNZ84
srkiNZ84 / signal_trap_test.sh
Created April 13, 2015 22:27
Simple script to test/demo simple signal handling in bash
#!/bin/bash
function sigusr1 {
echo "Received SIGUSR1."
STOP_EXECUTION=1
echo "Stopping execution after current item"
}
trap 'sigusr1' USR1
@srkiNZ84
srkiNZ84 / backup_db_glacier_encrypted
Last active August 30, 2017 20:14
Shell script to backup MySQL database to AWS Glacier, using GPG for encryption
#!/bin/bash
DBUSER=[db user here]
DBPW=[db pass here]
DBNAME=[db name here]
GPGID=[gpg email here]
GLACIER_VAULT=[aws glacier vault here]
WORKDIR=/tmp
DATETIME=`date +%F-%H%M%S-%z`
@srkiNZ84
srkiNZ84 / dns.py
Last active October 13, 2015 15:30
Datadog agent DNS check
import time
import socket
from checks import AgentCheck
from hashlib import md5
class DNSCheck(AgentCheck):
def check(self, instance):
if 'hostname' not in instance:
self.log.info("Skipping instance, no hostname found.")
@srkiNZ84
srkiNZ84 / dns.yaml
Created July 22, 2015 22:29
Sample DNS configuration for Datadog DNS check
init_config:
default_timeout: 5
instances:
- hostname: www.google.com
- hostname: www.yahoo.com
timeout: 8
- hostname: www.ubuntu.com
@srkiNZ84
srkiNZ84 / .bash_profile
Created September 10, 2015 03:56
Add SSH key to agent on bash startup
SSHAGENT=/usr/bin/ssh-agent
SSHAGENTARGS="-s"
if [ -z "$SSH_AUTH_SOCK" -a -x "$SSHAGENT" ]; then
eval `$SSHAGENT $SSHAGENTARGS`
trap "kill $SSH_AGENT_PID" 0
fi
/usr/bin/ssh-add ~/some_private_key.pem
@srkiNZ84
srkiNZ84 / login.py
Last active November 28, 2016 21:44
Simple AWS lambda function to demo "login"
from __future__ import print_function
import json
print('Loading login function')
def lambda_handler(event, context):
print('username gotten: ' + event['username'])
print('password gotten: ' + event['password'])
if(event['username'] == 'foo' and event['password'] == 'barbaz'):
- hosts: all
tasks:
- name: Put New version of credentials into DynamoDB
connection: local
command: credstash -p srdan put -a foopass blahblahblah
- name: Get credentials from DynamoDB
connection: local
debug: msg="Credstash lookup {{ lookup('credstash', 'foopass', profile_name='srdan') }}"
ignore_errors: true
@srkiNZ84
srkiNZ84 / gist:a08f3897069117167e6d9473c3f0818e
Created February 24, 2017 10:09
Lambda super simple login
from __future__ import print_function
import json
print('Loading login function')
def lambda_handler(event, context):
# TODO implement
#return 'Hello from Lambda'
@srkiNZ84
srkiNZ84 / envs_check.sh
Created November 5, 2017 23:53
Bash example how to check whether env vars are set
if [[ -z $FOO || -z $BAR ]]
then
echo "Either FOO, BAR (or both) not set"
exit 1
fi
echo "FOO and BAR must be set"