Skip to content

Instantly share code, notes, and snippets.

View DenverCoder1's full-sized avatar
👨‍💻
Always learning!

Jonah Lawrence DenverCoder1

👨‍💻
Always learning!
View GitHub Profile
<?php
// Get the contents of a URL
function curl_get_contents($url): string
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_AUTOREFERER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_URL, $url);
@DenverCoder1
DenverCoder1 / checkRedditUser.gs
Last active August 9, 2021 16:52
Google Apps Script to check if a given Reddit user exists.
// check if a reddit user exists using response code
// returns "TRUE" if they exist
// returns Error message if 404 response
function checkUser(input) {
// check that the input is a string
if (typeof user == 'string' && user.length) {
// open cache service for caching results
var cache = CacheService.getScriptCache();
// remove u/ and trailing spaces from username to normalize inputs
var user = input.replace(/^\/?(user|u|U)\//, "").trim();