Skip to content

Instantly share code, notes, and snippets.

@erikbern
erikbern / use_pfx_with_requests.py
Last active April 10, 2025 07:17
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
@contextlib.contextmanager
def pfx_to_pem(pfx_path, pfx_password):
''' Decrypts the .pfx file to be used with requests. '''
#!/home/airflow/.pyenv/shims/python
import airflow
from airflow.models import Connection
import argparse
import logging
parser = argparse.ArgumentParser()
parser.add_argument('-c', '--connection')
parser.add_argument('-t', '--connectiontype')
@abridgett
abridgett / s3_bucket_sizes
Last active December 10, 2018 04:56
s3_bucket_sizes
#!/bin/sh
# Report S3 bucket sizes
get_bucket_size() {
bucket="$1"
today=$(date +"%Y-%m-%d")
if [ $(uname -s) = "Darwin" ]; then
yesterday=$(date -v-1d +"%Y-%m-%d")
else
@victorfsf
victorfsf / environment.yml
Last active March 28, 2016 11:37
Python Data Warehouse Collection
name: datascience
dependencies:
- python=2.7.11
- numpy
- llvmlite=0.9.0
- numba=0.24.0
- pip:
- ipdb==0.9.0
- ipython==4.1.2
@jacobsalmela
jacobsalmela / convertDOCXtoPDF.sh
Last active July 18, 2023 18:14
Converts a DOC or DOCX to a PDF with a right-click
#!/bin/bash
# Jacob Salmela
# 2016-03-12
# Convert annoying DOCX into PDFs with a right-click
# Run this as an Automator Service
###### SCRIPT #######
for f in "$@"
do
# Get the full file PATH without the extension
@shawnsi
shawnsi / README.md
Last active March 24, 2025 10:37
Ansible Vault Environment Variable

Ansible Vault Environment Variable

Per http://docs.ansible.com/ansible/playbooks_vault.html you can set an environment variable to use a password file for vault access. We can use this to create an environment variable to hold the password.

Password Script

Copy vault-env from this project to ~/bin. Then add this to your ~/.bashrc:

export ANSIBLE_VAULT_PASSWORD_FILE=~/bin/vault-env
@BretFisher
BretFisher / .travis.yml
Created February 15, 2016 21:26
Travis-CI Docker Image Build and Push to AWS ECR
sudo: required #is required to use docker service in travis
language: php #can be any language, just php for example
services:
- docker # required, but travis uses older version of docker :(
install:
- echo "install nothing!" # put your normal pre-testing installs here
@mojaray2k
mojaray2k / instafeedjsaccess.md
Last active February 10, 2025 17:40
Getting Instagram Access Token for http://intafeedjs.com

#Use this URL to get your client authorized for Instafeed.JS plugin for Instagram.

  1. First login into your Instargam account
  2. Then go to https://www.instagram.com/developer/
  3. At the top click on the Button that says "Manage Clients".
  4. If you have not Register a new client.
  5. Fill out everything and where it says redirect url put this url: http://instafeedjs.com
  6. Then on the security tab make sure you uncheck "Disable implicit OAuth"
  7. Finally use this link to authoruize Instafeed. Where it says "[Client ID]" replace that including the brackets with your clientID from instagram:
  8. https://instagram.com/oauth/authorize/?client_id=[Client ID]&redirect_uri=http://instafeedjs.com&response_type=token
@MichaelCurrie
MichaelCurrie / autopep8 Travis-CI.md
Last active April 26, 2021 17:18
Automatically fix PEP-8 issues using Travis-CI

PEP-8 is a set of Python style recommendations. pep8 is a module that checks your .py file for violations. To make your Travis-CI build fail if you have any violations, you could add these lines to your .travis.yml:

before_install:
    - pip install pep8
    
script:
    # Run pep8 on all .py files in all subfolders
    # (I ignore "E402: module level import not at top of file"
    # because of use case sys.path.append('..'); import <module>)
@abridgett
abridgett / airflow_eg.py
Last active April 29, 2021 22:03
airflow XCOM notification example
MAP_SLACK_ATTACHMENTS = [
{
"fallback": "{{params.map}} {{ task_instance.xcom_pull(task_ids=params.map, key='slack_status') }}",
"pretext": "{{params.map}} update {{ task_instance.xcom_pull(task_ids=params.map, key='slack_status') }}",
"fields": [
{
"title": "Copied",
"value": "{{ task_instance.xcom_pull(task_ids=params.map, key='copied') }}",
"short": True
}