Skip to content

Instantly share code, notes, and snippets.

View michal-turzynski's full-sized avatar

Michal Turzynski michal-turzynski

View GitHub Profile

WORKING EFFECTIVELY WITH LEGACY CODE

To me, legacy code is simply code without tests. I’ve gotten some grief for this definition. What do tests have to do with whether code is bad? To me, the answer is straightforward, and it is a point that I elaborate throughout the book: Code without tests is bad code. It doesn’t matter how well written it is; it doesn’t matter how pretty or object-oriented or well-encapsulated it is. With tests, we can change the behavior of our code quickly and verifiably. Without them, we really don’t know if our code is getting better or worse.

Chapter 1 Changing Software

Four Reasons to Change Software: For simplicity’s sake, let’s look at four primary reasons to change software.

@michal-turzynski
michal-turzynski / tye.yml
Last active November 10, 2020 19:39
Project tye with ngrok service
name: sample-project
services:
- name: ngrok
image: wernight/ngrok
bindings:
- port: 4040
protocol: http
env:
- name: NGROK_LOOK_DOMAIN
value: "sample-app"
@michal-turzynski
michal-turzynski / D365-marketing-configuration-migration-schema.xml
Last active June 18, 2020 09:00
Dynamics 365 for Marketing - Configuration Migration schema file
<entities >
<entity name="msdyncrm_marketingemail" displayname="Marketing email" etc="10213" primaryidfield="msdyncrm_marketingemailid" primarynamefield="msdyncrm_name" disableplugins="false">
<fields>
<field displayname="Automatically generate plain text" name="msdyncrm_automaticallygeneratetextpart" type="bool" customfield="true" />
<field displayname="Click map" name="msdyncrm_clickmap" type="string" customfield="true" />
<field displayname="Content type" name="msdyncrm_email_contenttype" type="optionsetvalue" customfield="true" />
<field displayname="Description" name="msdyncrm_description" type="string" customfield="true" />
<field displayname="Designer HTML" name="msdyncrm_designerhtml" type="string" customfield="true" />
<field displayname="Email body" name="msdyncrm_emailbody" type="string" customfield="true" />
<field displayname="Email from address" name="msdyncrm_fromemail" type="string" customfield="true" />
@michal-turzynski
michal-turzynski / gist:1499665ce0e6fa116f6606e041ee8b66
Created May 13, 2020 10:34 — forked from msusur/gist:e34be94cbceac20ea364
Dynamics CRM Dependency Injection Workaround
public abstract class SuperPlugin : IPlugin{
private static Lazy<IDependencyResolver> DependencyResolverTrunk = new Lazy<IDependencyResolver>(ResolverFactory);
public void Execute(IServiceProvider serviceProvider){
// initialize a static container instance if not available
var containerWrapper = new ContainerWrapper{
Container = serviceProvider.GetService(typeof(IPluginExecutionContext)),
Resolver = DependencyResolverTrunk.Value
};
OnExecution(containerWrapper);
kubectl get pods | grep Evicted | awk '{print $1}' | xargs kubectl delete pod
@michal-turzynski
michal-turzynski / clean_code.md
Created January 22, 2020 18:05 — forked from wojteklu/clean_code.md
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

<policies>
<inbound>
<base />
<set-backend-service id="apim-generated-policy" backend-id="abcd" />
<validate-jwt header-name="Authorization" failed-validation-httpcode="401" failed-validation-error-message="Unauthorized. Access token is missing or invalid.">
<openid-config url="https://<b2c tenant name>.b2clogin.com/<b2c tenant name>.onmicrosoft.com/v2.0/.well-known/openid-configuration?p=<policy name>" />
<required-claims>
<claim name="iss">
<value>https://<b2c tenant name>.b2clogin.com/<AD tenant id>/v2.0/</value>
</claim>
version: "3.7"
services:
umbrella:
image: nrel/api-umbrella
volumes:
- ${WEBAPP_STORAGE_HOME}/config:/etc/api-umbrella
ports:
- "80:80"
- "443:443"
restart: always
umbrella:
image: nrel/api-umbrella
volumes:
- ${WEBAPP_STORAGE_HOME}/config:/etc/api-umbrella nrel/api-umbrella
[cmdletbinding(
DefaultParameterSetName="Subscription"
)]
param
(
[Parameter(ParameterSetName="Subscription",Mandatory=$true, HelpMessage="Enter Azure Subscription name. You need to be Subscription Admin to execute the script")]
[string] $subscriptionName,
[Parameter(ParameterSetName="ManagementGroup",Mandatory=$true, HelpMessage="Enter Azure Management Group Id. You need to be Management Group Admin to execute the script")]
[string] $managementGroupId,