View create_cfn_stack.sh
#!/usr/bin/env bash
STACK_NAME=$1
STACK_PATH=$2
if [ -z "$1" ]
then
echo "No STACK_NAME argument supplied"
exit 1
fi
View create_example_stack.sh
#!/usr/bin/env bash
STACK_NAME=$1
if [ -z "$1" ]
then
echo "No STACK_NAME argument supplied"
exit 1
fi
View policy.yml
- PolicyName: "s3SyncTaskPolicy"
PolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Action:
- s3:DeleteObject
- s3:ListBucket
- s3:GetObject
- s3:GetBucketLocation
View cli.py
import argparse
parser = argparse.ArgumentParser(prog='cl')
subparsers = parser.add_subparsers()
def foo(beep, boop):
print beep, boop
def bar(baz):
print baz
View pandas-json-yaml.py
import yaml
import json
import pandas as pd
df = pd.DataFrame({'one': [1.0, 2.1, 3.2], 'two': [4.3, 5.4, 6.5]})
with open('df.yml', 'w') as file:
yaml.dump({'result': json.loads(df.to_json(orient='records'))}, file, default_flow_style=False)
View one_liners.sh
# Stop all docker process
docker stop $(docker ps -a -q)
# rm all docker containers
docker rm $(docker ps -a -q)
# rm all docker images with some selection logic
docker rmi $(docker images --format "{{.Repository}}:{{.Tag}}")
# or
View search-term-parse.js
// Beautiful regex patterns that parse and validate complex querystring parameter of search terms
const searchSyntaxValidationRegex = /^([^:]+:[^:]+(?:,|$))+$/;
const searchSyntaxParseRegex = /([^:]+):\(([^(]+)\)(?:,|$)/g;
/**
* Parses comma separated list of key values into an object.
*
* IN:
* title:(bar bar),content_stripped:(baz, and qux),other:(beep boop)
*
View green-on-selection.js
export default function statelessRadio(React) {
return function StatelessRadio({ baseId, defaultValue, titleText, inputs = [], onSelection = () => {}} = {}) {
function handleSelectionChange(event) {
onSelection(event.target.value);
}
return (
<div id={baseId}>
<p id={`${baseId}__title`}>{titleText}</p>
{inputs.map((inputItem) => {
View on-selection-callback-test.js
// ...
import { spy } from 'sinon';
// ...
it('should take an onSelection callback prop', () => {
// "Arrange"
const props = {
inputs: [{}],
onSelection: spy()
};
View green-default-checked.js
return function StatelessRadio({ baseId, defaultValue, titleText, inputs = [] } = {}) {
// ...
{inputs.map((inputItem) => {
const defaultChecked = (defaultValue === inputItem.value);
return (
<div>
<input type="radio" name={baseId} value={inputItem.value} defaultChecked={defaultChecked} />
<label>{inputItem.label}</label>
</div>
);