This file contains hidden or 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
<html> | |
<head> | |
<style> | |
body { background: #358; color: #fff; padding: 50px; font-family: sans-serif; } | |
a { color: #fff; font-size: 40px; } | |
section { | |
width: 800px; | |
margin: 0px auto; | |
} |
This file contains hidden or 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
<html> | |
<head> | |
<style> | |
body { background: #358; color: #fff; padding: 50px; font-family: sans-serif; } | |
</style> | |
</head> | |
<body> | |
<script> |
This file contains hidden or 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
# implement division without using multiplication or division operators. | |
# return the result and the remainder. | |
# this implementation uses addition for the sum | |
def divide(number, divisor) | |
count = 0 | |
sum = 0 | |
while sum <= (number - divisor) |
This file contains hidden or 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
# implement division without using multiplication or division operators. | |
# return the result and the remainder. | |
# this implementation uses addition for the sum | |
def divide(number, divisor) | |
count = 0 | |
sum = 0 | |
while sum <= (number - divisor) |
This file contains hidden or 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 EmptyArrayError < StandardError | |
end | |
def avg(arr) | |
if arr.length == 0 | |
raise EmptyArrayError, "Average can only be called on arrays that have values." | |
end |
This file contains hidden or 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
<script src="//embed.flowplayer.org/5.5.2/embed.min.js"> | |
<div class="flowplayer" style="width: 624px; height: 400px;"> | |
<video> | |
<source type="video/mp4" src="/data/mp4.mp4"> | |
</video> | |
</div> | |
</script> |
This file contains hidden or 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
File Permissions | |
1 2 3 | |
- --- --- --- | |
d rwx rwx rwx | |
r: Read | |
w: Write | |
x: Execute (execute file as a program, or execute directory meaning see contents of directory) | |
This file contains hidden or 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 FilesController < ApplicationController | |
def index | |
end | |
def upload | |
upload = params[:babyfile] | |
name = upload.original_filename | |
directory = "public/data" | |
# create the file path |
This file contains hidden or 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
def select(arr) | |
arr.each do |elem| | |
if yield elem | |
puts elem | |
end | |
end | |
end | |
select([1, 5, 7, 2, 4, 6]) do |elem| | |
elem % 2 == 1 |
This file contains hidden or 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
def find_longest_palindromes | |
words = File.open('/usr/share/dict/words').read | |
longest_words = [] | |
words.each_line do |line| | |
word = line.strip |