Skip to content

Instantly share code, notes, and snippets.

View jeffreymeng's full-sized avatar

Jeffrey Meng jeffreymeng

View GitHub Profile
from collections import defaultdict
import os
import discord
from discord import Message
from dotenv import load_dotenv
intents = discord.Intents.default()
intents.message_content = True
@jeffreymeng
jeffreymeng / useAuthState-introduction.md
Last active September 4, 2023 15:27
Gatsby React Firebase Authentication Hook

As opposed to useAuthState in react-firebase-hooks (which doesn't work with gatsby builds), this is designed to work with gatsby-plugin-firebase.

Requires React and firebase

Usage example:

import firebase from "gatsby-plugin-firebase"
import useAuthState from ...
@jeffreymeng
jeffreymeng / README.md
Last active June 3, 2023 21:53
Canvas Quiz Scraper

This script can scrape the quiz result view of canvas, capturing questions, answers, and images. It automatically downloads a JSON file with the scraped data, and downloads each image individually. The scraped data will track your selected answers (independent of whether they are correct). This script is designed to be run in the chrome dev console. You will need to first load jquery if it is not in scope, which can be accomplished by going to the jquery website and copy-pasting the jquery.min.js file into the console.

Due to the nature of web scraping, you may need to adapt this code to fit the specific page semantics you're working with.

#!/bin/bash
BASE_PATH="~/Documents/code/"#change this to suit your needs
if [ "$#" == 0 ]
then
echo "Gitsync: Invalid Usage. See gitsync --help for more information"
elif [ "$1" == "--help" ] || [ "$1" == "--usage" ]
@jeffreymeng
jeffreymeng / Jquery-Replacement-Utility-Code-main-code.js
Last active October 28, 2018 20:40
Jquery Replacement Utility Code
//this is just the base code. To see a usage example, see Jquery-Replacement-Utility-Code-example-code.js
var getElement = function(selector) { // or var $ = function(selector) {
var wrapper = document.querySelector(selector);
// get Dom wrapper.
//function to add custom functions to the wrapper.
this.addFunction = function(name, code) {
// if code is undefined, assume name is an object with name:function pairs
//enumerate the object name
package BlackJackCopy;
import java.awt.*;
import javax.swing.*;
public class GUI extends JPanel{
final int width = 800;
final int height = 600;
package blackjack;
class Card {
public int number;//1 is ace, 2 is two, 13 is king
public int suit;//1 is club, 2 is diamond, 3 is heart, 4 is spade
public Card(int number, int suit) {//make a new card
this.number = number;
#include "stdafx.h"
// http://uva.onlinejudge.org/index.php?option=onlinejudge&page=show_problem&problem=2176
#include "UVa11235.h"
#include <iostream>
#include <list>
#include <map>
#include <algorithm>
#!/bin/bash
BASE_PATH="UNKNOWN - edit this by changing the variable in the gitsync file."
if [ "$#" == 0 ]
then
echo "Gitsync: Invalid Usage. See gitsync --help for more information"
elif [ "$1" == "--help" ] || [ "$1" == "--usage" ]
@jeffreymeng
jeffreymeng / auto image in new tab.md
Last active August 26, 2017 01:25
Works on any html file with images(word file saves as html, raw html file, etc.)

Usage: Works on any html file. When you have any html file with images(using src tag), and a user clicks on an image element, that image(the src) will automatically open in a new tab or window(depending on user/browser prefrence)

All you have to do is include the quick-use.html file's raw code(the script element and its contents) and add it to the end of your html(right before the closing body tab, or with all your other scripts. AFTER the images).