Skip to content

Instantly share code, notes, and snippets.

@mitchgollub
mitchgollub / package.json
Created February 1, 2020 22:23
Package.json for AWS Lambda Node
{
"name": "hello_world",
"version": "1.0.0",
"description": "hello world sample for NodeJS",
"main": "app.js",
"repository": "https://github.com/awslabs/aws-sam-cli/tree/develop/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs",
"author": "SAM CLI",
"license": "MIT",
"scripts": {
"debug": "sam local invoke --template ../template.yaml --event ../events/event.json -d 9229",
@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": [
@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 / 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-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-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.js
Created September 28, 2019 02:08
React: High Order Components Example
const HoC = Component => EnhancedComponent;
@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 / defensive-programming-strings-1.cs
Created July 14, 2019 21:26
defensive-programming-strings
Object shares = getValueFromField("SHARES");
Shares = (string)shares;
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))