Skip to content

Instantly share code, notes, and snippets.

@MelanieS
MelanieS / Fibonacci.rb
Last active August 29, 2015 13:58
Calculates user defined nth number in the Fibonacci sequence. Script doesn't utilize recursion.
puts "How many Fibonacci numbers would you like?"
n = gets.to_i
puts "Awesome! I'll get started on that right away!"
def fibonacci(n)
array = []
a,b = 0,1
n.times do
array << a
a,b = b,a+b
end
@MelanieS
MelanieS / name_sanitizer.pl
Last active August 29, 2015 13:58
Sanitizes user input (names) and prints out in form of "First M. Last"
#!/usr/bin/perl
use strict;
use warnings;
#Prints out the name in a "sanitized" form of "First M. Last"; that is, first name, space, middle initial, period, space, last name.
#If there is no middle name, prints the letter X with no period following it.
#If there are multiple middle names, uses the initial of the first one.
my $name = "Melanie Aurelia Shebel";
@MelanieS
MelanieS / step_and_time.rb
Last active August 29, 2015 14:02
Something
#ruby 2.2.1p85 (2015-02-26 revision 49769)
#energies files must contain time on left column, energy on right, separated by space
#change paths on line 73
energies = Dir.glob('*energies.txt')
energies = energies.pop
text = File.open(energies).read
text = text.to_s
array = text.split("\n")
<?php
wp_reset_postdata();
if(comments_open( ) || have_comments()) : ?>
<div class="comments-area">
<?php if ( post_password_required() ) : ?>
<p><?php _e( 'This post is password protected. Enter the password to view any comments ', 'zeon' ); ?></p>
</div>
<?php
/* Stop the rest of comments.php from being processed,
@MelanieS
MelanieS / course_tracker
Created July 9, 2014 20:15
PNC course tracker
#Purdue North Central doesn't have waitlists, but you can get notified of seat availability with this app
require 'rubygems'
require 'open-uri'
require 'hpricot'
require 'twilio-ruby'
availability = 0
puts "Enter the CRN for the PNC course you would like to track:"
crn = gets.chomp.to_s
@MelanieS
MelanieS / permute_tri.rb
Created September 11, 2015 02:38
permute_tri.rb
a = [60, -60]
# 4 refers to number of 60s or -60s in each element of array
a = a.repeated_permutation(6).to_a
puts "The array contains #{a.length} elements."
#creates output file called permute.txt
out_file = File.new("permute_out.txt", "w")
puts( ' <(^.^)> LITTLE KNOWN FACTS O\' MELANIE <(^.^)>')
puts
puts( 'To play, select the letter that corresponds with your answer
then press return')
answer = ''
while answer != 'c'
puts( '#1 Gym class sux. How would Melanie get out of running laps in Elem school?')
puts
puts( 'a. She got a doctors note')
# Is it customary to start variable counts at one? (ie. noun1) or
# at zero (ie. noun and the second being noun1) or how else is this
# handled?
print( 'Enter an adjective: ' )
adjective1 = gets.chomp()
print( 'Enter a verb ending in "ed": ')
verbEd = gets.chomp()
print( 'Enter a plural noun: ')
pluralNoun1 = gets.chomp()
# Try to figure out if there is a way to chomp & convert to an integer on
# same line (lines 7 and 8)
# Try to figure out how to print failure message (lines 14-16 & 20-22) for
# both cases in which the user is incorrect without having it in the program
# twice.
randNumber = rand(10)
randNumber = randNumber + 1
print( 'Guess my number! Enter a number (1-10): ')
userNumber = gets.chomp.to_i()
words = ['rocks', 'giraffes', 'nilla', 'dinosaur']
puts 'Need input! Input:'
input = gets.chomp
found = false
words.each do |i|
if input == i
found = true
end