Skip to content

Instantly share code, notes, and snippets.

View ZASMan's full-sized avatar
🎯
Coding in Ruby as usual.

Zane ZASMan

🎯
Coding in Ruby as usual.
View GitHub Profile
@ZASMan
ZASMan / series.rb
Created February 19, 2019 18:48
code comparison
# First I had this
class Series
def initialize(numbers)
@numbers = numbers
@numbers_array = numbers.split("").map { |num_string| num_string.to_i }
end
def slices(substring_length)
substring_length = substring_length.to_int
if substring_length > @numbers_array.length
@ZASMan
ZASMan / difference_of_squares.rb
Created December 11, 2018 19:32
Difference of Squares: Exercism/Project Euler problem
class Squares
def initialize(number)
@number = number
end
def square_of_sum
(1..@number).to_a.sum ** 2
end
def sum_of_squares
@ZASMan
ZASMan / maros.js
Created September 22, 2018 18:06
code_for_marcos
document.addEventListener("DOMContentLoaded", function(event) {
// ID's should be unique
// Button to click and execute prompt
var my_button = document.getElementById("my_button_id");
// Try adding another element by ID. Such as a div to append the names to
// For example:
// var my_div = document.getElementById("my_div");
// This is attaching a click event function with the function
// buttonAlert to the myButton ID
myButton.addEventListener("click", buttonAlert);
@ZASMan
ZASMan / squarespace_orange.css
Created February 4, 2018 20:30
squarespace_orange_css
/* This changes the color of the font on the navbar folder items and removes black border from around the dropdown links for folder links*/
.tweak-header-primary-nav-hover-style-fader .Header-nav .Header-nav-folder {
background-color: none;
}
.Header-nav-folder {
border: none;
border: 0;
}
.Header-nav-folder-item {
background-color: rgb(237, 125, 12);
@ZASMan
ZASMan / my_model_relationships.rb
Last active February 1, 2018 16:54
my_model_relationships.rb
class User < ApplicationRecord
has_many :notebooks, dependent: :destroy
has_one :user_name, foreign_key: "id", dependent: :destroy
# Has an attribute of first_name
# As well as an attribute of last_name
end
class Notebook < ApplicationRecord
belongs_to :user, autosave: true
has_many :email_logs, as: :email_loggable, dependent: :destroy
@ZASMan
ZASMan / pet.rb
Created October 15, 2015 11:35
pet.rb
class Pet
attr_reader :color, :breed
attr_accessor :name
def initialize(color, breed)
@color = color
@breed = breed
@hungry = true
end
def feed (food)
puts "Mmmm, " + food + "!"
@ZASMan
ZASMan / cat.rb
Created October 15, 2015 11:11
cat.rb
class Cat
attr_reader :color, :breed
attr_accessor :name
def initialize(color, breed)
@color = color
@breed = breed
@hungry = true
end
def feed (food)
puts "Mmmm, " + food + "!"
@ZASMan
ZASMan / fav_foods.rb
Last active October 15, 2015 10:27
fav_foods.rb
def food_array
["IceCream", "Pizza", "Rice"]
end
3.times do
puts "Chicken."
food_array << gets.chomp
end
def fav_foods
@ZASMan
ZASMan / program4.rb
Created October 13, 2015 02:18
program4.rb
3.times do
puts "Hello!"
end
number = 0
#while (number <= 10) do # while this condition is true, do...
#p "the number is now #{number}" # whatever is in this code block
#number += 1 # short for number = number + 1
#end # don’t forget your end
@ZASMan
ZASMan / program3.rb
Created October 13, 2015 02:17
program3.rb
def choose
puts "Do you like programming? Yes or no please."
choice = gets.chomp
case choice.downcase
when "yes"
puts "That\'s great!"
when "no"
puts "That\s too bad!"
when "maybe"
puts "Glad you are giving it a chance!"