Skip to content

Instantly share code, notes, and snippets.

View alpha-tango's full-sized avatar

A. Pope alpha-tango

View GitHub Profile
@alpha-tango
alpha-tango / linked_list.rb
Created October 27, 2014 22:52
Linked List Implementation
class LinkedList
def initialize
@head = nil
end
def each
node = @head
while !node.nil?
yield(node.data)
#You can get the recent articles by saving the data daily
#and look for the differences between the new data and the saved data
#unfortunately, saving all of the data from the NYT API might take up a lot of space
#you will probably need to create an event trigger that takes snapshots of the JSON data sent once a day.
json_data_from_api = articles_from_today
#today_total has each element be an article. The array contains all the articles created up to date.
@alpha-tango
alpha-tango / guess.js
Created September 15, 2014 18:10
Incredibly fun random number game
var randomNumber = Math.round(Math.random()*10+1);
var userName = prompt("What is your name?");
var guess = prompt(userName+", please guess a number between 1 and 10:");
if (guess == randomNumber) {
alert("You're so special, "+userName+", you totally won this game!!! zomg");
} else {
alert("You suck at life, "+userName+", you can't even guess a number right.");
@alpha-tango
alpha-tango / minefield.rb
Created September 7, 2014 00:35
My implementation of minefield.rb
class Minefield
attr_reader :row_count, :column_count, :mine_count, :cleared_cells, :mines
def initialize(row_count, column_count, mine_count)
@column_count = column_count
@row_count = row_count
@mine_count = mine_count
@cleared_cells = []
@mines = place_mines
@alpha-tango
alpha-tango / round_robin.rb
Created September 1, 2014 22:09
The robin monster
require 'pry'
def schedule_tournament(names)
tournament = []
round = []
# n = names.length
round_count = (n-1)
pnames = names.dup
@alpha-tango
alpha-tango / simple_sort.rb
Created September 1, 2014 21:02
The sorting monster
require 'pry'
def sort_list(arr)
list_array=arr.split(' ')
list_array.map!{|num| num.to_f}
rec_sort_list(list_array, [])
end
def rec_sort_list(list, sorted)
@alpha-tango
alpha-tango / objects.rb
Created August 29, 2014 19:35
Quick Challenge: TV objects
class TV
def initialize(size,brand)
@size = size
@brand = brand
end
end
class Channel(network)
@network = network
@channel_number = channel_number
@alpha-tango
alpha-tango / marker.rb
Created August 29, 2014 16:14
Dry Erase Boards & Markers
class Whiteboard
attr_accessor :contents
def initialize(contents = [])
@contents = contents
end
def erase
@contents = []
end
@alpha-tango
alpha-tango / card_getters.rb
Created August 29, 2014 15:45
Getters for Card Class
class Card
def initialize(rank, suit)
@suit = suit
@rank = rank
end
def rank
@rank
end
@alpha-tango
alpha-tango / getters.rb
Last active August 29, 2015 14:05
Getters
class Car
def initialize(color, owner, cylinders)
@color = color
@owner = owner
@cylinders = cylinders
end
def color
@color
end