Skip to content

Instantly share code, notes, and snippets.

View ruanbekker's full-sized avatar
🇿🇦

Ruan Bekker ruanbekker

🇿🇦
View GitHub Profile
@ruanbekker
ruanbekker / s3_get_bucket_acls_public.py
Last active August 1, 2017 19:19
Get All S3 Bucket Names that is Public Readable, and if so set to Private
import boto3
GROUPS_ALLUSERS = 'http://acs.amazonaws.com/groups/global/AllUsers'
GLOBAL_AUTHUSERS = 'http://acs.amazonaws.com/groups/global/AuthenticatedUsers'
s3 = boto3.client('s3')
list_buckets = s3.list_buckets()['Buckets']
available_buckets = []
@ruanbekker
ruanbekker / cheatsheet-aws-iam-s3.md
Last active August 14, 2017 06:32
AWS IAM S3 Policy Cheatsheet for S3

IAM Policies for S3

S3 Bucket Policy

IAM Policy:

List Bucket, Read Access to Objects in Path:

{
@ruanbekker
ruanbekker / setup-ruby-rails-env.sh
Created August 16, 2017 11:46
Setup Ruby on Rails Environment
#!/bin/bash
curl -L get.rvm.io | bash -s stable
source ~/.rvm/rvm.sh
rvm requirements
rvm install 2.4
rvm use 2.4 --default
rvm rubygems current
gem install rails
@ruanbekker
ruanbekker / cheatsheet-ruby.md
Created September 3, 2017 22:22
My Ruby Cheatsheet

Printing

Printing:

> puts "foo"
foo

Set a Variable and Printing the Value of the Variable:

@ruanbekker
ruanbekker / scraper-octopress-to-elasticsearch.py
Created October 14, 2017 21:27
Python Web Scraper for Octopress which Pushes Data to ES
# centos: libxslt-devel python-devel
# debian:
import re
import time
import requests
from bs4 import BeautifulSoup
from elasticsearch import Elasticsearch
es_client = Elasticsearch(['http://10.0.1.11:9200'])
@ruanbekker
ruanbekker / setup-payara41-domain-ubuntu.sh
Created November 26, 2017 00:53
Setup Payara Domain
#!/usr/bin/env bash
# https://github.com/payara/Payara-Examples/tree/master/Administration-Samples
DOMAIN_NAME="u1t-domain"
PAYARA_HOME="/opt/payara"
ASADMIN=${PAYARA_HOME}/bin/asadmin
PORT_BASE="4800"
ADMIN_PORT=$(($PORT_BASE + 48))
DEPLOYMENTS_LOCATION="/opt/payara/applications"
@ruanbekker
ruanbekker / setup-payara41-ubuntu.sh
Last active November 26, 2017 00:54
Setup Java 8 and Payara41 on Ubuntu 16
#!/usr/bin/env bash
apt update && apt upgrade -y
apt install unzip software-properties-common python-software-properties -y
add-apt-repository ppa:webupd8team/java
echo debconf shared/accepted-oracle-license-v1-1 select true | debconf-set-selections
echo debconf shared/accepted-oracle-license-v1-1 seen true | debconf-set-selections
apt update
apt install oracle-java8-installer -y
echo 'JAVA_HOME="/usr/lib/jvm/java-8-oracle"' >> /etc/environment
@ruanbekker
ruanbekker / bash-if-statements.md
Created December 5, 2017 22:10
Bash IF Statements

Exists

Check if a Directory exists:

if [ -d "./data" ]
  then echo "true"
  else echo "false"
fi
@ruanbekker
ruanbekker / auth_pass_input.py
Created January 22, 2018 10:43
Using Getpass to prompt for sensitive info without prompting for it
import getpass
text = getpass.getpass(prompt='Enter your passphrase to encrypt ')
print("You have entered: {}".format(text))
@ruanbekker
ruanbekker / crypto-coindata-cardano-watcher.py
Created January 22, 2018 18:32
Checks the Last 1H and last 24H Data of Cardano on Coindata
#!/usr/bin/python
import requests
import json
baseurl = 'https://coindata.co.za/api.php'
r = requests.get(baseurl).content
j = json.loads(r)
for crypto in j: