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
-module(talk). | |
-compile(export_all). | |
%% call talk:start() to start the program | |
start() -> | |
Node = chomp(io:get_line('Which node do you want to talk to?')), | |
%%Registered process where all the magic happens: | |
register(me, spawn(?MODULE, receiving, [])), | |
register(them, spawn(?MODULE, sending, [list_to_atom(Node)])), |
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
#Example of IoC using Pinsor | |
import pinsor | |
class PowerfullEngine(object): | |
def __str__(self): | |
return "I am a V8" | |
class WeakEngine(object): |
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
class Account(): | |
def __init__(self): | |
self.balance = 0 | |
self.currency = 'CAD' | |
self.overdraft = False | |
def make_deposit(self, amount): | |
"""imagine a boat load of business logic that would make this useful""" | |
pass |
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
[connection:main] | |
#RabbitMQ Setting | |
host = localhost | |
virtual_host = / | |
userid = guest | |
password = guest | |
[exchange:nasdaq] | |
durable = True | |
type = direct |
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
class HandlerFactory { | |
HandlerFactory(billing_service, account_repo) { | |
this.billing = billing_service; | |
this.accounts = account_repo | |
} | |
public static Handler create_handler(var discriminator){ | |
switch discriminator: | |
case 1: return type_a_handler(this.billing, this.accounts) | |
case 2: return type_b_handler(this.billing, this.accounts) |
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
//implementation | |
create_handler(var billing_service, var account_repo, var discriminator){ | |
switch discriminator: | |
case 1: return type_a_handler(billing_service, account_repo) | |
case 2: return type_b_handler(billing_service, account_repo) | |
} | |
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
//implementation | |
create_handler(var billing_service, var account_repo, var discriminator){ | |
switch discriminator: | |
case 1: return type_a_handler(billing_service, account_repo) | |
case 2: return type_b_handler(billing_service, account_repo) | |
} | |
handler_factory = partial( |
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
class HandlerFactory(object): | |
def __init__(self, billing_engine, accounts_repo): | |
self.engine = billing_engine | |
self.accounts = accounts_repo | |
def create_handler(self, discriminator): | |
if discriminator == 1: | |
return type1_handler(self.engine, self.accounts) | |
else: | |
return type2_handler(self.engine, self.accounts) |
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
def create_handler(billing_engine, accounts_repo, discriminator): | |
if discriminator == 1: | |
return type1_handler(billing_engine, accounts_repo) | |
else: | |
return type2_handler(billing_engine, accounts_repo) | |
# "a" and "b" passed for illustrative purposes only, | |
# They represent the billing_engine, accounts_repo dependencies | |
get_handler = partial( |
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 pylons.decorators import decorator, get_pylons | |
def cache_control(**options): | |
def updated_headers(func, *args, **kwargs): | |
pylons = get_pylons(args) | |
if pylons: | |
del pylons.response.headers['Cache-Control'] | |
del pylons.response.headers['Pragma'] | |
pylons.response.cache_control = {'max-age': options['max_age'], 'public': True} | |
return func(*args, **kwargs) |
OlderNewer