Skip to content

Instantly share code, notes, and snippets.

View ryanwarsaw's full-sized avatar

Ryan Warsaw ryanwarsaw

View GitHub Profile
@ryanwarsaw
ryanwarsaw / tic-tac-toe.html
Created January 9, 2020 21:33
Just having a little bit of fun with this demo
<!DOCTYPE html>
<html>
<head>
<title>Tic Tac Toe</title>
<style>
.board {
display: grid;
grid-gap: 5px;
grid-template-columns: repeat(3, 150px);
}
@ryanwarsaw
ryanwarsaw / Application.jsx
Created August 16, 2019 14:04
Automatic browser theme detection (and support) using React 16 context and hooks
import React from 'react';
import { Card } from '../components';
import { ThemeContext } from '../util';
class Application extends React.Component {
static contextType = ThemeContext;
toggleTheme = () => {
const newTheme = this.state.theme === 'light' ? 'dark' : 'light';
this.setState(state => ({ theme: newTheme }));
@ryanwarsaw
ryanwarsaw / delete-all-messages.js
Created December 7, 2018 02:27 — forked from IMcPwn/delete-all-messages.js
Delete all messages in a Discord channel
// Turn on Developer Mode under User Settings > Appearance > Developer Mode (at the bottom)
// Then open the channel you wish to delete all of the messages (could be a DM) and click the three dots on the far right.
// Click "Copy ID" and paste that instead of LAST_MESSAGE_ID.
// Copy / paste the below script into the JavaScript console.
// If you're in a DM you will receive a 403 error for every message the other user sent (you don't have permission to delete their messages).
var before = 'LAST_MESSAGE_ID';
clearMessages = function(){
const authToken = document.body.appendChild(document.createElement`iframe`).contentWindow.localStorage.token.replace(/"/g, "");
const channel = window.location.href.split('/').pop();
@ryanwarsaw
ryanwarsaw / sessions.json
Created August 9, 2018 16:23
Every session for Mozilla Festival 2018
This file has been truncated, but you can view the full file.
[
{
"title": "(Test) My first MozFest session proposal in 2018",
"owner": {
"name": "Mavis Ou",
"organization": "Mozilla\n\n\n\n\n\n\n\n\n\n\n\n\n---"
},
"milestone": "Decentralisation",
"labels": [
"Localisation support requested",
// TODO: Write a comment here.
void Dgraph::Dfs(int vertex) {
auto *has_been_visited = new bool[this->vertices_];
// set them all to unvisited.
for (int index = 0; index < this->vertices_; index++) {
has_been_visited[index] = false;
}
has_been_visited[vertex] = true;
stack<int> stack;
#ifndef LINKED_LIST_LIST_H_
#define LINKED_LIST_LIST_H_
#include <stdexcept>
#include <ostream>
using namespace std;
template<class T>
class Node {
template<typename T>
inline void Queue<T>::Enqueue(const T &element) {
if (this->data_->IsEmpty()) {
this->data_->AddToEnd(element);
} else {
Node<T> *node = this->data_->PeekHead();
if (node->data_ != element) {
// Issue here when inserting something into the first node.
while (node->next_ != nullptr) {
node = node->next_;
#include <iostream>
#include <fstream>
#include <vector>
#include <sstream>
using namespace std;
// TODO: Explain how this entire jumble of code works clearly and precisely.
vector<string> ParseWords(const string &line) {
vector<string> tokens;
{
"version": 0,
"weeks": [
{
"id": "0",
"title": "Week 1",
"topic": "Which fruits are best on a rainy day?",
"video": "videos/week1.mp4",
"questions": [
{
template<typename T>
void ShellSortFibonacci(vector<T> &list) {
vector<int> gap_sequence;
int exponent = 2;
while (fibonacci(exponent) < list.size()) {
int result = fibonacci(exponent);
exponent++;
gap_sequence.push_back(result);
}