Skip to content

Instantly share code, notes, and snippets.

View si3mshady's full-sized avatar
🐍

Elliott Arnold si3mshady

🐍
View GitHub Profile
@bpgould
bpgould / parse_version_from_setuptools.sh
Last active October 27, 2022 18:00
bash regex to parse semver
#!/bin/bash
# fancy regex will parse 0.8.39, can be used to parse semver
VERSION_FROM_SETUP=$(sed -n 's/^ *version="\([^"]*\).*/\1/p' setup.py)
# example setup.py file, start multi-line comment
: '
import setuptools
import os
setuptools.setup(
@bpgould
bpgould / identify_changed_dirs.sh
Created October 18, 2022 02:13
bash script to save directories with changed files in Travis CICD
#!/bin/bash
# this script will run in Travis CICD, identify changed files
# and save the directories of the files if a condition is met,
# it will then print the array of matching directories
if [[ "$TRAVIS_EVENT_TYPE" == "push" ]]; then
# collect only changed files from commit
files=($(git diff-tree --no-commit-id --name-only -r "$TRAVIS_COMMIT"))
elif [[ "$TRAVIS_EVENT_TYPE" == "pull_request" ]]; then
# collect all changed files from commit range
@alfredodeza
alfredodeza / remote-desktop.md
Last active December 14, 2023 16:27
Remote k8s with docker-desktop using an SSH tunnel

Remote Kubernetes using SSH

My setup is using a Macmini with Docker for Desktop installed and with the Kubernetes option enabled. The main objective of the setup: use kubectl directly without any additional flags from my local computer, accessing/interacting the remote k8s instance

Ensure SSH is setup with key-based authentication

Copy public key to the remote authorized_keys file

cat ~/.ssh/id_rsa.pub | ssh admin@macmini-server 'umask 0077; mkdir -p .ssh; cat >> .ssh/authorized_keys'
@si3mshady
si3mshady / user-data.yaml
Created June 18, 2021 05:28 — forked from jeffbrl/user-data.yaml
AWS CloudFormation UserData Example
# This example is from https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-sub.html.
UserData:
Fn::Base64:
!Sub |
#!/bin/bash -xe
yum update -y aws-cfn-bootstrap
/opt/aws/bin/cfn-init -v --stack ${AWS::StackName} --resource LaunchConfig --configsets wordpress_install --region ${AWS::Region}
/opt/aws/bin/cfn-signal -e $? --stack ${AWS::StackName} --resource WebServerGroup --region ${AWS::Region}
@si3mshady
si3mshady / selenium-webdriver-cheatsheet.md
Created February 21, 2021 18:37 — forked from siruguri/selenium-webdriver-cheatsheet.md
Selenium Webdriver CheatSheet

API workthough

  1. Open a browser

    # start an instance of firefox with selenium-webdriver
    driver = Selenium::WebDriver.for :firefox
    # :chrome -> chrome
    # :ie     -> iexplore
    
  • Go to a specified URL
//https://youtu.be/Mgs7jl430vs
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicReadGetObject",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
@jeffbrl
jeffbrl / user-data.yaml
Created October 21, 2018 00:04
AWS CloudFormation UserData Example
# This example is from https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-sub.html.
UserData:
Fn::Base64:
!Sub |
#!/bin/bash -xe
yum update -y aws-cfn-bootstrap
/opt/aws/bin/cfn-init -v --stack ${AWS::StackName} --resource LaunchConfig --configsets wordpress_install --region ${AWS::Region}
/opt/aws/bin/cfn-signal -e $? --stack ${AWS::StackName} --resource WebServerGroup --region ${AWS::Region}
@mpyw
mpyw / Logger.js
Created August 14, 2018 17:46
Send your browser console errors to AWS CloudWatch. Inspired by https://github.com/agea/console-cloud-watch
import React, { Component } from 'react'
import CloudWatchLogs from 'aws-sdk/clients/cloudwatchlogs'
import Fingerprint2 from 'fingerprintjs2'
import StackTrace from 'stacktrace-js'
import { promisify } from 'es6-promisify'
export default class Logger {
events = []
originalConsole = null
@adrianhall
adrianhall / AppSync-Example.yaml
Created April 13, 2018 16:01
An example CloudFormation template for AWS AppSync
---
Description: AWSAppSync DynamoDB Example
Resources:
GraphQLApi:
Type: "AWS::AppSync::GraphQLApi"
Properties:
Name: AWSAppSync DynamoDB Example
AuthenticationType: AWS_IAM
PostDynamoDBTableDataSource:
@initcron
initcron / ec2-ansible.yml
Created December 25, 2017 16:04
provision ec2 instance with ansible with user-data
# link: http://allandenot.com/devops/2015/01/31/provisioning-ec2-hosts-with-ansible.html
---
- name: Provision EC2 Box
local_action:
module: ec2
key_name: "{{ ec2_keypair }}"
group_id: "{{ ec2_security_group }}"
instance_type: "{{ ec2_instance_type }}"
image: "{{ ec2_image }}"