This file contains 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
# I always get confused with decorators because of all the nesting and where all of the arguments go | |
# Reference of using decoratores with arguments and with classes | |
## Very Simple Decorator | |
def foo(f): | |
# Inner function that must be returned | |
def decorator(): | |
print('decorator') | |
# Will be bar() from the below wrapped call |
This file contains 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
#!/usr/bin/env python | |
import json | |
import rethinkdb as r | |
from os import environ as env | |
HOST = env.get('RETHINK_HOST', '127.0.0.1') | |
PORT = env.get('RETHINK_PORT', 28015) | |
DB = env.get('RETHINK_DB', 'inventory') | |
GROUP = env.get('RETHINK_GROUP', 'dev') |
This file contains 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
#!/bin/bash | |
set -e | |
find_ansible_dir() { | |
dir=$(readlink -f ${1:-.}) | |
if [ $dir = '/' ] | |
then | |
echo "Could not find a playbook in $(pwd)" |
This file contains 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
from __future__ import (absolute_import, division, print_function) | |
__metaclass__ = type | |
import sys | |
from ansible import constants as C | |
from ansible.plugins.callback.default import CallbackModule as CallbackModule_default | |
from ansible.utils.color import colorize, hostcolor | |
def _color(play): |
This file contains 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
contents = '''contents = {0}{0}{0}{1}{0}{0}{0} | |
contents = contents.format('\{0}',contents) | |
with open("pointless.py", "w") as f: | |
f.write(contents) | |
''' | |
contents = contents.format('\'',contents) |
This file contains 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
- hosts: localhost | |
tasks: | |
- uri: | |
url: http://www.textfiles.com/etext/AUTHORS/SHAKESPEARE/shakespeare-macbeth-46.txt | |
return_content: true | |
register: blah | |
- osx_say: | |
msg: "{{ blah.content|replace('\n', ' ')|replace('\t',' ') }}" |
This file contains 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
node { | |
echo 'Results included as an inline comment exactly how they are returned as of Jenkins 2.121, with $BUILD_NUMBER = 1' | |
echo 'No quotes, pipeline command in single quotes' | |
sh 'echo $BUILD_NUMBER' // 1 | |
echo 'Double quotes are silently dropped' | |
sh 'echo "$BUILD_NUMBER"' // 1 | |
echo 'Even escaped with a single backslash they are dropped' | |
sh 'echo \"$BUILD_NUMBER\"' // 1 | |
echo 'Using two backslashes, the quotes are preserved' | |
sh 'echo \\"$BUILD_NUMBER\\"' // "1" |
This file contains 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
### Generic Dockerfile demonstrating good practices | |
### Imports | |
# Bad-ish, we do not need Ubuntu for this, nor do we want latest if we are using in a build system, predictable is better | |
FROM ubuntu:latest | |
# Better, using a small image since our app has no dependency on Ubuntu | |
FROM alpine:3.3 |
This file contains 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
#!/bin/bash | |
# Source arguments from Ansible | |
# These are passed into the module as $1 with a key=value format | |
# Sourcing this file sets the variables defined in the Ansible module | |
# Note that variables that are unused in the module are silently ignored | |
source $1 | |
# Helper function to fail the module with the specified error | |
# This can accept $@ in printf for the full error |
NewerOlder