Skip to content

Instantly share code, notes, and snippets.

View css animations
@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);
View permutation_recursive.rb
#Permutations Recursive
def _add_head(head, res)
out = []
res.each do |permutation|
0.upto(permutation.length) do |i|
_insert!(i, head, permutation, out)
View subsets_recursion_ruby.rb
#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]]] +{|x| x+[set[0]]} + s
View hanoi-ruby.rb
def _log(a,b)
"move top disk from peg #{a} to peg #{b} \n"
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]})
View CVTemplate.html
<!DOCTYPE html>
<html lang="en">
<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">-->
View Dynamic dispatch and Method Missing in Ruby
#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
Yorgg / badge_creator.rb
Last active Mar 18, 2020
Creating badge and achievements functionality in Ruby on Rails
View badge_creator.rb
#Step 1 - Create achievement, badge, and user models
#Create an Achivement model
#This will contain all of the achievements
class Achievement < ActiveRecord::Base
has_many :badges
has_many :users, through: :badges
Yorgg / multiplication_table.rb
Last active Aug 29, 2015
Multiplication table in ruby
View multiplication_table.rb
#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) {|n| n+=1}.map do |row| {|col| col+=1; row*col}
Yorgg / reverse-ruby.rb
Last active Aug 29, 2015
Reverse Ruby Methods
View reverse-ruby.rb
#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
Yorgg / sort-ruby.rb
Last active Aug 29, 2015
Sorting in Ruby
View sort-ruby.rb
#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
You can’t perform that action at this time.