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
# big text for timed tests | |
big_text = "The RSVP Hello message exchange was introduced in [RFC3209]. The | |
usage of RSVP Hello has been extended in [RFC3473] to support RSVP | |
Graceful Restart (GR) procedures. | |
More specifically, [RFC3473] specifies the use of the RSVP Hello | |
messages for GR procedures for Generalized MPLS (GMPLS). GMPLS | |
introduces the notion of control plane and data plane separation. In | |
other words, in GMPLS networks, the control plane information is | |
carried over a control network whose end-points are IP capable and | |
that may be physically or logically disjoint from the data bearer |
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 Volume_To_Shapes | |
def initialize volume_input | |
@volume_input = volume_input | |
@height = cube_root @volume_input | |
get_cube_dimensions | |
get_sphere_dimensions | |
get_cylinder_dimensions | |
get_cone_dimensions | |
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
class Rail_Fence_Cipher | |
def initialize instruction, number, text | |
@letter_array = text.split("") | |
@text_length = text.length | |
@number = number | |
case instruction | |
when "encrypt" | |
encrypt |
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
# Brute Force | |
# Takes a string and a pattern and returns the index of the pattern in the string, | |
# or returns "not found" | |
def brute_search string, pattern | |
pattern_length = pattern.length | |
for string_index in (0... string.length) | |
match_count = 0 | |
loop do | |
# if a non-match is found, then break. |
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
#Brute Force Right to Left | |
# Function accepts a string and a pattern to find in that string | |
def brute_search_2 string, pattern | |
pattern_length = pattern.length | |
# Iterate through the string starting at string[pattern_length-1] | |
# We are starting there because we are looking for matches in the pattern starting | |
# at the last char. | |
for string_index in (pattern_length - 1 ... string.length) | |
match_count = 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
#First iteration moving towards Harspool algorithm simply jumps forward by | |
# pattern_length if char not in pattern is found | |
# function accepts a string and a pattern and returns the index in the string where | |
# the pattern first occurs, or "not found" | |
def brute_search_2 string, pattern | |
pattern_length = pattern.length | |
bad_match_table = Hash.new | |
# Generates hash table with keys as all chars in pattern, and values as true |
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
#Horspool algorithm implements the good suffix rule. | |
# If the char is not present, it still skips ahead by the length of the pattern. | |
# If the char is not a match, but it is present in the string, it jumps forward by the appropriate ammount. | |
# pattern_length if char not in pattern is found | |
# function accepts a string and a pattern and returns the index in the string where | |
# the pattern first occurs, or "not found" | |
def brute_search_2 string, pattern | |
pattern_length = pattern.length | |
bad_match_table = Hash.new |
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 KMP | |
attr_reader :results | |
def initialize string, pattern | |
@string = string | |
@pattern = pattern | |
@string_length = string.length | |
@pattern_length = pattern.length | |
@table = kmp_table | |
@results = [] | |
kmp |
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
# UPDATED 7/15 | |
# Thanks to kootenpv for the code review! | |
# This makes it easy to create a reddit bot that | |
# A. Grabs comments from subreddits of your choice | |
# B. Searches for a keyword | |
# C. Replies to comments with that keyword from a list of responses on a CSV file | |
# Follow correct etiquette: | |
# https://www.reddit.com/r/Bottiquette |
We can make this file beautiful and searchable if this error is corrected: It looks like row 3 should actually have 2 columns, instead of 4 in line 2.
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
“I think of going to the grave without having a psychedelic experience like going to the grave without ever having sex. It means that you never figured out what it is all about. The mystery is in the body and the way the body works itself into nature.”, | |
“Stop consuming images and start producing them.”, | |
“You are a divine being. You matter, you count. You come from realms of unimaginable power and light, and you will return to those realms.”, | |
“You are an explorer, and you represent our species, and the greatest good you can do is to bring back a new idea, because our world is endangered by the absence of good ideas. Our world is in crisis because of the absence of consciousness.”, | |
“The male dominant agenda is so fragile that any competitor is felt as a deadly foe.”, |
OlderNewer