Skip to content

Instantly share code, notes, and snippets.

Arthur Alvim arthuralvim

Block or report user

Report or block arthuralvim

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
View cowsay-examples.md

sudo apt-get install cowsay fortunes

or

brew install cowsay fortune

cowsay -l
fortune | cowsay
@arthuralvim
arthuralvim / restart_bluetooth.sh
Created Jun 13, 2019
Script to restart Bluetooth on Mac OSX.
View restart_bluetooth.sh
#!/bin/bash
# blueutil
if which blueutil &> /dev/null; then
echo "blueutil installed!"
else
echo "blueutil installing..."
brew install blueutil
echo "blueutil installed!"
fi
@arthuralvim
arthuralvim / example_envattrs.py
Created May 28, 2019 — forked from doi-t/example_envattrs.py
Simple example of envattrs for aws lambda function
View example_envattrs.py
# echo '{}' > event.json; mkdir -p libs; pip install attrs envattrs -t libs; \
# export YOUR_PREFIX_SLACK_CHANNEL=your_project-staging; \
# export YOUR_PREFIX_S3_BUCKET=pyconapac-bucket; \
# export YOUR_PREFIX_THRESHOLD=50; \
# python-lambda-local -l libs/ -f handler -t 5 lambda_pyconapac.py event.json
from typing import Dict
import attr
import envattrs
@arthuralvim
arthuralvim / aws_lambda_cloudwatch_logs_exporter.md
Created May 28, 2019 — forked from doi-t/aws_lambda_cloudwatch_logs_exporter.md
Export logs from CloudWatch Logs to S3 with AWS Lambda
View aws_lambda_cloudwatch_logs_exporter.md

event example

TASK_NAME=${1:-'export_logs'}
FROM=${2:-'2017-12-24 12:00'}
TO=${3:-'2017-12-24 12:05'}
cat <<-EOF > event.json
{
    "taskName": "$TASK_NAME",
    "fromTime": `gdate --date="$FROM" +%s%3N`,
    "toTime": `gdate --date="$TO" +%s%3N`
@arthuralvim
arthuralvim / getting-start-with-AWS-Batch.md
Created May 28, 2019 — forked from doi-t/getting-start-with-AWS-Batch.md
A log of getting start with AWS Batch.
View getting-start-with-AWS-Batch.md
@arthuralvim
arthuralvim / use_pfx_with_requests.py
Created Apr 17, 2019 — forked from erikbern/use_pfx_with_requests.py
How to use a .pfx file with Python requests – also works with .p12 files
View use_pfx_with_requests.py
import contextlib
import OpenSSL.crypto
import os
import requests
import ssl
import tempfile
@contextlib.contextmanager
def pfx_to_pem(pfx_path, pfx_password):
''' Decrypts the .pfx file to be used with requests. '''
@arthuralvim
arthuralvim / queue_threading.py
Created Feb 21, 2019
Example of python queues and multithreading.
View queue_threading.py
import queue
import threading
num_worker_threads = 1
def do_work(item):
print(item)
View pytest-fixture-modularization.md

Using py.test is great and the support for test fixtures is pretty awesome. However, in order to share your fixtures across your entire module, py.test suggests you define all your fixtures within one single conftest.py file. This is impractical if you have a large quantity of fixtures -- for better organization and readibility, you would much rather define your fixtures across multiple, well-named files. But how do you do that? ...No one on the internet seemed to know.

Turns out, however, you can define fixtures in individual files like this:

tests/fixtures/add.py

import pytest

@pytest.fixture
View ansible_commands.md

Install

$ pip install ansible

Basic

$ ansible-playbook -i inventory <playbook.yml> -l <host_scope>
@arthuralvim
arthuralvim / files_info.py
Created Dec 8, 2018
Just a script to get some information about my files.
View files_info.py
import os
import sys
import json
import datetime
from collections import namedtuple
from pathlib import Path
_timestamp_convert = datetime.datetime.fromtimestamp
You can’t perform that action at this time.