Skip to content

Instantly share code, notes, and snippets.

View cassyarchibald's full-sized avatar

Cassy cassyarchibald

  • Seattle
View GitHub Profile
@cassyarchibald
cassyarchibald / lru_cache.rb
Created April 8, 2019 03:11 — forked from ralbt/lru_cache.rb
Ruby: LRU Cache Implementation
class LRUCache
attr_reader :dll, :hash, :count, :capacity
def initialize(capacity)
@dll = DLL.new
@hash = Hash.new
@count = 0
@capacity = capacity
end
def read(key)
@cassyarchibald
cassyarchibald / LinkedList.java
Created February 9, 2019 21:54
Linked List Practice
package com.linkedlists;
public class LinkedList {
Node head;
// static so main can access the inner class
static class Node {
int data;
Node next;
@cassyarchibald
cassyarchibald / example-api.rb
Created October 30, 2018 20:12 — forked from CheezItMan/example-api.rb
My Example Ruby Code
require 'httparty' # If using Rails with a Gemfile, this require is not needed
require 'awesome_print'
# response = HTTParty.get('https://dog.ceo/api/breeds/image/random')
# puts response.code
# puts response.message
# puts response.body
require 'httparty'
require 'awesome_print'
KEY = "AIzaSyBP30mYnbwKpZ0lCHtp6FuvcNSjNG0GsGM"
PLACE_FROM_TEXT_STRING = "https://maps.googleapis.com/maps/api/place/findplacefromtext/json?inputtype=textquery"
DETAIL_STRING = "https://maps.googleapis.com/maps/api/place/details/json"
#Starter Code:
seven_wonders = ["Great Pyramid of Giza", "The Ishtar Gate", "Colossus of Rhodes", "Pharos of Alexandria", "Statue of Zeus at Olympia", "Temple of Artemis", "Mausoleum at Halicarnassus"]
# Array for student names
student_names = []
# Array for student id numbers
student_id_numbers = []
# Array for student email addresses
student_email_addresses = []
# Getting student input/generating student information
# Ask the user to enter the names, ages, and favorite colors of their
# closest friends (you may not assume that the user's close friends
# all have unique names). Output the total number of close friends
# under 18, followed by their names. Output the number of unique
# favorite colors, and then list them (Hint: Check out the uniq method
# of the Array class in Ruby).
# Your solution should use at least 1 hash and at least 1 array.
puts "Welcome to Hash Fun!. \nI will be asking your for the names, ages, and favorite colors of your closest friends.\n"
# Adding astricks to help separate each problem
print "\n" + ("*" * 50) + "\n"
puts "Create an array to store 5 names. Have the user enter in the 5 names and then print out the 5 names in all UPPERCASE all on the same line. Note that the user may not enter all the names in uppercase."
#####################################################
# Creating an empty array to hold names
names = []
# Running a times loop to get user input
5.times do
# Asking user for name
# Requirements
# You will start by creating three arrays:
# An array that will contain student names
student_names = []
# An array that will store student ID numbers
student_id_numbers = []
# An array that will contain student email addresses
student_email_addresses = []
class BankAccount
attr_reader :name
def initialize(name)
@name = name
@transactions = []
add_transaction("Beginning Balance", 0)
end
def credit(description, amount)