Skip to content

Instantly share code, notes, and snippets.

arthuralvim /
Created Apr 17, 2019 — forked from erikbern/
How to use a .pfx file with Python requests – also works with .p12 files
import contextlib
import OpenSSL.crypto
import os
import requests
import ssl
import tempfile
def pfx_to_pem(pfx_path, pfx_password):
''' Decrypts the .pfx file to be used with requests. '''
arthuralvim /
Created Feb 21, 2019
Example of python queues and multithreading.
import queue
import threading
num_worker_threads = 1
def do_work(item):

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 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:


import pytest



$ pip install ansible


$ ansible-playbook -i inventory <playbook.yml> -l <host_scope>
arthuralvim /
Created Dec 8, 2018
Just a script to get some information about my files.
import os
import sys
import json
import datetime
from collections import namedtuple
from pathlib import Path
_timestamp_convert = datetime.datetime.fromtimestamp
arthuralvim /
Created Dec 6, 2018
Just a script to work and sync heroku backups with s3.
# install awscli and heroku cli before.
# sudo pip install awscli
sudo su
curl | sh
heroku login --interactive
heroku apps
arthuralvim /
Last active Jan 16, 2019
GNU Screen Commands

Screen Commands

On the command prompt, type screen. Run the desired program. Use the key sequence ctrl-a + ctrl-d to detach from the screen session. Reattach to the screen session by typing screen -r.

List running screen sessions

$ screen -list


arthuralvim /
Created Oct 22, 2018 — forked from jonasgeiregat/
Management command for django to dump database data (fixtures) on a per model base.
from import BaseCommand, CommandError
from django.core import serializers
from optparse import make_option
class Command(BaseCommand):
Generate a fixture file for a specific model.
Useage: ./ generate_fixtures app.models.MyModel --file=MyModelsOutputFile.json
arthuralvim /
Last active Oct 1, 2018
Sobre chaves SSH
You can’t perform that action at this time.