Skip to content

Instantly share code, notes, and snippets.

@mayfer
mayfer / permissions.txt
Created February 6, 2015 19:34
file permissions
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)
@mayfer
mayfer / index.html.erb
Created February 6, 2015 19:35
flow player
<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>
@mayfer
mayfer / exceptions.rb
Created February 9, 2015 18:44
exceptions
class EmptyArrayError < StandardError
end
def avg(arr)
if arr.length == 0
raise EmptyArrayError, "Average can only be called on arrays that have values."
end
# 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)
@mayfer
mayfer / division.rb
Created February 9, 2015 18:51
division.rb
# 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)
@mayfer
mayfer / index.html
Created February 10, 2015 19:04
Example showing methods within instances of functions, via the "this" keyword. Also, chaining methods by returning "this" every time.
<html>
<head>
<style>
body { background: #358; color: #fff; padding: 50px; font-family: sans-serif; }
</style>
</head>
<body>
<script>
@mayfer
mayfer / index.html
Created February 10, 2015 19:09
jQuery todo list WITH ajax
<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;
}
@mayfer
mayfer / index.html
Created February 21, 2015 01:07
Node Websockets example (chat + cursors)
<!doctype>
<html>
<head>
<title>hi</title>
<style>
body, html {
background: #aaa;
font-family: monospace;
@mayfer
mayfer / new.html.erb
Created February 23, 2015 18:56
Intro to Sinatra
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="/style.css" />
</head>
<body>
<% if @loggedin == true %>
welcome, <%=@username %>
<a href='/logout'>Log out</a>
@mayfer
mayfer / clock.rb
Created February 28, 2015 00:28
Algorithms lecture notes
# find angle between clock hands
def angle(hour, minutes)
hour += (minutes / 60.0)
angle_hour = hour * 30
angle_mins = minutes * 6
(angle_hour - angle_mins).abs