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 FileManager | |
attr_reader :file, :file_name | |
def initialize(file_name) | |
@file_name = file_name | |
load_file | |
end | |
def load_file | |
@file = File.open(@file_name, "r") |
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
module FileHandler | |
def self.load_from_file(filename) | |
File.open(filename, "r") | |
end | |
end | |
class Card | |
attr_reader :keyword, :definition | |
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 'net/smtp' | |
list_of_messages = [] | |
File.readlines('new_titles.txt').each do |line| | |
list_of_messages << "Subject: #{line.strip!}\n\nYOU ARE ONE STINKY FILTHY WHORE!!! Have fun removing all the emails buddy lol" | |
end | |
smtp = Net::SMTP.new('smtp.gmail.com', 587) | |
smtp.enable_starttls |
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
function SimpleSymbols(str) { | |
if ( str.length == 0 || !str.match(/[a-zA-Z]/) ) | |
return false; | |
for ( var i = 0; i < str.length; i++ ) { | |
if ( str[i].match(/[a-zA-Z]/) ) { | |
var v = [str[i-1] == '+', str[i+1] == '+'].every(function (e, idx, ary) { | |
return ( e == true ); | |
}); | |
if ( v == false ) | |
return false; |
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
function nearestLargest(ary, i) { | |
var finds = []; | |
ary.forEach(function (el, idx, ary) { | |
if (ary[idx] > ary[i]) | |
finds.push(el); | |
}); | |
return finds.sort()[0]; | |
} |
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
// Using the JavaScript language, have the function MeanMode(arr) take the array of numbers stored in arr and return 1 if | |
// the mode equals the mean, 0 if they don't equal each other (ie. [5, 3, 3, 3, 1] should return 1 because the mode (3) equals | |
// the mean (3)). The array will not be empty, will only contain positive integers, and will not contain more than one mode. | |
// Input = 1, 2, 3Output = 0 | |
// Input = 4, 4, 4, 6, 2Output = 1 | |
function MeanMode( arr ) { | |
var sum = 0; | |
arr.forEach( function ( el, idx, ary ) { |
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
// Using the JavaScript language, have the function DashInsert(num) insert dashes ('-') between each two odd numbers in num. | |
// For example: if num is 454793 the output should be 4547-9-3. Don't count zero as an odd number. | |
// Input = 99946 Output = "9-9-946" | |
// Input = 56730 Output = "567-30" | |
function DashInsert( num ) { | |
var dashI = ''; | |
var nums = ( num ).toString().split( '' ); | |
for ( var i = 0; i < nums.length; 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
// Using the JavaScript language, have the function SwapCase(str) take the str parameter and swap the case of each character. | |
// For example: if str is "Hello World" the output should be hELLO wORLD. Let numbers and symbols stay the way they are. | |
// Input = "Hello-LOL" Output = "hELLO-lol" | |
// Input = "Sup DUDE!!?" Output = "sUP dude!!?" | |
function SwapCase( str ) { | |
var swap = ''; | |
for ( var i = 0; i < str.length; i++ ) { | |
if ( str[i] == str[i].toUpperCase() ) |
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
// Using the JavaScript language, have the function NumberSearch(str) take the str parameter, search for all the numbers in the | |
// string, add them together, then return that final number. For example: if str is "88Hello 3World!" the output should be 91. | |
// You will have to differentiate between single digit numbers and multiple digit numbers like in the example above. So | |
// "55Hello" and "5Hello 5" should return two different answers. Each string will contain at least one letter or symbol. | |
// Input = "75Number9" Output = 84 | |
// Input = "10 2One Number*1*" Output = 13 | |
function numCoverter( str ) { | |
var sum = 0; |
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
// Using the JavaScript language, have the function ThirdGreatest(strArr) take the array of strings stored in strArr and return // the third largest word within in. So for example: if strArr is ["hello", "world", "before", "all"] your output should be | |
// world because "before" is 6 letters long, and "hello" and "world" are both 5, but the output should be world because it | |
// appeared as the last 5 letter word in the array. If strArr was ["hello", "world", "after", "all"] the output should be after // because the first three words are all 5 letters long, so return the last one. The array will have at least three strings and // each string will only contain letters. | |
// Input = "coder","byte","code" Output = "code" | |
// Input = "abc","defg","z","hijk" Output = "abc" |