Skip to content

Instantly share code, notes, and snippets.

View rtoal's full-sized avatar
💭
Copying and pasting

Ray Toal rtoal

💭
Copying and pasting
View GitHub Profile
@rtoal
rtoal / UFOCodeAlong.md
Last active September 27, 2023 00:48
Instructions for a UFO 3-D Codealong using the p5js editor

Code Along

Brief notes on a 45 minute code-along I like to do to introduce P5.js, 3-D graphics, variables, objects, conditionals, and animation.

  • (Optional) make an account for the p5js editor
  • Go to https://editor.p5js.org/
  • File -> New if not already at a new file
  • Name it if you like
  • In function setup, replace line with createCanvas(500, 500, WEBGL);
  • Run (hit the "Play" button)
@rtoal
rtoal / rsa-math-example.txt
Created April 17, 2022 22:15
Python shell session to check RSA-style math
>>> p = 36469
>>> q = 50929
>>> n = p * q
>>> n
1857329701
>>> e = 65537
>>> d = pow(e, -1, (p-1)*(q-1))
>>> d
395695169
>>> m = bytes("¿Dónde está ud.?", "utf-8")
<head>
<link href="https://fonts.googleapis.com/css?family=Courgette|Catamaran|Tangerine|Assistant|Lora|Source+Sans+Pro|Open+Sans|Pacifico|Nothing+You+Could+Do|Lato|Titillium+Web" rel="stylesheet">
<style>
td {width: 150px; height: 150px; text-align: center; font-family:Helvetica}
.js {font-family: Assistant; font-size:450%; font-weight:800; text-align:right; padding-right:10px}
.rust {font-family: 'Source Sans Pro'; font-size: 300%; font-weight: 500}
.python {font-family: 'Titillium Web'; font-size: 250%; font-weight: normal; color:#bbb}
.haskell {font-family: Helvetica; font-size: 225%; font-weight: 500; letter-spacing: -2px}
.java {font-family: 'Open Sans'; font-size: 300%; font-weight:400; color:#eef}
.elm {font-family: 'Open Sans'; font-size: 325%; font-weight: 300; letter-spacing: 5px}
@rtoal
rtoal / ExercisesTest.java
Created October 14, 2020 00:54
Test suite for CMSI 386 Java Homework
import java.util.HashMap;
import java.util.List;
import java.util.ArrayList;
import java.util.Set;
import java.util.Map;
import java.util.Optional;
public class ExercisesTest extends TestSuite {
public static void main(String[] args) {
TestSuite.run(new ExercisesTest());
@rtoal
rtoal / TestSuite.java
Created October 1, 2020 04:37
A not-half-bad test framework for Java
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.util.Objects;
import java.util.function.Consumer;
public abstract class TestSuite {
int successes = 0;
int failures = 0;
int errors = 0;
@rtoal
rtoal / main.rs
Created September 14, 2019 16:06
The guessing game from the Rust book
use std::io;
use std::cmp::Ordering;
use rand::Rng;
fn main() {
println!("Guess the number!");
let secret_number = rand::thread_rng().gen_range(1, 101);
loop {
@rtoal
rtoal / practice-midterm.md
Last active October 9, 2019 14:31
CMSI 386 Practice Exam

CMSI 386 Practice Exam

Name: (ENTER YOUR NAME HERE)

Problem 1: Forcing Keyword Arguments

Suppose the boss demanded a function to compute the area of a rectangle. The boss says the function MUST have four parameters, x1, y1, x2, and y2 where (x1, y1) is one of the corner points and (x2, y2) is the other corner point. But since our users can never remember what order the four parameters go in (Is it x1-x2-y1-y2 or x1-y1-x2-y2?), we will make our function REQUIRE that the four arguments in the call be “named.” Note that I said required. The function is not supposed to work if the arguments are not named. In fact, it should be an error to make a call without “naming” the arguments.

a) Write the function in JavaScript:

@rtoal
rtoal / rest-auth-notes.md
Last active December 4, 2018 09:03
Notes on authenticating REST APIs

Random Thoughts on Authentication in REST APIs

Disclaimer: I am not an auth expert, but I know someone who is. All errors and ramblings below are mine, not theirs.

First, some considerations:

  • Is your API a public data service or just the "backend piece" of your own web or mobile app?
  • Are you employing a third-party (e.g., "login with Facebook") or are you managing credentials yourself?
  • Basic auth or token auth?
  • Stateless (token fully contains verification info) or stateful (must consult data store every time to verify) tokens?
  • Long-lived tokens or short-lived tokens?
@rtoal
rtoal / codingchallenge.md
Created April 27, 2018 16:26
Swift Coding Challenge

Given a grid layout of Basic Latin letters as follows:

   A B C D E
   F G H I J
   K L M N O
   P Q R S T
   U V W X Y
   Z
@rtoal
rtoal / CMSI284S2018HW2.md
Last active February 6, 2018 02:03
CMSI 284 Spring 2018 Homework 2

Do all these problems without the aid of a computer, except where required to look up character names, character code points, and emoji data. The purpose of these exercises is for you to develop skills. If you spend the time to practice with pencil and paper (or a whiteboard) you will learn the material much better.

To submit your answers, copy the text below into a secret gist on GitHub and fill in the answers at the end of the same line. Email or DM me the url of the secret gist.

Make sure your Gist filename is CMSI284S2018HW2.md.

Your submission will be autograded so it is imperative that your answers are formmatted as expected. All encoded values should be in hex, not binary. Use the proper number of bits always; for example, UTF-32 answers must always show 8 hex digits, and characters should use the U+ prefix. MAKE SURE YOUR GIST HAS EXACTLY 50 LINES, NO MORE, NO LESS. Answers that are "correct" but not in the proper format will receive zero points, since answers that follow