Skip to content

Instantly share code, notes, and snippets.

View wizact's full-sized avatar
🐶
I have no idea what i'm doing

Amir Mohtasebi wizact

🐶
I have no idea what i'm doing
View GitHub Profile
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="unity" type="Microsoft.Practices.Unity.Configuration.UnityConfigurationSection, Microsoft.Practices.Unity.Configuration, Version=2.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<section name="policyInjection" type="Microsoft.Practices.EnterpriseLibrary.PolicyInjection.Configuration.PolicyInjectionSettings, Microsoft.Practices.EnterpriseLibrary.PolicyInjection, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</configSections>
<unity xmlns="http://schemas.microsoft.com/practices/2010/unity">
<sectionExtension type="Microsoft.Practices.Unity.InterceptionExtension.Configuration.InterceptionConfigurationExtension, Microsoft.Practices.Unity.Interception.Configuration"/>
<!-- Using Policy Injection -->
<container name="InteceptionPolicy">
var fileMap = new System.Configuration.ExeConfigurationFileMap {
ExeConfigFilename = "unity.config"
};
Configuration configuration = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None);
var unitySection = (UnityConfigurationSection) configuration.GetSection("unity");
var uc = new UnityContainer().LoadConfiguration(unitySection, "InteceptionPolicy");
var calculator = uc.Resolve < ICalculator > ();
calculator.CalculateAdd(1, 2);
namespace Infrastructure {
public class LoggingInterceptionHandler : ICallHandler {
private readonly ILogger logger;
public int Order {
get;
set;
}
public LoggingInterceptionHandler(ILogger logger) {
this.logger = logger;
}
<?xml version="1.0"?><?xml version="1.0
<interception>
<policies>
<add name="Policy">
<matchingRule name="MatchMethods" type="MemberNameMatchingRule">
<constructor>
<param name="namesToMatch">
<array type="string[]">
<value value="Calculate*"/>
@wizact
wizact / CombinedGuard.ts
Created April 17, 2018 04:08
Combined guard since Angular does not have an order for guards in a route. Changed the original idea to throws and catch on first false
import 'rxjs/add/observable/from';
import 'rxjs/add/observable/fromPromise';
import 'rxjs/add/observable/concat';
import 'rxjs/add/operator/first';
import 'rxjs/add/operator/concat';
import 'rxjs/add/operator/takeWhile';
import 'rxjs/add/operator/reduce';
import 'rxjs/add/operator/catch';
import { Injectable } from '@angular/core';
import {
@wizact
wizact / microservices_definition.md
Last active October 31, 2017 22:16
What is Micrservices ?

What is Microservices?

Microservices are (Sam Newman):

  • Small
  • Autonomouses Services
  • That work together

Small, Focused on Doing One Thing Well

  • Taking the single responsibility principal in monolith to independent services: "Gather together those things that change for the same reason, and separate those things that change for different reasons"
@wizact
wizact / TMJListingContentHelper.cs
Created August 28, 2017 22:49
Strips all HTML tags and replace BRs with Windows Line Endings.
void Main()
{
var content = "<span>Trade Me is one of New Zealand's busiest web platforms, with around 4 million members and 850,000 people visiting the site every day. This means that the code you write will be in front of all of these people, which is pretty exciting!</span><br /><br /><span>Trade Me Property is NZ's most popular property site, with more than twice as many Kiwi visitors than any of the competition. We're proud of our ability to connect with consumers and real estate agents alike, and we have exciting plans in the pipeline!</span><br /><br /><span>To drive our success further, we're on the hunt for a passionate .NET developer to join our Auckland Property Team.</span><br /><br /><span>What you'll be doing: </span><br /><br /><ul><li>Working within our Agile environment, you'll get your hands dirty alongside other developers, testers, designers and business analysts.</li><li>Using your extraordinary skills to develop and test stories with your squad.</li><li>Contributing to requirements anal
@wizact
wizact / CollectionJson.ts
Created August 11, 2016 08:28
Collection+Json TypeScript definition
declare namespace CollectionJson {
export interface Link {
rel: string;
href: string;
prompt: string;
}
export interface QueryData {
name: string;
@wizact
wizact / cert.sh
Last active July 15, 2016 11:31
Generate cert
openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 365 -subj "/C=NZ/ST=Wellington/L=Wellington/O=ACME/OU=Org/CN=localhost" -nodes
@wizact
wizact / FlagsLeftShift.cs
Created July 7, 2016 21:34
How to do flags
void Main()
{
Console.WriteLine((int)LeftShiftEnum.None);
Console.WriteLine((int)LeftShiftEnum.Two);
Console.WriteLine((int)LeftShiftEnum.Four);
Console.WriteLine((int)LeftShiftEnum.Eight);
Console.WriteLine((int)LeftShiftEnum.Sixteen);
}
[Flags]