Skip to content

Instantly share code, notes, and snippets.

View ruanbekker's full-sized avatar
🇿🇦

Ruan Bekker ruanbekker

🇿🇦
View GitHub Profile
@mgaspari
mgaspari / youtube-to-mp3.rb
Created August 23, 2017 18:48 — forked from stefan-lz/youtube-to-mp3.rb
youtube vids to mp3 files (ruby)
#!/usr/bin/ruby
#usage: youtube-to-mp3 <youtube-url>
#example: youtube-to-mp3 http://www.youtube.com/playlist?list=PL398CE05652474A1E
#desc: downloads a single youtube vid or a playlist, then converts to mp3.
# Requires youtube-dl and ffmpeg
url = ARGV[0]
system("youtube-dl -citA #{url}")
@fgassert
fgassert / ec2-get-security-credentials
Last active March 18, 2020 01:27
gets iam security credentials from instance metadata and writes them to awscli environment variables and .s3cfg (for s3cmd)
#!/bin/bash
# gets iam security credentials from instance metadata and writes them to
# awscli environment variables and .s3cfg (for s3cmd)
# Usage: ec2-get-security-credentials ROLENAME DEFAULT_REGION
# ROLE=$1
# DEFAULT_REGION=$2
@gene1wood
gene1wood / role_arn_to_session.py
Created December 29, 2016 17:38
Simple python function to assume an AWS IAM Role from a role ARN and return a boto3 session object
import boto3
def role_arn_to_session(**args):
"""
Usage :
session = role_arn_to_session(
RoleArn='arn:aws:iam::012345678901:role/example-role',
RoleSessionName='ExampleSessionName')
client = session.client('sqs')
"""
@jdavis
jdavis / open_port.py
Created November 8, 2012 17:26
Find an open port in Python.
import socket
def find_open_port():
"""
Use socket's built in ability to find an open port.
"""
sock = socket.socket()
sock.bind(('', 0))
@DaisukeMiyamoto
DaisukeMiyamoto / assume_role.py
Created September 12, 2018 05:00
AWS Boto3 Assume Role example
import boto3
from boto3.session import Session
def assume_role(arn, session_name):
"""aws sts assume-role --role-arn arn:aws:iam::00000000000000:role/example-role --role-session-name example-role"""
client = boto3.client('sts')
account_id = client.get_caller_identity()["Account"]
print(account_id)
@davidsneal
davidsneal / html-share-buttons.html
Last active December 12, 2023 13:18
HTML Share Buttons
<!-- I got these buttons from simplesharebuttons.com -->
<div id="share-buttons">
<!-- Buffer -->
<a href="https://bufferapp.com/add?url=https://simplesharebuttons.com&amp;text=Simple Share Buttons" target="_blank">
<img src="https://simplesharebuttons.com/images/somacro/buffer.png" alt="Buffer" />
</a>
<!-- Digg -->
<a href="http://www.digg.com/submit?url=https://simplesharebuttons.com" target="_blank">
@pythoninthegrass
pythoninthegrass / jenkins-docker-compose.yml
Last active February 11, 2024 08:18 — forked from SWBSanjeewa/jenkins-docker-compose
Run jenkins master and slave using docker compose
# MASTER PRE-REQS
# Install docker, docker-compose
# mkdir -p ~/{jenkins,jnlp_slave}
# master
# docker run -d \
# -u root \
# --name=jenkins \
# -e TZ=America/Denver \
# Source: https://gist.github.com/baaf4adb25e9efaba886c17a2ad722a5
########################################################
# How To Auto-Scale Kubernetes Clusters With Karpenter #
# https://youtu.be/C-2v7HT-uSA #
########################################################
# Referenced videos:
# - Karpenter: https://karpenter.sh
# - GKE Autopilot - Fully Managed Kubernetes Service From Google: https://youtu.be/Zztufl4mFQ4
@greyli
greyli / app.py
Last active February 25, 2024 03:04
Photo upload and manage with Flask and Flask-Uploads (Multiple file upload support!).
# -*- coding: utf-8 -*-
import os
import uuid
from flask import Flask, render_template, redirect, url_for, request
from flask_uploads import UploadSet, configure_uploads, IMAGES, patch_request_class
from flask_wtf import FlaskForm
from flask_wtf.file import FileField, FileRequired, FileAllowed
from wtforms import SubmitField
@sebstyle
sebstyle / rancher-on-k3os.md
Last active March 21, 2024 03:43
Install rancher on k3os

Rancher cluster on k3os

Goal

Install rancher on k3os with centralized datastore on mysql cluster.

Environment

  • Host: Ubuntu 18.04.4 Desktop (32gb ram 4 cpu)
  • Virtualisation: kvm/qemu (virtual machine manager)
  • Local network: 192.168.0.0/16
    • Gateway: 192.168.0.1