Skip to content

Instantly share code, notes, and snippets.

View chrisjensen's full-sized avatar

Chris Jensen chrisjensen

View GitHub Profile
@chrisjensen
chrisjensen / nginx.conf
Last active January 21, 2021 02:42
NGINX and Node NGINX.conf
# NGINX reverse proxies everything that comes to edge and either
# sends it to the edge Node server or to our API
#
# Some common problems you might encounter:
# SSL_do_handshake() failed (SSL: error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure) while SSL handshaking to upstream
# Could mean you're passing a request to the API without using
# proxy_ssl_server_name on;
#
# If you're getting host not found issues you may need to
# proxy_set_header Host ${API_HOST}
@chrisjensen
chrisjensen / launch.sh
Created January 21, 2021 02:37
NGINX + Node launch file
#!/usr/bin/env bash
set -e
# Merge environment variable
envsubst '${RESOLVER}' < /home/app/nginx.conf > /home/app/nginx-complete.conf
# Launch nginx and node concurrently
nginx -g 'daemon off;' -c /home/app/nginx-complete.conf &
if [ "$NODE_ENV" = "development" ]; then
@chrisjensen
chrisjensen / Docker
Last active January 21, 2021 02:39
NGINX + Node Docker on Fly
FROM nginx:1.15.7-alpine
WORKDIR /home/app
ENV TINI_VERSION v0.18.0
ENV TINI_SHA "50a5bb62e3c4fdfb442da6d1530abb2b6afacc24"
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-static /tini
RUN echo "$TINI_SHA /tini" | sha1sum -c -
RUN chmod +x /tini
@chrisjensen
chrisjensen / donateButton.js
Created June 16, 2020 10:01
Expanding Donate Button
const { DonationForm } = RaiselyComponents.Molecules;
const [showDonate, setShowDonate] = useState(false);
return (
<div className="donation-profile__wrapper spotlight-donate">
{showDonate ? (
<DonationForm
profileUuid={profile.uuid}
title={`Donate to ${profile.name}`}
integrations={props.integrations}
@chrisjensen
chrisjensen / calculateSplitDonations.js
Last active June 16, 2020 09:38
Calculate split donations
// Load all charity profiles using the Raisely API
const profiles = await getData(api.profiles.getAll());
// Sum the donations to a specific charity
const totalSpecific = profiles.reduce(
(total, profile) => total + profile.total,
0
);
// Calculate the general donations by subtracting specific donations from the total of all donations
const totalGeneral =
get(this.props, "global.campaign.total", 0) - totalSpecific;
@chrisjensen
chrisjensen / showCostumeTile.js
Last active June 16, 2020 09:14
Display costume tile
const { SlimContent } = RaiselyComponents.Loading;
const { ProfileImage, ProgressBar } = RaiselyComponents.Atoms;
return (
<React.Fragment>
{props.header}
<div className={`profile-tile profile-tile--detail-${detail}`}>
<ProfileImage
defaultImage={defaultImage}
profile={profile}
@chrisjensen
chrisjensen / loadCostumes.js
Created June 16, 2020 09:02
Load Costumes
async function loadCostumes(props) {
if (get(props, 'global.campaign.mock')) return mockCostumes;
try {
const response = await fetch(url);
if (!response.ok) {
console.error(await response.text());
throw new Error('Could not load. Try refreshing the page');
}
const body = await response.json();
@chrisjensen
chrisjensen / loadHighestDonor.js
Last active June 16, 2020 08:51
Load Highest Donor
useEffect(() => {
async function fetchData() {
const response = await fetch(url);
if (!response.ok) {
console.error(await response.text());
throw new Error('Could not load. Try refreshing the page');
}
const body = await response.json();
const [topDonor, secondDonor] = body.data.donors;
@chrisjensen
chrisjensen / styleHighestDonors.scss
Created June 15, 2020 21:01
Style Highest Donor
.highest-donor {
&__wrapper {
padding: 1rem;
background: white;
color: black;
text-align: center;
}
&__body {
font-size: 1.2rem;
@chrisjensen
chrisjensen / displayHighestDonor.js
Last active June 16, 2020 08:50
Display Highest Donor
return (
<div className="highest-donor__wrapper">
<p className="highest-donor__body">Chris will dance to a song chosen by {leadDonor}</p>
<p className="highest-donor__gap">(or you for a donation of ${highestGift})</p>
</div>
);