Skip to content

Instantly share code, notes, and snippets.

View reza's full-sized avatar
:atom:

Reza Hashemi reza

:atom:
  • Sydney, Australia
View GitHub Profile
@reza
reza / gist:d30fbcd5da0f88f3fb9fb1cb8d6c109d
Created June 1, 2018 12:31
Link OpenCv3 (Now part of Homebrew Core) to Python3.6 on Mac OSX High Sierra
~$ brew install opencv3 --with-contrib --with-python3 --without-python
Warning: opencv: this formula has no --with-contrib option so it will be ignored!
Warning: opencv: this formula has no --with-python3 option so it will be ignored!
Warning: opencv: this formula has no --without-python option so it will be ignored!
==> Downloading https://homebrew.bintray.com/bottles/opencv-3.4.1_5.high_sierra.bottle.2.tar.gz
Already downloaded: /Users/reza/Library/Caches/Homebrew/opencv-3.4.1_5.high_sierra.bottle.2.tar.gz
==> Pouring opencv-3.4.1_5.high_sierra.bottle.2.tar.gz
🍺 /usr/local/Cellar/opencv/3.4.1_5: 600 files, 214.8MB
Note: The tricky part is using the Cellar path below rather than /usr/local/opt/opencv/lib/python3.6/site-packages
@reza
reza / aws-guardduty-lambda-security
Created January 23, 2018 12:49
I have used a lambda function to automatically deactivate any access key associated with a high severity GuardDuty alert.
#!/usr/bin/env python
#developed for blog post at http://www.cloudten.com.au/aws-guardduty-intelligent-threat-detection/
from __future__ import print_function
import boto3
import json
def lambda_handler(event, context):
print("Received event: " + json.dumps(event))
try:
#!/bin/bash
#
# Assume the given role, and print out a set of environment variables
# for use with aws cli.
#
# To use:
#
# $ eval $(./iam-assume-role.sh)
#
@reza
reza / ansible-aws-cloud-init.sh
Last active December 25, 2017 06:04
ansible-aws-cloud-init.sh
#!/bin/bash
# Ver 2.1, By Reza Hashemi
# Automate EC2 instance setup and Install latest Ansible and its dependencies via pip (recommended method)
# The cloud init script detects the EC2 instance platform at launch and uses preferred package manager
# AWS cloud init script to install ansible on startup, autodetects required package manager
# Add as user data inside advanced details at AWS EC2 configure instance details (step 3)
# Changes:
# Ver 2.1 Tested on Centos 6
# No issues with pynacl and cryptography
# Ver 2 Tested on RHEL, Centos 7, Ubuntu, SUSE, Fedora 23-25, Debian
@reza
reza / fix-rubygems-source.sh
Created July 9, 2017 16:38
gem install rails not working after upgrading to ruby 2.4.1: ERROR: Could not find a valid gem 'rails' (>= 0), here is why: Unable to download data from https://production.s3.rubygems.org - no such name (https://production.s3.rubygems.org/specs.4.8.gz)
#!/bin/sh
gem source -r https://production.s3.rubygems.org
gem source -a https://rubygems.org