Skip to content

Instantly share code, notes, and snippets.

View reichert621's full-sized avatar

Alex Reichert reichert621

View GitHub Profile
@reichert621
reichert621 / useCustomizableFont.ts
Last active February 8, 2024 21:06
Quickly inject a Google font into your Next app via "font" query parameter
import {useRouter} from 'next/router';
import {useEffect} from 'react';
// Small hack to inject a Google font into the webpage
function appendCustomFont(font: string) {
if (typeof document === 'undefined') {
return console.warn(
'`window.document` unavailable: cannot append custom font.'
);
}
.ChatWidget{margin:0}.TextArea--transparent,.TextArea--transparent:active,.TextArea--transparent:focus,.TextArea--transparent:hover{border:none;box-shadow:none;resize:none;outline:0}button.WidgetToggle{outline:none;border:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;cursor:pointer;width:50px;height:50px;border-radius:50%;display:flex;justify-content:center;align-items:center}
parcelRequire=function(e,r,t,n){var i,o="function"==typeof parcelRequire&&parcelRequire,u="function"==typeof require&&require;function f(t,n){if(!r[t]){if(!e[t]){var i="function"==typeof parcelRequire&&parcelRequire;if(!n&&i)return i(t,!0);if(o)return o(t,!0);if(u&&"string"==typeof t)return u(t);var c=new Error("Cannot find module '"+t+"'");throw c.code="MODULE_NOT_FOUND",c}p.resolve=function(r){return e[t][1][r]||r},p.cache={};var l=r[t]=new f.Module(t);e[t][0].call(l.exports,p,l,l.exports,this)}return r[t].exports;function p(e){return f(p.resolve(e))}}f.isParcelRequire=!0,f.Module=function(e){this.id=e,this.bundle=f,this.exports={}},f.modules=e,f.cache=r,f.parent=o,f.register=function(r,t){e[r]=[function(e,r){r.exports=t},{}]};for(var c=0;c<t.length;c++)try{f(t[c])}catch(e){i||(i=e)}if(t.length){var l=f(t[t.length-1]);"object"==typeof exports&&"undefined"!=typeof module?module.exports=l:"function"==typeof define&&define.amd?define(function(){return l}):n&&(this[n]=l)}if(parcelRequire=f,i)throw i;return f}({
@reichert621
reichert621 / hn-google-sheets-slack.js
Created June 12, 2020 20:30
Send top Hacker News posts to Slack and Google Sheets
const Taro = require('taro-client')(
'__YOUR_API_KEY__'
);
const main = async () => {
const posts = await Taro.scrape.hn({threshold: 400});
if (posts.length === 0) {
return;
}
@reichert621
reichert621 / index.js
Created June 12, 2020 02:55
Taro Slack demo
const Taro = require('taro-client')('__YOUR_API_KEY__');
Taro.notify.slack({message: 'Hello from NodeJS!'});
@reichert621
reichert621 / reddit-slack.js
Created June 9, 2020 14:38
Taro Example: Send top subreddit post to Slack
const request = require('superagent');
const Taro = require('taro-client')(
// Replace this with your Taro API key
process.env.TARO_API_KEY
);
const getTopPost = async (subreddit) => {
const sub = `https://www.reddit.com/r/${subreddit}/top.json`;
const res = await request.get(sub).query({sort: 'top', t: 'day'});
const {children: posts} = res.body.data;
@reichert621
reichert621 / TODOS.md
Created June 5, 2020 02:41
Taro TODOs

TODOs

Install Taro client

npm install taro-client

Create email templates

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