Skip to content

Instantly share code, notes, and snippets.

View reichert621's full-sized avatar

Alex Reichert reichert621

View GitHub Profile
@reichert621
reichert621 / app.js
Last active May 21, 2019 07:57
Upload files to Amazon S3 with loopback, loopback-component-storage, angular, ng-file-upload
// bower dependency: "ng-file-upload"
// npm dependency: "loopback-component-storage"
'use strict';
angular
.module('app', [
'ngFileUpload'
])
.controller('UploadController', function(Upload) {
@reichert621
reichert621 / keybase.md
Created December 19, 2016 18:37
Keybase proof

Keybase proof

I hereby claim:

  • I am reichert621 on github.
  • I am alexhaven (https://keybase.io/alexhaven) on keybase.
  • I have a public key whose fingerprint is 17B5 344A 2ABB A851 11D5 7700 776C 6210 F268 C1A7

To claim this, I am signing this object:

@reichert621
reichert621 / overview.md
Created June 7, 2018 21:47
Mental Health Project Overview

Purpose

Goal

  • To track daily habits and productivity against mental health (i.e. anxiety, happiness, depression, stress, etc.)
  • Using this information, to determine which habits/actions have the biggest impact on our mental health

Target audience

  • People who would like to improve their psychological well-being by adopting new habits to find out which ones actually have a quantifiable positive impact on their lives
  • People who would like to improve their productivity and also track the impact of what they consider "productive" on their mental health
  • People looking to get more self-disciplined and improve self-awareness
@reichert621
reichert621 / validations-0.js
Last active September 12, 2018 07:09
Refactoring #0
const handleValidations = inputs => {
const { name, email, birthday } = inputs;
const required = ['name', 'email', 'address', 'state', 'country', 'birthday'];
let errors = {};
for (let i = 0; i < required.length; i += 1) {
const val = required[i];
if (inputs[val].length < 1) {
@reichert621
reichert621 / validations-1.js
Created September 9, 2018 04:51
Refactoring 1
const moment = require('moment');
const isInputPresent = input => {
return input && typeof input === 'string' && input.trim().length > 0;
};
const isValidEmail = email => {
const regex = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return regex.test(String(email).toLowerCase());
@reichert621
reichert621 / validations-2.js
Created September 9, 2018 05:11
Refactoring 2
const getValidators = () => {
return [
{
field: 'name',
validations: [
[isInputPresent, 'Name is required'],
[isValidName, 'Invalid name']
]
},
import request from 'superagent';
import React from 'react';
import ReactDOM from 'react-dom';
import {
StripeProvider,
Elements,
CardElement,
injectStripe
} from 'react-stripe-elements';
import React from 'react';
import { StripeProvider, Elements, injectStripe } from 'react-stripe-elements';
// Replace with your public key (https://dashboard.stripe.com/test/apikeys)
const STRIPE_API_KEY = 'pk_test_xxx';
const Checkout = props => {
const handleCheckout = () => {
props.stripe.redirectToCheckout({
items: [{ sku: props.skuId, quantity: 1 }],
import request from 'superagent';
import React from 'react';
import StripeCheckout from 'react-stripe-checkout';
// Replace with your public key (https://dashboard.stripe.com/test/apikeys)
const STRIPE_API_KEY = 'pk_test_xxx';
const createOrder = (skuId, customer) => {
const { email, name, address } = customer;
// Load environment variables from our `.env` file
require('dotenv').config();
const path = require('path');
const express = require('express');
// Make sure your STRIPE_SECRET_KEY exists as an environment variable!
// This should look something like `sk_test_xxxxxxxxxxxxxxxxxxxxxxxxx`
// and can be found at https://dashboard.stripe.com/test/apikeys
const stripe = require('stripe')(process.env.STRIPE_SECRET_KEY);