Skip to content

Instantly share code, notes, and snippets.

View ybur-yug's full-sized avatar

yburyug ybur-yug

View GitHub Profile
@ybur-yug
ybur-yug / nums_to_roman_nums.rb
Last active December 21, 2015 23:18
turns regular numbers to roman numerals up to 3999. Epicodus exercise
def roman_nums(number)
romans = {
1 => "I",
2 => "II",
3 => "III",
4 => "IV",
5 => "V",
6 => "VI",
7 => "VII",
8 => "VIII",
@ybur-yug
ybur-yug / nucleotide_counter.rb
Last active December 21, 2015 23:18
Nucleotide counter. Takes input of ATGC sequence form dna and returns number of each type in the string using basic regex and a hash. Epicodus exercise.
def nucleo_counter(sequence)
g = sequence.gsub(/[ATC]/, "").length
c = sequence.gsub(/[ATG]/, "").length
a = sequence.gsub(/[GCT]/, "").length
t = sequence.gsub(/[AGC]/, "").length
nucleotides = {
"A's" => a,
"T's" => t,
"G's" => g,
"C's" => c
@ybur-yug
ybur-yug / phone_num_formatter.rb
Last active December 21, 2015 23:18
Phone number formatter. Takes a phone number in any format X, (rjowgij4195205bw300iofjs to 1(319)4920502, etc) and returns it in proper 1(xxx)-xxx-xxxx format. Epicodus exercise.
def phone_format(number)
phone_number = num_scrub(number)
real_number = phone_number.split("")
if real_number.length < 11
num_sections = [["("],[],[]]
num_sections[0].push(real_number[0...3])
num_sections[1] = real_number[3...6]
num_sections[2] = real_number[6..-1]
num_sections[0].push(")-")
@ybur-yug
ybur-yug / anagram_detector.rb
Last active December 21, 2015 23:18
Anagram detector. returns true if input word is an anagram of anything in the input array possible_anagrams.
def anagrams(word, possible_anagrams)
individual_letters = []
anagrams = []
possible_anagrams.each do |anagram|
individual_letters.push((anagram.split("")))
end
individual_letters.each do |anagram|
anagram.sort!
end
individual_letters.each do |words|
@ybur-yug
ybur-yug / wordy_calc.rb
Last active December 21, 2015 23:18
Takes input in the form of "what is 5 plus 9" "what is 9 multiplied by 13" etc. words with * - / + for single operations or multiple of the same operation.
def wordy_calc(question)
i = 0
operation_plus = question.match(/(plus)/).to_s
operation_minus = question.match(/(minus)/).to_s
operation_times = question.match(/(multiplied)/).to_s
operation_div = question.match(/(divided)/).to_s
question_arr = question.split(" ")
question_arr.each do |word|
word.gsub!(/\D/, '')
end
notification :terminal_notifier
guard :rspec do
watch('spec/spec_helper.rb') { "spec" }
watch('config/routes.rb') { "spec/routing" }
watch('app/controllers/application_controller.rb') { "spec/controllers" }
watch('spec/spec_helper.rb') { "spec" } # purely a failsafe to ensure spec_helper stays classy
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
## Test
### Some Text
- thing
- stuff
- woooo
"<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/><title>Ahalogy Pin Report</title></head><body><h1 class=\"wordmark\">Ahalogy</h1><div class=\"container\"><div class=\"stuff\">[\"<div class='pin>'<div class='image'>https://res.cloudinary.com/ahalogy/image/upload/21a35e531d5f6ae930884223012c696e.jpg</div><div class='pin_inner'> We talked about these in episode 2 of WTHAYE<div class='board'> 573786877463664698</div>div class='link'> http://online.wsj.com/article/SB10001424127887323852904578129171392996966.html?_szp=215081</div></div></div>\"]</div></div></body></html>"
"http://www.kraftrecipes.com/recipes/dinner/seafood/seafood-salad/main.aspx?cm_mmc=Social-_-Pinterest-_-Ahalogy-_-seafood-salad\rhttp://www.kraftrecipes.com/recipes/quinoa-feta-vegetables-154953.aspx?cm_mmc=Social-_-Pinterest-_-Ahalogy-_-154953\rhttp://www.kraftrecipes.com/recipes/quinoa-broccoli-cheese-bacon-126229.aspx?cm_mmc=Social-_-Pinterest-_-Ahalogy-_-126229\rhttp://www.kraftrecipes.com/recipes/greek-yogurt-cheesecake-123265.aspx?cm_mmc=Social-_-Pinterest-_-Ahalogy-_-123265\rhttp://www.kraftrecipes.com/recipes/tropical-fruit-dip-124312.aspx?cm_mmc=Social-_-Pinterest-_-Ahalogy-_-124312\rhttp://www.kraftrecipes.com/recipes/parmesan-roasted-tomatoes-139118.aspx?cm_mmc=Social-_-Pinterest-_-Ahalogy-_-139118\rhttp://www.kraftrecipes.com/recipes/lemon-raspberry-mousse-squares-115432.aspx?cm_mmc=Social-_-Pinterest-_-Ahalogy-_-115432\rhttp://www.kraftrecipes.com/recipes/cheesy-hash-browns-65191.aspx?cm_mmc=Social-_-Pinterest-_-Ahalogy-_-65191\rhttp://www.kraftrecipes.com/recipes/chorizo-potato-green-chile-omele
"vundle stuff
set nocompatible
filetype off
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
Bundle 'gmarik/vundle'
Bundle 'kien/ctrlp.vim'
Bundle 'rking/ag.vim'
Bundle 'bling/vim-airline'
Bundle 'tpope/vim-fugitive'