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
Last active Oct 9, 2019
CMSI 386 Practice Exam
View practice-midterm.md

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 / main.rs
Created Sep 14, 2019
The guessing game from the Rust book
View main.rs
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 / read_zipped_json_from_s3.py
Created Oct 1, 2014
Read gzipped JSON file from S3
View read_zipped_json_from_s3.py
import json
import gzip
import cStringIO
from boto.s3.connection import S3Connection
from boto.s3.key import Key
AWSACCESSKEY='********************'
AWSSECRETKEY='****************************************'
def read_gzipped_json_file_from_s3(bucket_name, key_name):
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, considering 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.
@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 / AnimalDemo.java
Created Oct 27, 2014
An example of inheritance and polymorphism in Java
View AnimalDemo.java
abstract class Animal {
private String name;
public Animal(String name) {
this.name = name;
}
public String speak() {
return name + " says " + sound();
}
public abstract String sound();
}
@rtoal
rtoal / rubin.py
Created Dec 14, 2013
Rubin's "'Goto Considered Harmful' Considered Harmful" as a Python One-Liner
View rubin.py
next((i for i,row in enumerate(a) if all(x == 0 for x in row)), -1)
@rtoal
rtoal / animals.scala
Created Oct 27, 2014
An example of inheritance and polymorphism in Scala
View animals.scala
abstract class Animal(name: String) {
def speak = name + " says " + sound
def sound: String
}
class Cow(name: String) extends Animal(name) {
override def sound() = "moooooo"
}
class Horse(name: String) extends Animal(name) {
@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

You can’t perform that action at this time.