After watching Bryan Cantrill's presentation on [Running Aground: Debugging Docker in Production][aground] I got all excited (and strangely nostalgic) about the possibility of core-dumping server-side Python apps whenever they go awry. This would theoretically allow me to fully inspect the state of the program at the point it exploded, rather than relying solely on the information of a stack trace.
This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.
The script is here:
#!/bin/bash
convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| A PyYAML loader that annotates position in source code. | |
| The loader is based on `SafeConstructor`, i.e., the behaviour of | |
| `yaml.safe_load`, but in addition: | |
| - Every dict/list/unicode is replaced with dict_node/list_node/unicode_node, | |
| which subclasses dict/list/unicode to add the attributes `start_mark` | |
| and `end_mark`. (See the yaml.error module for the `Mark` class.) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| In [1]: policy = """{ | |
| ...: "Statement":[{ | |
| ...: "Effect":"Allow", | |
| ...: "Action":["s3:*"], | |
| ...: "Resource":["arn:aws:s3:::mybucket"]}]}""" | |
| In [2]: import boto | |
| In [4]: c = boto.connect_iam() | |
| In [5]: instance_profile = c.create_instance_profile('myinstanceprofile') | |
| In [6]: role = c.create_role('myrole') | |
| In [7]: c.add_role_to_instance_profile('myinstanceprofile', 'myrole') |