Skip to content

Instantly share code, notes, and snippets.

View Kalimaha's full-sized avatar
🌒
not because they are easy, but because they are hard

Guido Barbaglia Kalimaha

🌒
not because they are easy, but because they are hard
View GitHub Profile
@Kalimaha
Kalimaha / test_decorators.py
Created May 19, 2017 01:44
Python Decorators
import inspect
class Pact(object):
has_pact_with = None
state = None
def __str__(self):
return "\n==> Provider Pact\n\tHas pact with: " + str(self.has_pact_with) + "\n\tState: " + str(self.state)
@Kalimaha
Kalimaha / conftest.py
Created May 19, 2017 00:40
Local PyTest Plugin
import pytest
from pytest_pact.utils.pytest_utils import read_marker
@pytest.hookimpl(hookwrapper=True)
def pytest_pyfunc_call(pyfuncitem):
state = read_marker(pyfuncitem, 'state')
print(state)
outcome = yield
res = outcome.get_result()
@Kalimaha
Kalimaha / test_mock.py
Created May 14, 2017 09:36
pytest-mock
import calculator
def test_answer(mocker):
mocker.patch.object(calculator, 'sum')
calculator.sum.return_value = 123
assert calculator.sum(2, 3) == 123
@Kalimaha
Kalimaha / index.html
Created December 26, 2016 14:46
index
<!DOCTYPE html>
<html>
<head>
<title>Serverless Guestbook</title>
<script src="https://code.jquery.com/jquery-3.1.1.min.js" type="text/javascript">
</script>
<script type="text/javascript">
const get_url = 'https://tfh1cxol33.execute-api.ap-southeast-2.amazonaws.com/serverlessguestbookdeployment'
const post_url = 'https://tfh1cxol33.execute-api.ap-southeast-2.amazonaws.com/serverlessguestbookdeployment'
const list_messages = (messages) => { for (m of messages) $('#list').append(format(m)) }
@Kalimaha
Kalimaha / Gruntfile.js
Created December 7, 2016 03:36
Grunt Playground
(function () {
'use strict';
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json')
});
grunt.task.loadTasks('./tasks');
@Kalimaha
Kalimaha / dev.yml
Created November 8, 2016 05:33
Configuration File
Files:
- MonitoringStackName: my-stack
BucketName: my-bucket
Filename: my-file
TopicName: my-topic
AlarmName: my-alarm
AlarmProtocol: email
AlarmEndpoint: "my.name@example.com"
@Kalimaha
Kalimaha / monitoring_stack.yml
Created November 8, 2016 05:27
Monitoring Stack
Description: Monitoring Stack
Parameters:
TopicName:
Description: Name for the SNS topic used for the monitoring
Type: String
AlarmName:
Description: Name for the CloudWatch alarm
Type: String
@Kalimaha
Kalimaha / custom_resource.yml
Created November 8, 2016 05:07
Custom Resource configuration
Resources:
S3ConfigurationUpdater:
Type: "Custom::S3ConfigurationUpdater"
Properties:
ServiceToken: !GetAtt [ LambdaFunction, Arn ]
@Kalimaha
Kalimaha / Lambda.yaml
Created November 2, 2016 22:20
AWS Lambda function to configure an Existing S3 Bucket
LambdaFunction:
Type: "AWS::Lambda::Function"
DependsOn: SNSTopic
Properties:
Description: "Lambda function to modify the existing S3 bucket"
Handler: index.handler
Runtime: "nodejs4.3"
Timeout: 300
Role: !GetAtt [ LambdaFunctionRole, Arn ]
Code:
@Kalimaha
Kalimaha / RequestIdentityLogger.rb
Created October 5, 2016 23:02
Log the Transaction and Request ID across multiple microservices
# frozen_string_literal: true
require 'docker_logger'
module Utils
class Logger
def self.instance
RequestIdentityLogger
end
end