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
@keyframes bounce { | |
0% { | |
-moz-transform: translateY(-40px); | |
-webkit-transform: translateY(-40px); | |
-ms-transform: translateY(-40px); | |
-webkit-transform: scale(0.2); | |
} | |
20%, 50%, 80%, 100% { | |
-moz-transform: translateY(0); |
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
#Permutations Recursive | |
def _add_head(head, res) | |
out = [] | |
res.each do |permutation| | |
0.upto(permutation.length) do |i| | |
_insert!(i, head, permutation, out) | |
end | |
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
##Subsets | |
#my first attempt | |
def subsets(set) | |
return set if set.length == 1 | |
return [[set[0]], [set[1]], set] if set.length == 2 | |
s = subsets(set[1..-1]) | |
[[set[0]]] + s.map{|x| x+[set[0]]} + s | |
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
def _log(a,b) | |
"move top disk from peg #{a} to peg #{b} \n" | |
end | |
def hanoi(n, s={from: 1, free: 2, to: 3}) | |
return _log(s[:from], s[:to]) if n == 1 | |
hanoi(n-1, {from: s[:from], free: s[:to], to: s[:free]}) + | |
_log(s[:from], s[:to]) + | |
hanoi(n-1, {from: s[:free], free: s[:from], to: s[:to]}) |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Jean Luc Picard - Resume</title> | |
<!--if you want to use the css file instead: | |
<link rel="stylesheet" href="stylesheet.css">--> | |
</head> | |
<style> |
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
#Examples from 'meta programming in Ruby' | |
#These methods save you from manually typing out each method for the wrapper class. | |
#If the data source is updated (new methods) you also don't need to update this wrapper class. | |
#Dynamic Dispatch | |
class Computer | |
def initialize(computer_id, data_source) | |
@id = computer_id | |
@data_source = data_source |
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
#Step 1 - Create achievement, badge, and user models | |
#Create an Achivement model | |
#This will contain all of the achievements | |
#model | |
class Achievement < ActiveRecord::Base | |
has_many :badges | |
has_many :users, through: :badges | |
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
#Multiplication table in Ruby with nested arrays | |
#[[1, 2, 3, 4], | |
# [2, 4, 6, 8], | |
# [3, 6, 9, 12], | |
# [4, 8, 12, 16]] | |
def multiplication_table(size) | |
Array.new(size) {|n| n+=1}.map do |row| | |
Array.new(size) {|col| col+=1; row*col} |
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
#Simple programming challenge in Ruby | |
#1) Reverse a string and array without using the ruby method 'reverse' | |
#2) Reverse a string and array recursively | |
#reverse string | |
def reverse(s) | |
i = 0 |
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
#My implementation of sorting algorithms in Ruby | |
#insertion sort | |
def sort_insert(a) | |
index = 1 | |
while index < a.length | |
value = a[index] | |
a[0...index].each_with_index do |sorted_value, i| | |
if value < sorted_value |