Skip to content

Instantly share code, notes, and snippets.

@carolineartz
carolineartz / dabblet.css
Created June 15, 2013 21:13
The first commented line is your dabblet’s title
/**
* The first commented line is your dabblet’s title
*/
background: #f06;
background: linear-gradient(45deg, #f06, yellow);
min-height: 100%;
@carolineartz
carolineartz / facebook_response_array_total.rb
Last active January 2, 2016 09:59
.each vs. .length.times and TypeError
#total sum of array .each vs. .length.times
#using .length.times
def total(array)
sum = 0
#The length method returns the size of the array.
#Here, adding .times iterates the following block length times...
array.length.times do |x|
#...since the use of .times passes the parameter, x, 0 through (length -1),
#the block needs to get the value the array elements via index.
@carolineartz
carolineartz / challenge1_1_array_total.rb
Last active January 2, 2016 13:29 — forked from dbc-challenges/phase0_template_gist.rb
Exercise: Calculating the array total Write a method total which takes an Array of numbers as its input and returns their total (sum).
# PSEUDOCODE
# INPUT: an array of numbers
# OUPUT: sum of all numbers in array
# STEPS: start with a total of zero
# iterate over each element in the array
# for each element, add its value to the total
# return the total after there are no more elements
# INITIAL CODE:

OS X Apps

Alfred 2 & power pack

CodeRunner

*CodeGofer Download existing and create your own code recipe libraries (XML); search and copy to clip board via hotkey

image

@carolineartz
carolineartz / challenge1_1_letter_grade.rb
Last active January 2, 2016 23:49 — forked from dbc-challenges/phase0_template_gist.rb
Exercise: Calculate the letter grade of a series of grades Create a method get_grade that accepts an Array of test scores. Each score in the array should be between 0 and 100, where 100 is the max score. Compute the average score and return the letter grade as a String, i.e., 'A', 'B', 'C', 'D', 'E', or 'F'.
# PSEUDOCODE
# INPUT: array of grades
# OUPUT: a string representation of the letter grade that corresponds with
# the average score of the array of grades
# STEPS: Compute the average value of the values in teh input array
# divide the average by the length of input array => computes average score
# define letter grade distribution
# convert the average score to its corresponding letter grade
# return letter grade, as string
@carolineartz
carolineartz / challenge1_1_array_median.rb
Last active January 3, 2016 00:09 — forked from dbc-challenges/phase0_template_gist.rb
Exercise: Calculating the median of an array of numbers Write a method median which takes an Array of numbers as its input and returns the median value.
# CALCULATE THE MEDIAN OF AN ARRAY OF NUMBERS
# PSEUDOCODE
# INPUT: array of numbers
# OUPUT: the median number of the elements of the input array
# STEPS: sort the array
# determine if the array has one or two middle values by checking
# if the length is even or odd
# if there is an odd length, return the value of the middle element
# otherwise return the average of the two middle elements' values
@carolineartz
carolineartz / challenge1_1_pad_array1.rb
Last active January 3, 2016 00:09 — forked from dbc-challenges/phase0_template_gist.rb
Implement Array#pad and Array#pad!. Each method accepts a minimum size (non-negative integer) and an optional pad value as arguments. If the array's length is less than the minimum size, Array#pad should return a new array padded with the pad value up to the minimum size. If the minimum size is less than or equal to the length of the array, it s…
# CALCULATE THE MEDIAN OF AN ARRAY OF NUMBERS
# PSEUDOCODE
# INPUT: array object takes a non-negative integer minimum array size,
# optional value to pad which defaults to nil
# OUPUT: array object (#pad! returnning the same object while #pad
# will return a copy) which is padded conditional on its existing
# attributes and the passed parameters
# STEPS: for #pad! [#pad will do the same, but make a copy prior to executing
# anything with the potential to modify it] if the array is smaller than the
@carolineartz
carolineartz / Review_Others,_Refactor_Yours:_Pad_an_Array_solution.rb
Last active January 3, 2016 02:09
Solution for Review Others, Refactor Yours: Pad an Array
# Solution for Challenge: Review Others, Refactor Yours: Pad an Array. Started 2014-01-13T02:14:42+00:00
# FIRST ATTEMPT
## ORIGIAL CODE:
class Array
def pad!(min_size, value = nil)
if self.length < min_size
(min_size - self.length).times do
self << value
@carolineartz
carolineartz / challenge1_1_pad_array1.rb
Last active January 3, 2016 02:18 — forked from dbc-challenges/phase0_template_gist.rb
Implement Array#pad and Array#pad!. Each method accepts a minimum size (non-negative integer) and an optional pad value as arguments. If the array's length is less than the minimum size, Array#pad should return a new array padded with the pad value up to the minimum size. If the minimum size is less than or equal to the length of the array, it s…
# PSEUDOCODE
# INPUT: array object takes a non-negative integer minimum array size,
# optional value to pad which defaults to nil
# OUPUT: array object (#pad! returnning the same object while #pad
# will return a copy) which is padded conditional on its existing
# attributes and the passed parameters
# STEPS: for #pad! [#pad will do the same, but make a copy prior to executing
# anything with the potential to modify it] if the array is smaller than the