Skip to content

Instantly share code, notes, and snippets.

View vladimirnani's full-sized avatar

Vladimir Nani vladimirnani

View GitHub Profile
from datetime import datetime
from uuid import NAMESPACE_URL, uuid5
from django.test import TransactionTestCase
from eventsourcing.application.decorators import applicationpolicy
from eventsourcing.application.django import DjangoApplication
from eventsourcing.application.process import ProcessApplication
from eventsourcing.domain.model.aggregate import BaseAggregateRoot
from eventsourcing.system.definition import System
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
choco feature enable -n=allowGlobalConfirmation
choco install logstash --version 6.2.4
choco feature disable -n=allowGlobalConfirmation
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
A related problem to this happens when projections start doing lookups to other projections. As example there could be a customer table managed by a CustomerProjection and an orders table managed by an OrdersProjection. Instead of having the OrdersProjection listen to customer events the decision was made to have it lookup in the CustomerProjection what the current Customer Name is to copy into the orders table. This can save time and duplication in the OrdersProjection code.
On a replay of only the Orders projection all of the orders will end up with the current Customer Name not the Customer Name from the time that the original order was placed. A replay will result in different results that the original. This is a tradeoff to the reduced code that was originally gained, the two projections now have a coupling.
In the case of sharing information the two projections can no longer be replayed independently, they instead need to be replayed as a group. It is quite easy to end up with an unmanageable web of d
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
choco feature enable -n=allowGlobalConfirmation
choco install logstash --version 6.2.4
choco feature disable -n=allowGlobalConfirmation
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
@vladimirnani
vladimirnani / hosts.bat
Last active January 3, 2016 10:49
Swithces redirections in hosts file based on environment variable.
SET InputFile=%SystemRoot%\System32\drivers\etc\hosts
SET OutputFile=%SystemRoot%\System32\drivers\etc\hoststemp
IF "%HOSTS_OVERRIDE%" == "" GOTO FIRST_RUN
IF "%HOSTS_OVERRIDE%"=="1" (
SETX HOSTS_OVERRIDE 0
GOTO TEST
) else (
SETX HOSTS_OVERRIDE 1
GOTO LIVE
@vladimirnani
vladimirnani / sitemap_test.py
Created December 23, 2013 07:51
Test all urls defined in settings.py
from django.test import TestCase
from django.core.urlresolvers import reverse
from django_project.sitemaps import StaticSitemap
from django_project.urls import sitemaps
class StaticSitemapTests(TestCase):
def setUp(self):
names = [name for s in sitemaps.values()
if isinstance(s, StaticSitemap)
@vladimirnani
vladimirnani / proxy_switch.py
Last active December 31, 2015 05:39
Flips network connection in Windows.
import wmi
from _winreg import *
NETWORK_NAME = 'Local Area Connection'
REG_KEY = 'Software\Microsoft\Windows\CurrentVersion\Internet Settings'
def main():
c = wmi.WMI()
key = OpenKey(HKEY_CURRENT_USER, REG_KEY, 0, KEY_WRITE)
adapter = [a for a in c.Win32_NetworkAdapter()