This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Exam | |
attr_accessor :passes | |
attr_accessor :fails | |
def initialize(students) | |
@students = students | |
@passes = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
words = File.open('/usr/share/dict/words').read | |
words.gsub!(/\r\n?/, "") | |
hashes = {} | |
anagrams = {} | |
most = 1 | |
most_anagram = '' | |
words.each_line do |word| | |
word = word.strip.downcase |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# given an array of integers, find the largest value | |
def find_largest(numbers) | |
# initialize our "largest number" to the first number in the array | |
# because it is the largest so far | |
largest = numbers[0] | |
# looping over each number once | |
numbers.each do |i| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'pg' | |
class Orm | |
@@conn = PG.connect( | |
dbname: 'dfq35t7uirbums', | |
port: 5432, | |
user: 'bmdjwluxchptuq', | |
host: 'ec2-54-204-41-178.compute-1.amazonaws.com', | |
password: 'aEH-cKdr2zoXYUAjI8Xjma5eXK' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
r = { | |
"shrimp" => [ | |
"algae", | |
"other_shrimps", | |
"seaweed", | |
], | |
"toad" => [ | |
"children", | |
"flies", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
puts "Enter A" | |
a = gets.chomp | |
puts "Enter B" | |
b = gets.chomp | |
c = Integer(a) + Integer(b) | |
puts c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# must be baller and either furnished or rent cheaper than 2100 | |
def rent?(furnished, rent, baller) | |
if baller && furnished || rent < 2100 | |
return true | |
else | |
return false | |
end | |
end | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Built from Mohit Cheppudira's sine wave generator - http://0xfe.blogspot.com | |
// Modified by Murat Ayfer - http://muratayfer.com | |
soundWave = function(context) { | |
// xs is a list of x (time) values, one per wave. | |
// time is not represented as synchronized clicks or milliseconds, its passing is freq dependent | |
// so that's why we keep a value per each wave. | |
this.xs = []; | |
this.counter = 0; | |
this.context = context; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ORM | |
def save | |
table_name = self.class | |
sql_columns = self.instance_variables.map do |i| | |
i.slice(1, i.length) | |
end.join(', ') | |
sql_values = self.instance_variables.map do |i| | |
'"' << self.instance_variable_get("#{i}") << '"' |
OlderNewer