Skip to content

Instantly share code, notes, and snippets.

View russomi's full-sized avatar
☁️
Remote

Michael Russo russomi

☁️
Remote
View GitHub Profile
@russomi
russomi / tutorial-template.md
Created March 26, 2017 16:10
Tutorial markdown template based on kubernetes.io docs

tutorial-name

This is a simple description of the tutorial.

Overview

Prerequisites

Contributing

When contributing to this repository, please first discuss the change you wish to make via issue, email, or any other method with the owners of this repository before making a change.

Please note we have a code of conduct, please follow it in all your interactions with the project.

Pull Request Process

  1. Ensure any install or build dependencies are removed before the end of the layer when doing a
@russomi
russomi / cw_exp.js
Created June 8, 2018 20:15 — forked from fbrnc/cw_exp.js
AWS Lambda function that collects relevant metrics from CloudWatch and pushes them to ElasticSearch
var AWS = require('aws-sdk');
var cloudwatch = new AWS.CloudWatch({ region: 'us-east-1'});
exports.handler = function (event, context) {
var ElasticSearchHost = 'elasticsearch.example:9200';
var Environment = 'int';
var EndTime = new Date;
var StartTime = new Date(EndTime - 15*60*1000);
var Metrics = {
@russomi
russomi / data-structures-yaml.md
Last active January 21, 2021 23:07
Data Structures in YAML

Data Structures in YAML

  • Scalars
  • Lists
  • Associative Arrays

Scalar

  • Strings (scalars) are ordinarily unquoted, but may be enclosed in double-quotes ("), or single-quotes (').
  • Block scalars are delimited with indentation with optional modifiers to preserve (|) or fold (>) newlines.
@russomi
russomi / gist:60a06ed1b16d905339850b86bae9353f
Created March 15, 2020 00:45 — forked from ozh/git cherry-pick within a pull request.md
git cherry-pick within a pull request

1. Create new branch:

git checkout -b otherrepo-master master

2. Get the contents of the PR

git pull https://github.com/otherrepo/my-repo-name.git master
@russomi
russomi / .gitignore
Created August 7, 2020 14:32 — forked from olooney/.gitignore
worked examples of argparse and python logging
logs/
@russomi
russomi / unnittestexample.py
Created September 18, 2020 16:35 — forked from Bergvca/unnittestexample.py
Some unnittest + Mock examples in Python. Includes examples on how to mock a entire class (ZipFile), mock an Iterator object and how to use side_effect properly
import unittest
import os
from zipfile import ZipFile
from mock import MagicMock, patch, Mock, mock_open
# The functions that are tested:
def function_to_test_zipfile(example_arg):
with ZipFile(example_arg, 'r') as zip_in:
for input_file in zip_in.infolist():
@russomi
russomi / filter_dict.py
Created September 26, 2020 15:19 — forked from 89465127/filter_dict.py
python filter a dictionary by keys or values
d = {1:11, 2:22, 3:33}
# filter by key
d2 = {k : v for k,v in filter(lambda t: t[0] in [1, 3], d.iteritems())}
# filter by value
d3 = {k : v for k,v in d.iteritems() if k in [2,3]}
@russomi
russomi / using_filterable_dict.py
Created September 26, 2020 15:25 — forked from melvinkcx/using_filterable_dict.py
Filtering Dictionary in Python
from typing import Dict
# Helper function to generate dict object
def get_menu() -> Dict[str, dict]:
return {
"TIMMY_BLACK": {
"item": "Timmy's Coffee Barista's Black",
"sugar_free": True,
"with_milk": False,
},
@russomi
russomi / FilterableDict.py
Created September 26, 2020 15:30
FilterableDict with Filter objects - taken from https://pypi.org/project/aiatools/
class FilterableDict(dict):
def __call__(self, filter_):
return FilterableDict([k, v for k, v in self.iteritems() if filter_(v) else None, None])
class Filter(object):
def __call__(self, o):
throw NotImplementedError()
def __and__(self, right):