Skip to content

Instantly share code, notes, and snippets.

:octocat:

Ruan Bekker ruanbekker

:octocat:
Block or report user

Report or block ruanbekker

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ruanbekker
ruanbekker / write_gamescores_to_dynamodb.py
Created Jun 23, 2019
Generate Gamescores to DynamoDB from Blogpost
View write_gamescores_to_dynamodb.py
# from blogpost:
# - https://sysadmins.co.za/experimenting-the-client-interface-for-dynamodb-in-boto3-with-gamescores/
import boto3
import time
import random
import datetime
client = boto3.Session(region_name='eu-west-1', profile_name='test').client('dynamodb')
# dynalite
# client = boto3.Session(region_name='eu-west-1').client('dynamodb', aws_access_key_id='', aws_secret_access_key='', endpoint_url='http://localhost:4567')
@ruanbekker
ruanbekker / python_requests_elasticsearch_iam.py
Created Jun 21, 2019
Authenticate AWS Elasticsearch Requests with Requests and RequestsAws4Auth
View python_requests_elasticsearch_iam.py
import boto3
import json
import requests
from requests_aws4auth import AWS4Auth
host = 'https://search-domain-name-xx.eu-west-1.es.amazonaws.com'
region = 'eu-west-1'
service = 'es'
headers = {'Content-Type': 'application/json'}
@ruanbekker
ruanbekker / swarm.yml
Created Jun 15, 2019 — forked from MetalArend/swarm.yml
Run a GitLab Runner on your Swarm
View swarm.yml
version: '3.4'
secrets:
# Find your registration token at: "Your project" > "Settings" > "CI/CD" > "Runners settings" > "Specific Runners" (look for registration token)
# Register it as `GITLAB_REGISTRATION_TOKEN`: `docker secret create GITLAB_REGISTRATION_TOKEN YOUR_REGISTRATION_TOKEN`
GITLAB_REGISTRATION_TOKEN:
external: true
# Find your personal access token at: "Your user account" > "Settings" > "Access Tokens" > "Create personal access token" (for api)
# Register it as `GITLAB_PERSONAL_ACCESS_TOKEN`: `docker secret create GITLAB_PERSONAL_ACCESS_TOKEN <YOUR ACCESS TOKEN>`
@ruanbekker
ruanbekker / index_center.html
Created Jun 9, 2019
Center Image in Center of Page in HTML
View index_center.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="description" content="python web page for kubernetes demo">
<meta name="keywords" content="kubernetes,python,web">
<meta name="author" content="Ruan Bekker">
<title>Python Page</title>
@ruanbekker
ruanbekker / mac_docker_swarm.sh
Last active May 27, 2019
Setup Docker-in-Docker Swarm
View mac_docker_swarm.sh
#!/bin/bash
# Credit: https://callistaenterprise.se/blogg/teknik/2017/12/18/docker-in-swarm-mode-on-docker-in-docker/
# https://hub.docker.com/_/docker?tab=tags
# https://www.blog.labouardy.com/docker-swarm-networking-and-dynamic-reverse-proxy/
SWARM_ENABLED=true
DOCKER_VERSION=18.06.3-ce-dind
NUM_WORKERS=3
if [ ${SWARM_ENABLED} == "false" ]
@ruanbekker
ruanbekker / random_num.sh
Created May 25, 2019
Selecting Random Numbers in BASH
View random_num.sh
# create the array
for x in {1..1000}
do
array[$x]="$x"
done
# print random number between 1-1000
size=${#array[@]}
echo ${array[$(($RANDOM % $size))]}
@ruanbekker
ruanbekker / clean-up-boot-partition-ubuntu.md
Created May 17, 2019 — forked from ipbastola/clean-up-boot-partition-ubuntu.md
Safest way to clean up boot partition - Ubuntu 14.04LTS-x64, Ubuntu 16.04LTS-x64
View clean-up-boot-partition-ubuntu.md

Safest way to clean up boot partition - Ubuntu 14.04LTS-x64, Ubuntu 16.04LTS-x64

Reference

Case I: if /boot is not 100% full and apt is working

1. Check the current kernel version

$ uname -r 
@ruanbekker
ruanbekker / letsencrypt-docker.md
Created May 9, 2019
Generate Letsencrypt Certificate with Docker
View letsencrypt-docker.md
mkdir letsencrypt
docker run -ti --rm -v "$(pwd)"/letsencrypt:/etc/letsencrypt \
certbot/certbot --manual --preferred-challenges dns certonly -d sub.domain.com
@ruanbekker
ruanbekker / go
Created Apr 25, 2019 — forked from CarterTsai/go
golang s3 PutObject
View go
package main
import (
"bytes"
"fmt"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/s3"
)
You can’t perform that action at this time.