Skip to content

Instantly share code, notes, and snippets.

View fgmacedo's full-sized avatar

Fernando Macedo fgmacedo

View GitHub Profile
@miracle2k
miracle2k / odict.py
Created July 26, 2012 20:56
Make PyYAML do very basic things.
"""Make PyYAML output an OrderedDict.
It will do so fine if you use yaml.dump(), but that generates ugly,
non-standard YAML code.
To use yaml.safe_dump(), you need the following.
"""
def represent_odict(dump, tag, mapping, flow_style=None):
"""Like BaseRepresenter.represent_mapping, but does not issue the sort().
@jbarratt
jbarratt / multi_package_ci.py
Created September 13, 2012 19:51
Multi-package local python CI with watchdog
#!/usr/bin/env python
'''
Based on http://ginstrom.com/scribbles/2012/05/10/continuous-integration-in-python-using-watchdog/
Dependencies: ``watchdog`` (pip install watchdog)
Montiors the whole tree for changes.
Check for all changes to any files and test the associated package; we might want to test changes to a pyramid test.ini, say, or a file rename as part of a refactor.
@shimizukawa
shimizukawa / PIL_build.rst
Last active June 26, 2016 14:32 — forked from adrianer/PIL_build.rst
PIL(Pillow) build on Windows (32bit & 64bit)

PIL(Pillow) build on Windows (32bit & 64bit)

If you want to build PIL on Windows, you need to prepare few external libraries. Although some libraries did not provide static library for windows 32/64 bits then you need to build these libraries by your hand too. Also, PIL will load by python at last then you are recommended to use same compiler with python to build libraries.

Target PIL and versions

Pillow:1.7.8 for Python 2.7: src
@dimitrov
dimitrov / Mapping Script
Created March 9, 2015 14:05
Jenkins Warnings Plugin mapping script for flake8
import hudson.plugins.warnings.parser.Warning
import hudson.plugins.analysis.util.model.Priority
String fileName = matcher.group(1)
String type = matcher.group(4)
String lineNumber = matcher.group(2)
String message = matcher.group(5)
String typeCategory = String.valueOf(type.charAt(0));
String category
Priority priority = Priority.NORMAL
import sys
import argparse
from getpass import getpass
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
def navigate(card_number, user_name, passkey):
try:
browser = webdriver.Firefox()
@AlexNeises
AlexNeises / watermark.py
Created September 22, 2016 18:59
Adding a repeating watermark to an image using Python and Pillow
from PIL import Image
def create_watermark(image_path, final_image_path, watermark, hires=False):
main = Image.open(image_path)
mark = Image.open(watermark)
mark = mark.rotate(30, expand=1)
mask = mark.convert('L').point(lambda x: min(x, 25))
mark.putalpha(mask)
mark_width, mark_height = mark.size
main_width, main_height = main.size
@DomWeldon
DomWeldon / README.md
Last active September 21, 2024 10:27
SSM + pydantic: ARNs in environment variables are queried at load time

SSM + Pydantic

Query values from SSM when deployed, by placing an SSM ARN as the environment variable

Background

I wanted to query secrets from SSM at runtime, to laod them into a pydantic.BaseSettings settings object, but still be able to pass standard values during development (and I guess, if I want, in prod).

I've done a couple of similar implementations before, but they have always felt clunky and involved altering the object after instantiation, or hard coding which values to take out of SSM.