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 / read_zipped_json_from_s3.py
Created October 1, 2014 15:16
Read gzipped JSON file from S3
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):
@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 / AnimalDemo.java
Created October 27, 2014 04:22
An example of inheritance and polymorphism in 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 December 14, 2013 18:11
Rubin's "'Goto Considered Harmful' Considered Harmful" as a Python One-Liner
next((i for i,row in enumerate(a) if all(x == 0 for x in row)), -1)
@rtoal
rtoal / animals.scala
Created October 27, 2014 03:52
An example of inheritance and polymorphism in 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 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

@rtoal
rtoal / CMSI284S2018HW1.md
Last active January 17, 2018 00:04
CMSI 284 Spring 2018 Homework 1

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 December 20, 2017 19:19
Smart TV Virtual Keyboard Trace
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 October 14, 2017 00:01
Try this JavaScript/Python Test

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: