Skip to content

Instantly share code, notes, and snippets.

💭
Copying and pasting

Ray Toal rtoal

💭
Copying and pasting
Block or report user

Report or block rtoal

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@rtoal
rtoal / practice-midterm.md
Created Oct 27, 2018
CMSI 386 Practice Midterm
View practice-midterm.md

CMSI 386 Practice Midterm

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 Dec 4, 2018
Notes on authenticating REST APIs
View rest-auth-notes.md

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 Apr 27, 2018
Swift Coding Challenge
View codingchallenge.md

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 Feb 6, 2018
CMSI 284 Spring 2018 Homework 2
View CMSI284S2018HW2.md

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

@rtoal
rtoal / CMSI284S2018HW1.md
Last active Jan 17, 2018
CMSI 284 Spring 2018 Homework 1
View CMSI284S2018HW1.md

Do all these problems without the aid of a computer. 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 CMSI284S2018HW1.md.

Your submission will be autograded so it is imperative that your answers are formmatted as expected; for example, if a 32-bit hex value is required, you are to use 8 hex digits, without ever doing silly things like removing leading zeros or putting spaces or commas between digits. Same with binary values (never omit leading zeros) and with decimals (no spaces, no commas). MAKE SURE YOUR GIST HAS EXACTLY 64 LINES, NO MORE, NO LESS. Answers that are "correct" but not in the proper format will receive zero points, since answers that follow ins

@rtoal
rtoal / tv.swift
Last active Dec 20, 2017
Smart TV Virtual Keyboard Trace
View tv.swift
struct Coordinate {
var row: Int = 0
var col: Int = 0
}
var coordinateMapping: [Character: Coordinate] = {
var mapping: [Character: Coordinate] = [:]
for (index, letter) in "ABCDEFGHIJKLMNOPQRSTUVWXYZ".enumerated() {
mapping[letter] = Coordinate(row: index / 5, col: index % 5)
}
@rtoal
rtoal / Test.md
Created Oct 14, 2017
Try this JavaScript/Python Test
View Test.md

CMSI 386 Fall 2017 Exam 1

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 / sizes.cpp
Created Oct 2, 2017
A C++ program with a crazy macro to print ranges of numeric types
View sizes.cpp
#include <cstdint>
#include <climits>
#include <cassert>
#include <iostream>
using namespace std;
#define show_type_range(t, min, max)\
cout << #t << " (" << sizeof(t) << " bytes): " << min << ".." << max << '\n';
View [-8] < 0.md

Clojure

user=> (< [-8] 0)

ClassCastException clojure.lang.PersistentVector cannot be cast to java.lang.Number

Python 2 (BOOOOOOOOOOO)

>>> [-8] < 0
View JSFirst.md

JS First

About This Manifesto

Have you ever argued for or against teaching language X as the first language in a university computer science curriculum? If so, I hope that your arguments:

  • were first and foremost about students, not about your personal language preferences (in other words, you should answer the question “What do we want students to gain from their experience with a first language?”, not “Is language X better than language Y?” because the latter question requires too much context and isn’t really answerable);
  • kept in mind that ultimately we want to train polyglots, so the first language is never the only language; and
  • took into account previous work from computing educators, and education theorists and practitioners in general.
You can’t perform that action at this time.