Skip to content

Instantly share code, notes, and snippets.

View jjfiv's full-sized avatar
🦀
RiiR

John Foley jjfiv

🦀
RiiR
View GitHub Profile
import sys
import socket
from time import time
args = sys.argv[1:]
if len(args) not in [1,2]:
print("usage: tls_prank_call hostname [port]")
hostname = args[0]
port = 443 if len(args) == 1 else int(args[1])
@jjfiv
jjfiv / GuessingGame.java
Last active February 18, 2022 17:22
P2 CS201 GuessingGame starter
import java.util.Random;
import java.util.Scanner;
// We discussed academic honesty, so when you re-type this code, be sure to cite it in a comment!
// This is the only time you MUST cite code from me, the instructor.
public class GuessingGame {
/** One more than the highest possible number in the game. */
private static final int HIGH = 100;
/** The lowest possible number in the game. */
@jjfiv
jjfiv / Welcome.java
Last active February 13, 2022 13:31
CS201 First Java File
/**
* Every Java file must have a class defined in it!
* Notice that the name of this file is Welcome.java
* .. and we define class Welcome!
* .. that's super important to Java. It's picky like that.
*/
public class Welcome {
/**
* Don't change any details about the outside of this `main` function
* ... it needs to be precise!
@jjfiv
jjfiv / complexity_lab.py
Created December 2, 2021 21:09
Project 9 Starter Bits
import timeit
# Complexity experiment time.
# Both sum_1x and sum_2x are O(n) functions.
# Let's investigate which is faster AND see if it's linear.
def sum_2x(target: list) -> int:
total = 0
for x in target:
@jjfiv
jjfiv / gfx.py
Last active November 16, 2021 00:02
Working on a Pygame Wrapper for CS145
import pygame
import random
__version__ = "2021.11.15.0"
class SimplePygame:
def __init__(self, screen):
self.screen = screen
self.has_quit = False
self.fonts = {}
@jjfiv
jjfiv / 17b_notes.py
Created November 11, 2021 17:20
CS145 Midterm Review #2: 17b_notes.py
# 17b_notes.py
## Recursion Breakdown
def countdown(n: int):
print("begin: countdown(",n,")")
if n == 0:
print("output:\t\tBlastoff!")
else:
print("before:\t\t", n)
@jjfiv
jjfiv / proj7_starter.py
Last active November 5, 2021 13:15
CS145 F2021 Project 7
###
# Recursive GCD:
#
# One of the oldest known algorithms, dating back to the
# 5th century BCE, is Euclid’s algorithm for computing the
# greatest common divisor (GCD) of two integers.
#
# The GCD of 36 and 24 is 12.
# It works as follows:
# Let a, b be positive integers.
@jjfiv
jjfiv / proj6_starter.py
Last active October 29, 2021 13:22
CS145 F2021 Project 6 Public
from typing import List, Tuple, Dict
ROOM = {
"name": "basement",
"description": """You have found the basement of the mansion.
It is darker down here.
You get the sense a secret is nearby, but you only see the stairs you came from.""",
"exits": [
{
"destination": "entranceHall",
@jjfiv
jjfiv / proj5_starter.py
Created October 22, 2021 11:52
CS145 F2021 Project 5 Starter Code
import os
from typing import List
def diff_compress(numbers: List[int]) -> List[int]:
previous = 0
encoded = []
for n in numbers:
encoded.append(n - previous)
previous = n
@jjfiv
jjfiv / proj4_starter.py
Created October 14, 2021 18:54
CS145-F2021 Project 4 Starter Code
def maxmin(xs):
"""
This function simultaneously computes the maximum
and the minimum values present in a list.
Input: a list of ordered values.
Returns: [maximum, minimum] or [None, None] for an empty list.
"""
minimum = None
maximum = None