Skip to content

Instantly share code, notes, and snippets.

View avi-beetul's full-sized avatar

Avi Beetul avi-beetul

  • Melbourne
View GitHub Profile
@avi-beetul
avi-beetul / postgres cheatsheet.md
Created November 14, 2018 03:53 — forked from apolloclark/postgres cheatsheet.md
postgres cheatsheet

Postgres Cheatsheet

This is a collection of the most common commands I run while administering Postgres databases. The variables shown between the open and closed tags, "<" and ">", should be replaced with a name you choose. Postgres has multiple shortcut functions, starting with a forward slash, "". Any SQL command that is not a shortcut, must end with a semicolon, ";". You can use the keyboard UP and DOWN keys to scroll the history of previous commands you've run.

Setup

installation, Ubuntu

http://www.postgresql.org/download/linux/ubuntu/ https://help.ubuntu.com/community/PostgreSQL

import boto3
from botocore.exceptions import ClientError
import os
import sys
import json
sys.argv = sys.argv[1:]
if sys.argv:
# first elem of sys argument must be a comma separated list
@avi-beetul
avi-beetul / dns_route53.py
Last active June 28, 2018 07:53
dns_route53.py
#!/usr/bin/env python
"""
This script can be used to create, update single, update batch and delete DNS record-set in aws Route53.
Pass `AWS PROFILE`, `domain name` as command-line argument to create a connection to aws account.
Depending on the action, set params name and/or value as command-line argument.
Example: python dns_route53.py create_record aws_profile domain name type value
Requirements:
sudo pip install boto dnspython
@avi-beetul
avi-beetul / ansible-summary.md
Created May 7, 2018 07:06 — forked from andreicristianpetcu/ansible-summary.md
This is an ANSIBLE Cheat Sheet from Jon Warbrick

An Ansible summary

Jon Warbrick, July 2014, V3.2 (for Ansible 1.7)

Configuration file

intro_configuration.html

First one found from of

@avi-beetul
avi-beetul / handler.py
Created March 13, 2018 04:38 — forked from patrickbrandt/handler.py
Restricting Lambda function by IP address
import json
import os
def ping(event, context):
ip1 = event['headers']['X-Forwarded-For'].split(',')[0]
ip2 = event['requestContext']['identity']['sourceIp']
print('two different referring IP address parsing techniques ip1: %s and ip2: %s') % (ip1, ip2)
referringIP = event['requestContext']['identity']['sourceIp']
#TODO: use a comma-delimited string to store multiple IP address values in the environment variable
@avi-beetul
avi-beetul / docker-clean.sh
Last active March 14, 2018 06:11
Docker cleanup
#!/bin/bash
echo -e "-- Removing exited containers --\n"
sudo docker rm $(sudo docker ps -q -f status=exited)
echo -e "\n\n-- Removing untagged images --\n"
sudo docker rmi $(sudo docker images -a -q)
echo -e "\n\n-- Removing all dangling volumes --\n"
sudo docker volume rm $(sudo docker volume ls -qf dangling=true)
from boto.route53.connection import Route53Connection
import urllib2
from syslog import syslog
# ======= CONFIG ========
AWS_ACCESS_KEY_ID = 'XXXXXXXXXXXXXXXXXX'
AWS_SECRET_ACCESS_KEY = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXX'
DDNSNAME = "foo.example.com." # Should end in period
ZONEID = "XXXXXXXXX"
# ===== END CONFIG ======
"""
Requeriments:
$ sudo pip install boto dnspython
Edit ~/.boto to use your AWS credentials
"""
import time
import sys