Skip to content

Instantly share code, notes, and snippets.

View peterrattew's full-sized avatar

Peter Denham peterrattew

  • London
  • 23:48 (UTC +01:00)
View GitHub Profile
@peterrattew
peterrattew / README.md
Last active March 18, 2022 17:06
Quickly add autolinks to all repositories in an organisation

Automated auto linker

Quickly set up autolinks for all repositories in your org

Just replace the fiew variables at the top and run it in node. yarn && node index.mjs

@peterrattew
peterrattew / Dockerfile
Created December 1, 2021 08:48
New Relic Source Maps Docker Image
FROM alpine
RUN apk --update add curl jq bash
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
WORKDIR /home/appuser
RUN mkdir forNewRelic
ADD start.sh /home/appuser
@peterrattew
peterrattew / index.js
Last active November 4, 2021 08:31
medium-add-to-bag
function AddToCart({ stockStatus, loading, isAddedToCart, isLoggedIn, grandTotal }) {
if(stockStatus === "OUT_OF_STOCK") return <button>OUT OF STOCK</button>;
if(loading) return "loading...";
if(isAddedToCart && !isLoggedIn) return <span>Login to view bag</span>;
if(isAddedToCart && isLoggedIn) return (
<>
<span>View Bag: </span>
<span>{Math.round(grandTotal)}</span>
</>
);
@peterrattew
peterrattew / index.js
Last active April 28, 2021 12:14
Conditional rendering using object literals
const { role } = user;
const components = {
ADMIN: AdminUser,
EMPLOYEE: EmployeeUser,
USER: NormalUser
};
const Component = components[role];
return <Component />;

Keybase proof

I hereby claim:

  • I am peterrattew on github.
  • I am peterrattew (https://keybase.io/peterrattew) on keybase.
  • I have a public key ASBf-ZAJDH1Fvkx5ucrnbWuaGgBw-YCVs5UjhGH5E9qhpwo

To claim this, I am signing this object: