Skip to content

Instantly share code, notes, and snippets.

@mitchgollub
mitchgollub / net-core-appsettings-json-variable-replacement-in-appveyor-1.ps1
Created July 14, 2019 20:52
net-core-appsettings-json-variable-replacement-in-appveyor
Write-Host "Environment Variable Substitution"
$variables = gci $env:$env:APPLICATION_PREFIX* | Select-Object -Property Key, Value
$configPath = "$env:APPLICATION_PATH\$env:CONFIG_FILE"
Write-Output "Loading config file from $configPath"
$appSettings = Get-Content -Raw $configPath | ConvertFrom-Json
foreach($variable in $variables) {
foreach (var salesRep in salesReps)
{
var summary = new SalesSummary { SalesRep = salesRep };
var repTransactions = transactions.Where(x => x.SalesRep == salesRep);
summary.Y2DSold = repTransactions.Where(x => x.Date >= new DateTime(dateTimeNow.Year, 1, 1))
.Select(x => CalculateTransaction(x))
@mitchgollub
mitchgollub / defensive-programming-strings-1.cs
Created July 14, 2019 21:26
defensive-programming-strings
Object shares = getValueFromField("SHARES");
Shares = (string)shares;
@mitchgollub
mitchgollub / defensive-programming-strings-2.cs
Created July 14, 2019 21:47
defensive-programming-strings-2
Object shares = getValueFromField("SHARES");
Shares = shares?.ToString();
@mitchgollub
mitchgollub / react-high-order-components.js
Created September 28, 2019 02:08
React: High Order Components Example
const HoC = Component => EnhancedComponent;
@mitchgollub
mitchgollub / react-high-order-components-2.js
Created September 28, 2019 02:11
React: High Order Components 2
const withClassName = Component => props => (
<Component {...props} className="my-class" />
);
@mitchgollub
mitchgollub / react-high-order-components-3.jsx
Last active December 2, 2022 22:25
React: High Order Components 3
const Profile = ({ username, age }) => (
<div>
<div>Username: {username}</div>
<div>Age; {age}</div>
</div>
);
Profile.propTypes = {
username: string,
age: number
};
@mitchgollub
mitchgollub / react-high-order-components-4.jsx
Last active September 28, 2019 20:03
React: High Order Components 4
const Profile = ({ name }) => (
<div>
<div>Name: {name}</div>
</div>
);
Profile.propTypes = {
name: string
};
const ProfileWithRenamedUsername = renameProp('username', 'name')(Profile);
@mitchgollub
mitchgollub / react-high-order-components-5.jsx
Last active September 28, 2019 20:05
React High Order Components 5
const enhance = compose(
flattenProp('user'),
renameProp('username', 'name')
);
// Combine HOC's (from Recompose or custom) with compose
const EnhancedProfile = enhance(Profile);
@mitchgollub
mitchgollub / launch.json
Created January 31, 2020 03:18
AWS SAM Lambda VS Code launch config
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch via NPM",
"runtimeExecutable": "npm",
"cwd": "${workspaceFolder}/hello-world",
"runtimeArgs": [