Skip to content

Instantly share code, notes, and snippets.

View davestevens's full-sized avatar

Dave Stevens davestevens

View GitHub Profile
@davestevens
davestevens / README.md
Created February 19, 2021 17:01
Fetching all comments from a Reddit post

Reddit API

I could not find a simple example showing how to consume the Reddit API to get the comments for a post. This shows step by step how to authenticate and the endpoints to request.

Setup

You need to create an app to get an app id and secret. Go to https://www.reddit.com/prefs/apps and at the bottom of the page under "developed applications" create a new app or view a current one.

If you click "edit" to open the app view you will be able to see the app id and secret, these are required for authentication.

@davestevens
davestevens / index.html
Last active September 21, 2020 08:13
Render a DDS to HTMLImageElement
<!DOCTYPE html>
<html>
<head> </head>
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r120/three.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/three-addons@1.2.0/build/three-addons.min.js"></script>
<script>
const loader = new THREE_ADDONS.DDSLoader();
loader.load("bucket.DDS", (texture) => {
texture.wrapT = THREE.RepeatWrapping;
@davestevens
davestevens / download-images-from-google-drive.js
Last active March 15, 2023 16:20
Download images from Google Drive folder using Node.js Google library
var google = require("googleapis"),
drive = google.drive("v2"),
fs = require("fs");
var config = {
"client_id": "client_id",
"client_secret": "client_secret",
"scope": "scope",
"redirect_url": "redirect_rul",
"tokens": {
@davestevens
davestevens / LetsEncrypt.md
Last active March 28, 2024 10:35
Let’s Encrypt setup for Apache, NGINX & Node.js

Let's Encrypt

Examples of getting certificates from Let's Encrypt working on Apache, NGINX and Node.js servers.

Obtain certificates

I chose to use the manual method, you have to make a file available to verify you own the domain. Follow the commands from running

git clone https://github.com/letsencrypt/letsencrypt
cd letsencrypt
@davestevens
davestevens / replaceState.html
Created September 3, 2015 14:53
replaceState test
<!--
Opening this in the latest Chrome (Version 45.0.2454.85) results in an error
"Uncaught SecurityError: Failed to execute 'replaceState' on 'History'"
This has only just stated happening this afternoon and doesn't cause an issue on older versions of Chrome
-->
<!DOCTYPE html>
<html>
<head>
<title>Testing replaceState</title>
</head>
@davestevens
davestevens / Controller.php
Created April 3, 2015 11:46
Displays all Database Queries in Laravel 5
<?php namespace App\Http\Controllers;
use Illuminate\Foundation\Bus\DispatchesCommands;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Log;
use DB;
abstract class Controller extends BaseController {
@davestevens
davestevens / slack_notify.rake
Created February 18, 2015 18:15
Capistrano Slack integration.
# Capistrano Task that hooks into `deploy:finished` to send a message to Slack
#
# 1. Setup a Slack Incoming Webhook Integration (https://api.slack.com/incoming-webhooks)
# 2. Put the Webhook URL in an Environment variable (SLACK_WEBHOOK_URL)
# 3. Place this file in `lib/capistrano/tasks`
#
# This will then create a new message in the channel on deployment, including who, what and where information
require "net/http"
require "json"
@davestevens
davestevens / Gemfile
Created January 21, 2015 23:51
BCrypt Issue
source "https://rubygems.org"
gem "bcrypt"
@davestevens
davestevens / inject_vs_each_with_object.rb
Created January 19, 2015 14:16
Inject vs. Each With Object
#!/usr/bin/env ruby
inputs = [[1,2,3], [2,4,6], [1,3,5]]
inject_output = inputs.inject([]) do |memo, input|
memo |= input
memo
end
each_with_object_output = inputs.each_with_object([]) do |input, memo|
@davestevens
davestevens / index.html
Created September 18, 2014 13:34
Scroll Issue in Chrome at 110% zoom
<!DOCTYPE html>
<html>
<head>
<title>Scroll Test</title>
<style>
.wrapper {
height: 40px;
width: 400px;
overflow: auto;
}