Skip to content

Instantly share code, notes, and snippets.

View ruanbekker's full-sized avatar
🇿🇦

Ruan Bekker ruanbekker

🇿🇦
View GitHub Profile
@ruanbekker
ruanbekker / setup-dynamodb-local.sh
Created May 21, 2016 18:53
Setup DynamoDB Local
#!/bin/bash
# usage: curl https://s3-eu-west-1.amazonaws.com/ruanbekker.repo/scripts/bootstrap-dynamodb-local.sh | sudo bash
# setup dependencies
yum update -y
yum install java-1.7.0-openjdk -y
yum install python-setuptools -y
easy_install pip
pip install boto
@ruanbekker
ruanbekker / generate-csv-data.py
Last active July 18, 2016 09:53
Generates CSV Data using the Faker library
#!/usr/bin/python
# example usage: ./generate-csv-data.py --filename data --number-runs 10000 --number-reiterations 5
from faker import Factory
import sys
import time
errInvalidArgs = "Usage: " + sys.argv[0] + " --filename" + " [STRING] " + " --number-runs" + " [INT] " + "--number-reiterations" + " [INT] "
errEg = " -> eg: " + sys.argv[0] + " --filename" + " dataset" + " --number-runs" + " 1000000 " + "--number-reiterations " + "5"
errOutput = "Outputs: dataset-timestamp.txt"
@ruanbekker
ruanbekker / generate-random-data-elasticsearch.py
Created August 8, 2016 14:35
generates random data and pushes to elasticsearch
from faker import Factory
from datetime import datetime
from elasticsearch import Elasticsearch
import json
esDomainEndpoint = "http://search-endpoint:80"
es = Elasticsearch(esDomainEndpoint)
def create_names(fake):
for x in range(100):
@ruanbekker
ruanbekker / generate-random-purchase-data.py
Last active December 21, 2016 05:39
Generates Random Transactional Data with Categories matching Shops
import random
method = ["credit", "debit", "credit", "credit", "debit", "credit", "credit", "cash", "credit"]
shop_dict = {
'Edgars': 'Clothing',
'CNA': 'Stationary',
'Sportmans Warehouse': 'Sports Equipment',
'Pick n Pay': 'Groceries',
'Rage Shoes': 'Shoes',
@ruanbekker
ruanbekker / 0_reuse_code.js
Created April 24, 2017 08:11
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@ruanbekker
ruanbekker / nested-sitemap-to-elasticsearch.py
Created April 30, 2017 13:42
Scrapes URL, Title and Keywords from Nested Sitemap to Elasticsearch
import time
import requests
from bs4 import BeautifulSoup
from elasticsearch import Elasticsearch
es_client = Elasticsearch(['http://search-domain:9200'])
drop_index = es_client.indices.create(index='myindex', ignore=400)
create_index = es_client.indices.delete(index='myindex', ignore=[400, 404])
@ruanbekker
ruanbekker / check-ssl-expiry.sh
Created May 10, 2017 18:13
Checks SSL Expiry Date with OpenSSL
#!/bin/bash
SERVER_NAME=""
echo | openssl s_client -servername $SERVER_NAME -connect $SERVER_NAME:443 2>/dev/null | openssl x509 -noout -dates
@ruanbekker
ruanbekker / flask-restful-api.py
Created June 11, 2017 22:45
Basic API Server with Flask-Restful
from flask import Flask
from flask_restful import Resource, Api
app = Flask(__name__)
api = Api(app)
class Colors(Resource):
def get(self):
return {
'colors': [
@ruanbekker
ruanbekker / alpine-python27_Dockerfile
Created July 18, 2017 14:41
Dockerfile for Python 2.7 on Alpine 3.6 (233MB)
FROM alpine:3.6
MAINTAINER Ruan Bekker
RUN apk update && \
apk add \
dumb-init \
musl \
linux-headers \
build-base \
@ruanbekker
ruanbekker / setup-elasticsearch-node-centos.sh
Created June 5, 2017 20:33
Bootstrap Script to Provision Elasticsearch Node on CentOS 7 fo ES Cluster
#!/bin/bash
# my testing was done with LXD/LXC so I had to set this on my hypervisor
# sysctl -w vm.max_map_count=262144
# set elasticsearch cluster name:
ES_CLUSTER_NAME="myescluster"
# set elasticsearch nodes ip/dns that will be part of the elasticsearch cluster
ES_NODES='["10.0.0.2", "10.0.0.3"]'