Skip to content

Instantly share code, notes, and snippets.

View reichert621's full-sized avatar

Alex Reichert reichert621

View GitHub Profile
@reichert621
reichert621 / ping-server.js
Last active May 31, 2020 00:32
Taro Example: Ping your server
const request = require('superagent');
const ping = async () => {
const res = await request.get('https://taro-beta.herokuapp.com/api/ping');
return res.body;
};
// Run function and verify output
ping().then(console.log).catch(console.log);
@reichert621
reichert621 / inspirational-quote.js
Last active May 31, 2020 00:34
Taro Example: Inspirational quotes
const request = require('superagent');
const _ = require('lodash');
const getRandomInspirationalQuote = async () => {
const {text: json} = await request.get('https://type.fit/api/quotes');
const quotes = JSON.parse(json);
return _.sample(quotes);
};
@reichert621
reichert621 / hacker-news.js
Last active May 31, 2020 00:39
Taro Example: Scraping top Hacker News posts
const request = require('superagent');
const cheerio = require('cheerio');
const _ = require('lodash');
const scraper = async (threshold = 200) => {
const url = 'https://news.ycombinator.com/'
const {text: html} = await request.get(url);
const $ = cheerio.load(html);
const links = $('.storylink').map((i, el) => {
return {href: $(el).attr('href'), text: $(el).text()};
const request = require('superagent');
const checkItemInStock = async () => {
const {text: html} = await request.get(
'https://www.bowflex.com/selecttech/552/100131.html'
);
const inStock = html.toLowerCase().indexOf('out of stock') === -1;
return {inStock};
};
// import ...
import './App.css'; // Import our new CSS
const STRIPE_API_KEY = 'pk_test_...';
const createCharge = token => {
// ...
};
const Form = props => {
@import url('https://fonts.googleapis.com/css?family=Open+Sans:300,400,500');
* {
box-sizing: border-box;
}
html,
body {
font-family: 'Open Sans', 'Helvetica Neue', Arial, san-serif;
line-height: 1.15;
@reichert621
reichert621 / index.html
Created July 1, 2019 02:23
HTML with Stripe
<!DOCTYPE html>
<html lang="en">
<head>
<!-- ... -->
<!-- Add this script tag within the <head> tags! -->
<script src="https://js.stripe.com/v3"></script>
</head>
<body>
const express = require('express');
const bodyParser = require('body-parser');
const stripe = require('stripe')(process.env.STRIPE_SECRET_KEY);
const app = express();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
const createOrder = (skuId, { email, name, address }) => {
// 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);
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;