Skip to content

Instantly share code, notes, and snippets.

View reichert621's full-sized avatar

Alex Reichert reichert621

View GitHub Profile
@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;
import request from 'superagent';
import React from 'react';
import ReactDOM from 'react-dom';
import {
StripeProvider,
Elements,
CardElement,
injectStripe
} from 'react-stripe-elements';
@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 / check-item-in-stock.js
Last active May 31, 2020 00:37
Taro Example: Check if an item is in stock
const request = require('superagent');
const checkItemInStock = async () => {
// Checks to see if the product in the URL below is in stock
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};
@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()};
@reichert621
reichert621 / yc-jobs.js
Last active May 31, 2020 00:44
Taro Example: Scraping recent YC job posts
const moment = require('moment');
const request = require('superagent');
const cheerio = require('cheerio');
const _ = require('lodash');
const scraper = async () => {
const url = 'https://news.ycombinator.com/jobs'
const {text: html} = await request.get(url);
const $ = cheerio.load(html);
const links = $('.storylink').map((i, el) => {
@reichert621
reichert621 / reddit.js
Last active May 31, 2020 00:49
Taro Example: Get top posts from favorite subreddits
const request = require('superagent');
const _ = require('lodash');
const getTopPosts = async (subreddit, options = {}) => {
const {count = 5, interval = 'week'} = options;
const sub = `https://www.reddit.com/r/${subreddit}/top.json?sort=top&t=${interval}`;
const res = await request.get(sub);
const {children: posts} = res.body.data;
return posts.slice(0, count).map((post) => {
@reichert621
reichert621 / TODOS.md
Created June 5, 2020 02:41
Taro TODOs

TODOs

Install Taro client

npm install taro-client

Create email templates

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};
};